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

128 lines
3.6 KiB
JavaScript
Executable File
Raw 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.

var msort = 1;
var page = 1;
var condition = 1;
var desc = 0;
var keyword;
var isjiazai = 1;
var count = 1;
var pagesize = 10;
var ct1;
var ct2;
var goodsName = '';
function pullupRefresh(shopId, msort, desc, pagesize, page, goodsName, ct1, ct2) {
// setTimeout(function() {
// mui('#pullrefresh').pullRefresh().endPullupToRefresh();
var data_set = {
page: page,
pagesize: pagesize,
shopId: shopId,
mdesc: desc,
msort: msort,
goodsName: goodsName
}
// console.log(order_class)
if(isjiazai == 0) {
return;
}else{
isjiazai = 0;
}
mui.ajax(hyhUrl('app/Shops/getShopGoods'), { 
data: data_set,
dataType: 'json', //服务器返回json格式数据  
type: 'post', //HTTP请求类型  
timeout: 10000, //超时时间设置为10秒  
success: function(data) {           //服务器返回响应,根据响应结果,分析是否登录成功;  
// console.log(data.data.goodsFavoritesNum)
// console.log(data.data.Rows)
var data = toJson(data);
data = data.data;
var html = '';
if(data.Rows == '') {
$('.mui-scroll').append('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;">没有更多商品</p>');
isjiazai = 0;
return;
}
$.each(data.Rows, function() {
html += '<div class="recommend_con_block shadown_wai" data-goodsId="' + this.goodsId + '"><img class="rcb_img" src="' + ectImgUrl(this.goodsImg) + '" alt="" /><div class="rcb_con"><div class="rcb_title"><span style="display:none;" data-shopId="' + this.shopId + '">自营</span>' + this.goodsName + '</div><div class="rcb_pay">¥' + this.shopPrice + ' <span style="display:none;">满减</span></div><div class="rcb_bottom"><span>可用木吉抵扣20%货款</span></div></div><img style="display:none;" class="icon_icon" src="../img/icon_sscl.png" alt="" /></div>';
});
if(page == "1") {
$('.recommend_con').html(html);
} else {
$('.recommend_con').append(html);
}
isjiazai = 1;
$('.rcb_img').height($('.rcb_img').width());
},
error: function(xhr, type, errorThrown) {           //异常处理;  
// alert(type);    
}  
}); 
// }, 500);
}
mui.plusReady(function() {
var shopId = localStorage.getItem('shopId')
var costnum = 0;
var self = plus.webview.currentWebview();
goodsName = self.data_keyword;
pullupRefresh(shopId, msort, desc, pagesize, page, goodsName, ct1, ct2)
$('.commoditylistnav').on('tap', '.nav_block', function() {
page = 1;
isjiazai = 1;
$(this).addClass('on').siblings().removeClass('on');
msort = $(this).attr('data-condition');
if($('#cost_btn').hasClass('on')) {
costnum += 1;
if(costnum % 2 == 1) {
$('#cost_btn').html('价格 <img src="../img/cost3.png"/>');
desc = 1;
} else if(costnum % 2 == 0) {
$('#cost_btn').html('价格 <img src="../img/cost2.png"/>');
desc = 0;
}
} else {
$('#cost_btn').html('价格 <img src="../img/cost1.png"/>')
costnum = 0;
desc = 0
}
pullupRefresh(shopId, msort, desc, pagesize, page, goodsName, ct1, ct2)
})
document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
if(scroll.y == scroll.maxScrollY) {
if(isjiazai == 1) {
page++;
pullupRefresh(shopId, msort, desc, pagesize, page, goodsName, ct1, ct2);
}
}
})
})
// setInterval(function() {
// $('.cnxh_block img').height($('.cnxh_block img').width());
// $('.cnxh_block').height($('.cnxh_block').width() * 266 / 198);
// }, 100)