qlg.tsgz.moe/static/app2/js/activity4.js
2019-09-06 23:53:10 +08:00

199 lines
6.6 KiB
JavaScript
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//添加返回顶部按钮
document.write('<script type="text/javascript" src="' + localStorage.getItem("jsUrl") + 'scrollToTop.js?ver=' + localStorage.getItem('version') + '"></scr' + 'ipt>');
var num = 1;
var isOver = 1;
var catId = '';
function getMsg(catIdNum, pageNum, pagesizeNum) {
var data_msg = {
catId: catIdNum ? catIdNum : '',
page: pageNum ? pageNum : 1,
pagesize: pagesizeNum ? pagesizeNum : 10
}
if(isOver == 0) {
return;
} else {
isOver = 0;
}
mui.ajax(llUrl('addon/hyhbrandsrec-hyhBrandsrec-getBrandCatList'), { 
data: data_msg,
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;
var data = toJson(data, 1);
if(data.status == 1) {
var htmlcon = '';
data = data.data;
if(data.Rows == '') {
if(pageNum == 1) {
$('.scroll_con').html('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px; margin-top:10px">没有更多内容</p>');
} else if(pageNum > 1) {
$('.scroll_con').append('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px; margin-top:10px">没有更多内容</p>');
}
isOver = 0;
return;
}
$.each(data.Rows, function() {
htmlcon += '<div class="scroll_con_block shadown_wai"><div class="scb_title" data-shopId="'+ this.shopId +'"><img src="'+ ectImgUrl(this.shopImg) +'" /><p>'+ this.shopName +'</p><span class="s1">官方旗舰店</span><span class="s2">进店看看</span></div>';
if(this.list != '') {
htmlcon += '<div class="scroll_con_con clearfix">';
$.each(this.list, function() {
htmlcon += '<div class = "scc_block" data-goodsId="' + this.goodsId + '"><img src = "'+ ectImgUrl(this.goodsImg) +'" /><p>'+ this.goodsName +'</p><span>¥'+ this.shopPrice +'</span></div>';
});
htmlcon += '</div>';
}
htmlcon += '</div>';
});
if(pageNum == 1) {
$('.scroll_con').html(htmlcon);
} else if(pageNum > 1) {
$('.scroll_con').append(htmlcon);
}
isOver = 1;
} else {
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
// alert(type);      
}  
}); 
}
mui.plusReady(function() {
mui.ajax(llUrl('addon/hyhbrandsrec-hyhBrandsrec-getBrandList'), { 
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
// var data = toJson(data,1);
if(data.status == 1) {
var html = '';
var html_ = '';
var data = data.data;
$.each(data.brandlist_rec, function(num) {
if(num % 2 == 0) {
html += '<div class="swiper-slide"><div class="ss_top ss_ shadown_wai"data-shopId="' + this.shopId + '"><img src="' + ectImgUrl(this.brandImg) + '" /><p>' + this.brandName + '</p></div>';
} else {
html += '<div class="ss_bottom ss_ shadown_wai"data-shopId="' + this.shopId + '"><img src="' + ectImgUrl(this.brandImg) + '" /><p>' + this.brandName + '</p></div></div>';
}
})
$.each(data.brand_list, function() {
html_ += '<div class="nav_block" data-catId="' + this.catId + '">' + this.typeName + '</div>';
});
$('.swiper-wrapper').html(html);
$('.nav').html(html_);
$('.nav_block').eq(0).addClass('on');
$('.t_con').height($('.t_con').width() * 470 / 718);
$('#topbanner').height($('#topbanner').width() * 470 / 718);
$('#topbanner .swiper-slide').height($('#topbanner .swiper-slide').width() * 2.1);
var swiper = new Swiper('#topbanner', {
slidesPerView: 3.1,
paginationClickable: true,
spaceBetween: 5,
freeMode: true
});
$('.ss_top').height($('.ss_top').width());
$('.ss_bottom').height($('.ss_bottom').width());
getMsg($('.nav_block').eq(0).attr('data-catId'), 1, 10);
} else {
console.log(data.status);
}
},
error: function(xhr, type, errorThrown) {           //异常处理;  
console.log(errorThrown);      
}  
}); 
document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
if(scroll.y == scroll.maxScrollY) {
if(isOver == 1) {
num++;
getMsg(catId, num, 10);
}
}
})
$('.con').on('tap', '.scc_block', function() {
var id = $(this).attr('data-goodsId');
mui.openWindow({
url: 'details.html',
id: 'details.html' + id,
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度默认为100%
height: '100%' //新页面高度默认为100%
},
extras: {
data_id: id
},
createNew: false, //是否重复创建同样id的webview默认为false:不重复创建,直接显示
show: {},
waiting: {
autoShow: false, //自动显示等待框默认为true
}
})
})
$('.con').on('tap', '.scb_title', function() {
var shopId = $(this).attr('data-shopId');
mui.openWindow({
url: 'storeout.html',
id: 'storeout.html' + shopId,
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度默认为100%
height: '100%' //新页面高度默认为100%
},
extras: {
shopId: shopId
},
createNew: false, //是否重复创建同样id的webview默认为false:不重复创建,直接显示
show: {},
waiting: {
autoShow: false, //自动显示等待框默认为true
}
})
})
$('.con').on('tap', '.ss_', function() {
var shopId = $(this).attr('data-shopId');
mui.openWindow({
url: 'storeout.html',
id: 'storeout.html' + shopId,
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度默认为100%
height: '100%' //新页面高度默认为100%
},
extras: {
shopId: shopId
},
createNew: false, //是否重复创建同样id的webview默认为false:不重复创建,直接显示
show: {},
waiting: {
autoShow: false, //自动显示等待框默认为true
}
})
})
$('.nav').on('tap', '.nav_block', function() {
catId = $(this).attr('data-catId');
isOver = 1;
num = 1;
getMsg(catId, 1, 10);
$(this).addClass('on').siblings().removeClass('on')
})
})