if(location.origin === undefined){
location.origin = location.protocol + '//' + location.hostname
}
var shuwon = {
percent: 0,
timers: "",
init: function (e) {
// // 输入框提示
// $("body").append('
');
// // 返回到顶部
// $("body").append('');
// // 加载动画
$("body").append('');
this.common()
},
/**
* 页面加载完毕
*/
loaded: function () {
$('#loading').addclass('active');
settimeout(function () {
shuwon.navigation()
}, 1000)
},
index: function () {
},
common: function () {
// $('.header').load('header.html')
// $('.footer').load('footer.html')
$('.backup').click(function () {
$('body,html').animate({
scrolltop: 0
}, 500)
})
$('.box.btn').click(function () {
$(this).toggleclass('active')
})
$('.box.seo .list .item').eq(0).addclass('active');
$('.box.seo .type .item').click(function(){
$(this).addclass('active').siblings().removeclass('active')
$('.box.seo .list .item').eq($(this).index()).addclass('active').siblings().removeclass('active')
})
$('.menu-btn').click(function(){
$('body').toggleclass('open')
})
$('.slider .qq').click(function(){
var this_qq = $(this).attr('data-qq');
location.href = "tencent://message/?uin="+ this_qq +"&menu=yes"
})
$('.slider .phone_').click(function(){
var n = $(this).attr('data-num');
location.href = 'tel:+86' + n;
})
},
getoffset: function () {
if ($(window).width() > 1200) {
return ($(window).width() - 1200) / 2
} else {
return 0;
}
},
/**
* 视频弹出层
*/
video: function () {
$(".video_list ul li").click(function () {
$(".lightbox").addclass("active");
$(".lightbox video").attr("src", $(this).attr("data-url"));
})
$(".close_video").click(function () {
$(".lightbox").removeclass("active");
$(".lightbox video").attr("src", "");
})
},
/**
* 加入我们弹出层
*/
join: function () {
$(".join_list ul li").click(function () {
$(".lightbox").addclass("active");
})
$(".jointipboxtitle .close").click(function () {
$(".lightbox").removeclass("active");
})
},
/*sj:function(){
$('input[name="phone"]').on('input',function(){
if($(this).val().length > 11){
$(this).val($(this).val().substr(0,11))
}else{
$(this).val($(this).val().replace(/[^0-9]/g,''))
}
})
$('.form.common .text .btn').click(function() {
var btn = $(this);
var form = $('.form.common .text .btn').eq(0).prev(),
name = form.find('input[name="name"]').val(),
phone = form.find('input[name="phone"]').val();
if(name == ''){
sw._toast('请填写姓名!','error');
return;
}
if(phone == ""){
sw._toast('请填写手机号码','error');
return;
}
if(!shuwon.regphone(phone)){
sw._toast('手机号码格式不正确!','error');
return;
}
$.ajax({
url:"/plus/diy.php",
data:{name:name,phone:phone,action:'post',diyid:'2',do:'2',dede_fields:'name,text;phone,text',dede_fieldshash:'fde07a4de034c5c0ad2f6ca6af5d7bca'},
datatype: 'json',
type:'post',
datatype: 'json',
async: false,
success:function(res) {
if(res.code == 1) {
sw._toast('提交成功','success')
btn.attr('disabled','')
} else {
sw._toast('提交失败','error')
}
}
})
})
},*/
/**
* 返回顶部
*/
backtop: function () {
var offset = 300,
offset_opacity = 1200,
scroll_top_duration = 500,
$back_to_top = $('.backtop');
$(window).scroll(function () {
($(this).scrolltop() > offset) ? $back_to_top.addclass('active'): $back_to_top.removeclass('active');
if ($(this).scrolltop() > offset_opacity) {
$back_to_top.addclass('active')
}
});
$back_to_top.on('click', function (event) {
event.preventdefault();
$('body,html').animate({
scrolltop: 0
}, scroll_top_duration)
})
},
/**
* 随机返回区间值
* min:最小值
* max:最大值
*/
rand: function (min, max) {
return math.random() * (max - min) + min;
},
/**
* 验证手机号码
* @param {obj} 传入的手机号码
* @return 正确返回true 错误返回false
*/
/*regphone: function (obj) {
reg = /^(13|15|17|18|14|19)[0-9]{9}$/;
return reg.test(obj);
},*/
/**
* 判断验证码是否符合要求
*/
regcode: function (obj) {
if (obj.length == 0 || obj.length != 6) {
return true;
}
return false;
},
/**
* 只能输入中英文和数字
*/
regname: function (obj) {
var reg = /^[\u4e00-\u9fa5]{2,20}$/;
return reg.test(obj);
},
/**
* 姓名 || 只能输入中英文
* @param {obj} 传入的字符
* @return 正确返回true 错误返回false
*/
regname: function (obj) {
reg = /^[\u4e00-\u9fa5a-za-z]+$/;;
return reg.test(obj);
},
/**
* 判断身份证号码是否符合要求
*/
regid: function (obj) {
reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|x|x)$)/;
return reg.test(obj);
},
/**
* 提示信息
* @msg 提示的信息
* @success true 成功 | false 失败
*/
toast: function (msg, sucess) {
$(".toast").addclass("active").find("span").html(msg);
if (!sucess) {
$(".toast").addclass("warn");
} else {
$(".toast").removeclass("warn");
}
settimeout(function () {
$(".toast").removeclass("active")
}, 1500)
},
/**
* 获取地址栏
* @name 获取传入的参数
*/
geturlparam: function (name) {
var reg = new regexp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
return r ? decodeuricomponent(r[2]) : null;
},
/**
* 倒计时
*/
countdowntime: function () {
isclick = false;
$('.yzmbtn').addclass("enable");
$('.yzmbtn').addclass("active").html('60秒后重新获取')
var waittime, currtime = 59;
var interval = setinterval(function () {
shuwon.timechange(currtime);
currtime--;
if (currtime < 0) {
clearinterval(interval);
currtime = waittime;
}
}, 1000);
},
/**
* 时间戳转时间
*
* @param {any} timer
*/
timer: function (timer) {
var timebpx = {
month: 0, //开始-月份
date: 0, //开始-号数
hours: 0, //开始-小时
minutes: 0, //开始-分钟
day: 0, //剩余-天数
hour: 0, //剩余-小时
minute: 0, //剩余-分钟
second: 0 //剩余-秒
}
var current = math.floor(new date().gettime() / 1000),
timed = 0,
time = new date(timer * 1000);
var dd_ = 0,
hh_ = 0,
mm_ = 0,
ss_ = 0;
timed = timer - current;
dd_ = math.floor(timed / (60 * 60 * 24)); //计算剩余的天数
hh_ = math.floor(timed / (60 * 60)) - (dd_ * 24) //计算剩余的小时数
mm_ = math.floor(timed / 60) - (dd_ * 24 * 60) - (hh_ * 60) //计算剩余的分钟数
ss_ = math.floor(timed) - (dd_ * 24 * 60 * 60) - (hh_ * 60 * 60) - (mm_ * 60) //计算剩余的秒数
if (hh_ <= 9) hh_ = '0' + hh_;
if (mm_ <= 9) mm_ = '0' + mm_;
if (ss_ <= 9) ss_ = '0' + ss_;
timebpx.day = dd_ //天
timebpx.hour = hh_ //时
timebpx.minute = mm_ //分
timebpx.second = ss_ //秒
timebpx.month = time.getmonth() + 1
timebpx.date = time.getdate()
timebpx.date = time.gethours()
timebpx.date = time.getminutes()
return timebpx
},
/**
* 获取数据
* @url 传入的数据接口
* @para 传入的参数
*/
getdataforapi: function (url, para, callback) {
$.ajax({
type: "post",
data: para,
url: location.origin + url,
datatype: 'json',
success: function (data) {
if (data.result) {
callback(data)
} else {
shuwon.toast(data.msg);
}
},
error: function (e) {
shuwon.toast("数据加载错误", false)
}
})
},
fixednav: function () {
document.addeventlistener('scroll', function () {
var scroll_top = $(window).scrolltop();
if (scroll_top > 150) {
$('.header').addclass('active')
} else {
$('.header').removeclass('active')
}
}, false)
},
about: function () {
$('.about-page .box3 .silck').slick({
infinite: true,
speed: 500,
arrows: true,
slidestoshow: 1,
slidestoscroll: 1,
centermode: true,
variablewidth: true,
draggable: false,
})
$('.about-page .box3 .silck').on('afterchange', function (e, slick) {
console.log(slick.$slides.eq(slick.currentslide).attr('data-text'))
slick.$slides.eq(slick.currentslide).addclass('active').siblings().removeclass('active')
// slick.refresh()
$('.p-title').text(slick.$slides.eq(slick.currentslide).attr('data-text'))
})
// $('.about-page .box3 .silck').on('init',function(e,slick){
// $('.p-title').text(slick.slides.eq(slick.currentslide).attr('data-text'))
// })
$('.about-page .box4 .silck').slick({
infinite: false,
speed: 500,
arrows: true,
slidestoshow: 4,
slidestoscroll: 1,
draggable: false,
responsive:[{
breakpoint:769,
settings:{
slidestoshow: 3,
}
},
{
breakpoint:414,
settings:{
slidestoshow: 2,
}
}]
})
$('.about-page .box4 .item').click(function () {
$('.about-page .box4 .large_ .img-box').get(0).style.backgroundimage = $(this).find('.img-box').get(0).style.backgroundimage
})
}
}
shuwon.init()
shuwon.fixednav()
function _page(opts){
function page(opts){
this.opts = opts || {};
this.active = parseint(sw.getsearch('page')) || 1;
this.pagesize = this.opts.pagesize || 6;
this.total = parseint(this.opts.total) || 0;
this.pages = math.ceil(this.total / this.pagesize);
this.virtual_page = this.active;
this.init()
}
page.prototype.init = function(){
this.render(this.count())
this.events()
}
page.prototype.count = function(active){
var pages = this.pages,p = [],active = active || this.active;
if(pages <= 5){
for(var i = 1;i <= pages;i++){
p.push({
text:i,
page:i,
isactive:this.active == i
})
}
}else{
if(active >= 3){
if(this.pages - active > 2){
p.push({
text:'...',
page:'prev',
isactive:false
})
for(var i = active - 2;i <= active + 2;i++){
p.push({
text:i,
page:i,
isactive:this.active == i
})
}
p.push({
text:'...',
page:'next',
isactive:false
})
}else{
p.push({
text:'...',
page:'prev',
isactive:false
})
for(var i = this.pages - 4;i <= this.pages;i++){
p.push({
text:i,
page:i,
isactive:this.active == i
})
}
}
}else{
for(var i = 1;i <= 5;i++){
p.push({
text:i,
page:i,
isactive:this.active == i
})
}
p.push({
text:'...',
page:'next',
isactive:false
})
}
}
return p;
}
page.prototype.render = function(arr){
var this_ = this
document.getelementsbyclassname('pages')[0].appendchild(this.creattag(1,'首页',false))
_.each(arr,function(v,i){
var tag = this_.creattag(v.page,v.text,v.isactive)
document.getelementsbyclassname('pages')[0].appendchild(tag)
})
document.getelementsbyclassname('pages')[0].appendchild(this.creattag(this.pages,'尾页',false))
document.getelementsbyclassname('pages')[0].appendchild(this.creattag('total','总'+this.total+'条',false))
}
page.prototype.events = function(){
var self = this
document.queryselector('.pages').addeventlistener('click',function(event){
// self.remove()
var evttarget = event.target || event.srcelement;
if(evttarget.tagname !== 'a'){
evttarget = evttarget.parentelement
}
if(/next/.test(evttarget.classname)){
if(self.virtual_page + 5 <= self.pages ){
self.virtual_page+=5
}else{
self.virtual_page = self.pages
}
self.remove()
self.render(self.count(self.virtual_page))
}
if(/prev/.test(evttarget.classname)){
if(self.virtual_page - 5 > 0 ){
self.virtual_page-=5
}else{
self.virtual_page = 1
}
self.remove()
self.render(self.count(self.virtual_page))
}
},false)
}
page.prototype.remove = function(){
var c = document.getelementsbyclassname('pages')[0],childs = c.childnodes;
for(var i = childs.length - 1; i >= 0; i--) {
c.removechild(childs[i]);
}
}
page.prototype.creattag = function(page,text,isactive){
var a = document.createelement('a'), p =document.createelement('p');
if(!isnan(parseint(page))){
a.classname = 'page_item';
a.href = location.origin + location.pathname + '?' + this.setseach(page);
}else{
a.href = "javascript:void(0);"
a.classname = page;
}
if(isactive){
$(a).addclass('active')
}
p.innertext = text;
a.appendchild(p);
return a;
}
page.prototype.setseach = function(page){
var search = location.search;
if(search != ''){
var arr = search.substr(1).split('&');
if(!/(^|&|\?)page=([^&]*)(&|$)/.test(search)){
arr.push('page=1');
}
_.each(arr,function(v,i){
if(/(^|&)page=([^&]*)(&|$)/.test(v)){
arr[i] = 'page=' + page
}
})
return arr.join('&')
}else{
return 'page='+ page
}
}
return new page(opts)
}