163 lines
4.8 KiB
HTML
163 lines
4.8 KiB
HTML
<script type="text/javascript">
|
||
const CommonMixin = {
|
||
data(){
|
||
return {
|
||
}
|
||
},
|
||
methods:{
|
||
async CommonGetImageData(type){
|
||
var self = this;
|
||
self.CommonSetHash();//设置hash
|
||
self.ImageProps.urlparam = self.CommonSetParam();//获取提交参数
|
||
self.$nextTick(function(){
|
||
self.$refs.RefImageLayout.restart()
|
||
});
|
||
if(self.headerkeyword){
|
||
let param = {
|
||
keyword:self.headerkeyword,
|
||
};
|
||
axios.post('index.php?mod=banner&op=appajax&do=addsearch',param);
|
||
}
|
||
},
|
||
CommonSetHash(){
|
||
var self = this;
|
||
var ScreenParam = self.$refs.ScreenBoxRef.GetParam('hash');
|
||
var Params = {}
|
||
if(self.DocumentAppid){
|
||
Params['id'] = self.DocumentAppid;
|
||
}
|
||
if(self.headerkeyword){
|
||
Params['keyword'] = self.headerkeyword;
|
||
}
|
||
Params = {...Params,...ScreenParam,};
|
||
var arr = [];
|
||
for(var key in Params){
|
||
arr.push(key+'='+Params[key]);
|
||
}
|
||
var hash = arr.join('&');
|
||
location.hash=hash;
|
||
},
|
||
CommonSetParam(){
|
||
var self = this;
|
||
var Params = {};
|
||
var ScreenParam = self.$refs.ScreenBoxRef.GetParam();
|
||
// var OrderParam = self.HeaderRightBtnGetParam();
|
||
var OrderParam = {};
|
||
if(self.DocumentAppid){
|
||
Params['sid'] = self.DocumentAppid;
|
||
}
|
||
if(self.headerkeyword){
|
||
Params['keyword'] = self.headerkeyword;
|
||
}
|
||
if(ScreenParam && ScreenParam.classify){
|
||
this.ScreenParam.fids = ScreenParam.classify
|
||
}
|
||
return {...Params,...ScreenParam,...OrderParam};
|
||
},
|
||
CommonGetHashParam(name,url){
|
||
let hash=location.hash;
|
||
if(url){
|
||
url=hash.replace(/&.+$/i,'').replace('#','');
|
||
}else{
|
||
url=location.hash;
|
||
}
|
||
if (!name) {
|
||
return '';
|
||
}
|
||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
||
if (!url) {
|
||
return '';
|
||
}
|
||
var r = url.match(reg);
|
||
if (r !== null) {
|
||
return decodeURIComponent(r[2]);
|
||
}
|
||
},
|
||
CommonDeleteAll(){
|
||
const self = this;
|
||
this.HeaderKeyword = '';
|
||
self.$refs.ScreenBoxRef.DeleteAll();
|
||
this.CommonGetImageData();
|
||
|
||
},
|
||
async CommonInit(){
|
||
const self = this;
|
||
//主题颜色
|
||
let theme = localStorage.getItem('theme');
|
||
if(theme){
|
||
this.DocumentThemeColor=theme;
|
||
}else{
|
||
this.DocumentThemeColor = 'light'
|
||
}
|
||
const {data: res} = await axios.post('index.php?mod=search&op=ajax&operation=getpagesetting',{
|
||
sid:this.DocumentAppid,
|
||
});
|
||
if(res.data){
|
||
var getpagesetting = res.data;
|
||
}
|
||
this.screenType.type = getpagesetting && getpagesetting.filterstyle?parseInt(getpagesetting.filterstyle):0;
|
||
|
||
|
||
this.screenType.show = true;
|
||
|
||
|
||
this.OpenDetailType = getpagesetting && getpagesetting.opentype || 'new';
|
||
//筛选显示隐藏
|
||
let showscreen = sessionStorage.getItem('showscreen');
|
||
if(parseInt(showscreen) > -1){
|
||
this.Screenshow = parseInt(showscreen)?true:false;
|
||
this.HeaderRightBtnScreen.active = parseInt(showscreen);
|
||
}
|
||
|
||
//布局方式
|
||
|
||
this.HeaderRightBtnShow.layout = getpagesetting && getpagesetting.layout || 'waterFall';
|
||
this.ImageProps.layout = getpagesetting && getpagesetting.layout || 'waterFall';
|
||
//其它信息
|
||
|
||
if(getpagesetting && getpagesetting.display && getpagesetting.display.indexOf('other') > -1){
|
||
this.HeaderRightBtnShow.other = getpagesetting && getpagesetting.other || '';
|
||
this.ImageProps.ShowMessage.other = getpagesetting && getpagesetting.other || '';
|
||
}else{
|
||
this.ImageProps.ShowMessage.other = '';
|
||
}
|
||
//显示信息
|
||
|
||
this.HeaderRightBtnShow.display = getpagesetting && getpagesetting.display || [];
|
||
this.ImageProps.ShowMessage.display = getpagesetting && getpagesetting.display || [];
|
||
//排序方式
|
||
|
||
this.HeaderRightBtnShow.sort = getpagesetting && getpagesetting.desc || 'desc';
|
||
|
||
this.HeaderRightBtnShow.order = getpagesetting && getpagesetting.sort || 'btime';
|
||
|
||
self.$nextTick(function(){
|
||
self.CommonGetImageData();
|
||
})
|
||
},
|
||
CommonHighlight(text,words){
|
||
// 默认的标签,如果没有指定,使用span
|
||
var i, len = words.length,
|
||
re;
|
||
//匹配每一个特殊字符 ,进行转义
|
||
var specialStr = ["*", ".", "?", "+", "$", "^", "[", "]", "{", "}", "|", "\\", "(", ")", "/", "%"];
|
||
for (let index = 0; index < specialStr.length; index++) {
|
||
const item = specialStr[index];
|
||
if(words.indexOf(item) != -1) {
|
||
words = words.replace(new RegExp("\\" + item, 'g'), "\\" + item);
|
||
}
|
||
}
|
||
// $.each(specialStr, function(i, item) {
|
||
|
||
// });
|
||
//匹配整个关键词
|
||
re = new RegExp(words, 'g');
|
||
if(re.test(text)) {
|
||
text = text.replace(re, '<span class="highlight">$&</span>');
|
||
}
|
||
return text;
|
||
},
|
||
|
||
}
|
||
}
|
||
</script> |