var ruoguang = {
jsrun: function () {
ruoguang.allpage()
var pageof = $('.pagebox').attr('id')
// 执行对应页面js编写,每加一个模版页面都要添加
switch (pageof) {
case 'indexpage':
ruoguang.indexpage()
yes('首页', pageof)
break;
case 'searchcenpage':
ruoguang.searchcenpage()
yes('销售定制中心', pageof)
break;
default:
if (ruoguang[pageof] == undefined) {
console.log('%c页面无自定义js', 'color:red;line-height: 4em;font-size:14px')
}
break;
}
// pd('#aboutpage',ruoguang.about())
ruoguang.lastallpage()
function yes(str) {
console.log('%c成功加载:' + str + 'js', 'color:red;line-height: 4em;font-size:14px')
console.log('%c开发js请在ruoguang.js中搜索' + pageof + ': function', 'color:red;line-height: 4em;font-size:14px')
}
},
allpage: function() {
var navnum = $('.nav .num')
for (let i = 0; i < navnum.length; i++) {
navnum.eq(i).text('0'+(i+1))
}
},
indexpage: function () {
},
aboutpage: function(){
},
searchpage: function(){
},
searchcenpage: function(){
var caseli = $('.csli')
// caselih = caseli.height()
// caselilen = caseli.length
// caselist.css('position','relative')
// caseli.css({
// 'position':'absolute',
// 'width':'100%'
// })
// caselist.height(caselih*caselilen)
// for (let k= 0; k< caselilen; k++) {
// caseli.eq(k).css('top',caselih*k+'px')
// }
var searchform=document.forms['searchform']
if (searchform != undefined) {
var searchname=searchform.elements['searchname'];
var casetitle = caseli.find('h1')
var casenumber = caseli.find('h2')
var caseadd = caseli.find('h3')
searchname.oninput=function(){
for (let i = 0; i < caseli.length; i++) {
var word1 = casetitle.eq(i).text()
var word2 = casenumber.eq(i).text()
var word3 = caseadd.eq(i).text()
var nowyes = word1.search(searchname.value)!= -1||word3.search(searchname.value)!= -1||word2.search(searchname.value)!= -1
console.log()
if (nowyes) {
caseli.eq(i).css('display','block')
casetitle.eq(i).html(word1.replace(searchname.value,''+searchname.value+''))
casenumber.eq(i).html(word2.replace(searchname.value,''+searchname.value+''))
caseadd.eq(i).html(word3.replace(searchname.value,''+searchname.value+''))
} else {
caseli.eq(i).css('display','none')
}
}
}
}
var csliimg = $('.csli').find('img')
for (let i = 0; i < csliimg.length; i++) {
var _thissrc = csliimg.eq(i).attr('src')
if (_thissrc == '/static/images/nopic.png') {
csliimg.eq(i).attr('src','/template/default/static/img/defaltimg.jpg')
}
}
},
lastallpage: function () {
}
}
// 当前网站全局js的function