164 lines
5.4 KiB
JavaScript
Executable File
164 lines
5.4 KiB
JavaScript
Executable File
$('.mui-action-back').css('display', 'none');
|
||
$('.header_con img').attr('src', hyhImgUrl('static/app2/img/sale.png'));
|
||
var topTypeId = '40';
|
||
var secTypeId = '';
|
||
var pageSize = 10;
|
||
var page = 1;
|
||
var isjiazai = 1;
|
||
|
||
function lxy_dis(topTypeId, secTypeId, page, pageSize) {
|
||
|
||
var lxy_data_ = {
|
||
topTypeId: topTypeId ? topTypeId : '40',
|
||
secTypeId: secTypeId ? secTypeId : '',
|
||
page: page ? page : 1,
|
||
pageSize: pageSize ? pageSize : 10
|
||
}
|
||
if(isjiazai == 0) {
|
||
return;
|
||
} else {
|
||
isjiazai = 0;
|
||
}
|
||
mui.ajax(llUrl('addon/hyhlimitactive-Hyhlimitactive-actGoodsList'), {
|
||
data: lxy_data_,
|
||
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);
|
||
var data = data.data
|
||
var html = '';
|
||
|
||
if(data.Rows == '') {
|
||
|
||
if(page == 1) {
|
||
$('#recommend_con').html('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;">没有更多商品</p>');
|
||
} else {
|
||
$('#recommend_con').append('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;">没有更多商品</p>');
|
||
}
|
||
|
||
isjiazai = 0;
|
||
return;
|
||
}
|
||
|
||
$.each(data.Rows, function() {
|
||
html += '<div class="con_block shadown_wai" data-goodsId="' + this.goodsId + '"><img class="img" src="' + ectImgUrl(this.goodsImg) + '" /><p class="p1">' + this.goodsName + '</p><p class="p2">享' + parseInt(this.shopPrice * 10 / this.marketPrice) + '折优惠</p><p class="p3">¥<o>' + this.shopPrice + '</o></p><del><o>' + this.marketPrice + '</o></del><button>立即购买</button></div>'
|
||
});
|
||
|
||
if(page == 1) {
|
||
$('#recommend_con').html(html);
|
||
} else {
|
||
$('#recommend_con').append(html);
|
||
}
|
||
|
||
isjiazai = 1;
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
//alert(type);
|
||
}
|
||
});
|
||
}
|
||
|
||
mui.plusReady(function() {
|
||
|
||
mui.ajax(llUrl('addon/hyhlimitactive-Hyhlimitactive-actList'), {
|
||
data: {
|
||
topTypeId: topTypeId
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
//console.log(data.data.goodsFavoritesNum);
|
||
//console.log(data.data.Rows);
|
||
//console.log(data.status);
|
||
//var data = toJson(data);
|
||
if(data.status == 1) {
|
||
var data = data.data
|
||
var html = '';
|
||
var len = 0;
|
||
$.each(data.lists, function() {
|
||
html += '<div class="swiper-slide nav_block" data-secTypeId="' + this.secTypeId + '"><p class="p1">' + this.secTypeName + '</p></div>'
|
||
|
||
});
|
||
$('.nav').html(html);
|
||
|
||
if(data.lists.length > 5) {
|
||
len = 4.5
|
||
} else {
|
||
len = data.lists.length;
|
||
}
|
||
var swiper = new Swiper('#timer_swiper', {
|
||
slidesPerView: len,
|
||
paginationClickable: true,
|
||
spaceBetween: 0,
|
||
freeMode: true
|
||
});
|
||
|
||
$('.nav_block').eq(0).addClass('on');
|
||
secTypeId = $('.nav_block').eq(0).attr('data-secTypeId');
|
||
lxy_dis(topTypeId, secTypeId, 1, 10);
|
||
}
|
||
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
})
|
||
|
||
mui('.nav').on('tap', '.nav_block', function() {
|
||
secTypeId = $(this).attr('data-secTypeId');
|
||
page = 1;
|
||
isjiazai=1;
|
||
lxy_dis(topTypeId, secTypeId, page, 10);
|
||
|
||
})
|
||
|
||
document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
|
||
if(scroll.y == scroll.maxScrollY) {
|
||
if(isjiazai == 1) {
|
||
page++;
|
||
lxy_dis(topTypeId, secTypeId, page, pageSize);
|
||
}
|
||
|
||
}
|
||
})
|
||
|
||
$('#recommend_con').on('tap', '.con_block', function() {
|
||
var good_id = $(this).attr('data-goodsId');
|
||
mui.openWindow({
|
||
url: 'details.html',
|
||
id: 'details.html' + good_id,
|
||
styles: {
|
||
top: '0px', //新页面顶部位置
|
||
bottom: '0px', //新页面底部位置
|
||
width: '100%', //新页面宽度,默认为100%
|
||
height: '100%' //新页面高度,默认为100%
|
||
},
|
||
extras: {
|
||
data_id: good_id
|
||
// ..... //自定义扩展参数,可以用来处理页面间传值
|
||
},
|
||
createNew: false, //是否重复创建同样id的webview,默认为false:不重复创建,直接显示
|
||
show: {
|
||
// autoShow: true, //页面loaded事件发生后自动显示,默认为true
|
||
// aniShow: animationType, //页面显示动画,默认为”slide-in-right“;
|
||
// duration: animationTime, //页面动画持续时间,Android平台默认100毫秒,iOS平台默认200毫秒;
|
||
// event: 'titleUpdate', //页面显示时机,默认为titleUpdate事件时显示
|
||
// extras: {} //窗口动画是否使用图片加速
|
||
},
|
||
waiting: {
|
||
autoShow: true, //自动显示等待框,默认为true
|
||
title: '正在加载...', //等待对话框上显示的提示内容
|
||
options: {
|
||
// width: waiting - dialog - widht, //等待框背景区域宽度,默认根据内容自动计算合适宽度
|
||
// height: waiting - dialog - height, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
})
|
||
}) |