290 lines
11 KiB
JavaScript
Executable File
290 lines
11 KiB
JavaScript
Executable File
|
||
|
||
$('.search').css('display', 'none');
|
||
|
||
var num = 1;
|
||
var isOver = 1;
|
||
var recomId = '';
|
||
|
||
function getMsg(recomId, pageNum, pagesizeNum, classifyId,recomGoodsUrl) {
|
||
|
||
var data_msg = {
|
||
classifyId: classifyId,
|
||
recomId: recomId ? recomId : '',
|
||
page: pageNum ? pageNum : 1,
|
||
pagesize: pagesizeNum ? pagesizeNum : 10
|
||
}
|
||
|
||
if(isOver == 0) {
|
||
return;
|
||
} else {
|
||
isOver = 0;
|
||
}
|
||
mui.ajax(llUrl(recomGoodsUrl), {
|
||
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 html = '';
|
||
data = data.data;
|
||
if(data.Rows == '') {
|
||
if(pageNum == 1) {
|
||
$('.food_class_list').html('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px; margin-top:10px">没有更多内容</p>');
|
||
} else if(pageNum > 1) {
|
||
$('.food_class_list').append('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px; margin-top:10px">没有更多内容</p>');
|
||
}
|
||
|
||
isOver = 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>精选</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></div>'
|
||
});
|
||
|
||
if(pageNum == 1) {
|
||
$('.food_class_list').html(html);
|
||
} else if(pageNum > 1) {
|
||
$('.food_class_list').append(html);
|
||
}
|
||
$('.rcb_img').height($('.rcb_img').width());
|
||
|
||
isOver = 1;
|
||
} else {
|
||
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
|
||
}
|
||
mui.plusReady(function() {
|
||
var self = plus.webview.currentWebview();
|
||
var classifyId = self.classifyId;
|
||
|
||
if(classifyId == 2 ) {
|
||
$('.title').html('服饰');
|
||
}else if(classifyId == 4){
|
||
$('.title').html('家电');
|
||
}else if(classifyId == 3){
|
||
$('.title').html('家居');
|
||
}else if(classifyId == 9){
|
||
$('.title').html('生鲜');
|
||
}else if(classifyId == 1){
|
||
$('.title').html('桔子超市');
|
||
}else if(classifyId == 10){
|
||
$('.title').html('美妆');
|
||
}else if(classifyId == 11){
|
||
$('.title').html('数码');
|
||
}else if(classifyId == 12){
|
||
$('.title').html('箱包');
|
||
}else if(classifyId == 5){
|
||
$('.title').html('家电');
|
||
}else if(classifyId == 6){
|
||
$('.title').html('家纺');
|
||
}else if(classifyId == 7){
|
||
$('.title').html('配饰');
|
||
}else if(classifyId == 8){
|
||
$('.title').html('洗护');
|
||
}
|
||
// $('.oc_logo').attr('src', '../img/oc_logo' + classifyId + '.png');
|
||
var bannerUrl = '';
|
||
var recomactiveUrl = '';
|
||
var recomlistUrl = '';
|
||
if(classifyId == 2||classifyId == 4||classifyId == 3||classifyId == 9||classifyId == 1||classifyId == 10||classifyId == 11||classifyId == 12){
|
||
bannerUrl='addon/shuff-Shuff-topshow';
|
||
recomactiveUrl='addon/shuff-Shuff-recomactive';
|
||
recomlistUrl='addon/shuff-Shuff-recomlist';
|
||
recomGoodsUrl='addon/shuff-Shuff-recomgoods';
|
||
}else if(classifyId == 5||classifyId == 6||classifyId == 7||classifyId == 8){
|
||
bannerUrl='addon/selfmarket-selfmarket-selfSecBanner';
|
||
recomactiveUrl='addon/selfmarket-selfmarket-recomActive'
|
||
recomlistUrl='addon/selfmarket-selfmarket-recomList'
|
||
recomGoodsUrl='addon/selfmarket-selfmarket-recomGoods'
|
||
}
|
||
|
||
mui.ajax(llUrl(bannerUrl), {
|
||
data: {
|
||
classifyId: classifyId
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
// var data = toJson(data,1);
|
||
if(data.status == 1) {
|
||
var html = '';
|
||
var data = data.data;
|
||
$.each(data.banner, function() {
|
||
html += '<div class="swiper-slide" data-adURL="' + this.adURL + '" data-targetType="' + this.targetType + '"><img src="' + ectImgUrl(this.adFile) + '" /></div>'
|
||
})
|
||
$('#top_banner .swiper-wrapper').html(html);
|
||
$('#top_banner').height($('#top_banner').width() * 460 / 750);
|
||
var swiper = new Swiper('#top_banner', {
|
||
pagination: '#top_banner_pagination',
|
||
spaceBetween: 0,
|
||
loop: true,
|
||
autoplay: 3500,
|
||
autoplayDisableOnInteraction: false
|
||
});
|
||
|
||
if(data.left[0]) {
|
||
$('.add_top_left .food_p1').html(data.left[0].adName.split('|')[0]);
|
||
$('.add_top_left .food_p2').html(data.left[0].adName.split('|')[1]);
|
||
$('.add_top_left img').attr('src', ectImgUrl(data.left[0].adFile));
|
||
$('.add_top_left img').attr('data-adURL', data.left[0].adURL);
|
||
$('.add_top_left img').attr('data-targetType', data.left[0].targetType);
|
||
}
|
||
if(data.right_top[0]) {
|
||
$('.add_top_right_con .food_p1').html(data.right_top[0].adName.split('|')[0]);
|
||
$('.add_top_right .top .food_right_img1').attr('src', ectImgUrl(data.right_top[0].adFile));
|
||
$('.add_top_right .top .food_right_img1').attr('data-adURL', data.right_top[0].adURL);
|
||
$('.add_top_right .top .food_right_img1').attr('data-targetType', data.right_top[0].targetType);
|
||
$('.add_top_right .top .food_right_img2').attr('src', ectImgUrl(data.right_top[1].adFile));
|
||
$('.add_top_right .top .food_right_img2').attr('data-adURL', data.right_top[1].adURL);
|
||
$('.add_top_right .top .food_right_img2').attr('data-targetType', data.right_top[1].targetType);
|
||
}
|
||
if(data.right_bottom[0]) {
|
||
$('.add_top_right_con .food_p2').html(data.right_bottom[0].adName.split('|')[0]);
|
||
$('.add_top_right .bottom .food_right_img1').attr('src', ectImgUrl(data.right_bottom[0].adFile));
|
||
$('.add_top_right .bottom .food_right_img1').attr('data-adURL', data.right_bottom[0].adURL);
|
||
$('.add_top_right .bottom .food_right_img1').attr('data-targetType', data.right_bottom[0].targetType);
|
||
$('.add_top_right .bottom .food_right_img2').attr('src', ectImgUrl(data.right_bottom[1].adFile));
|
||
$('.add_top_right .bottom .food_right_img2').attr('data-adURL', data.right_bottom[1].adURL);
|
||
$('.add_top_right .bottom .food_right_img2').attr('data-targetType', data.right_bottom[1].targetType);
|
||
}
|
||
|
||
$('.add_top_left img').height($('.add_top_left img').width());
|
||
$('.add_top_right img').height($('.add_top_right img').width());
|
||
} else {
|
||
console.log(data.status);
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
console.log(errorThrown);
|
||
}
|
||
});
|
||
|
||
mui.ajax(llUrl(recomactiveUrl), {
|
||
data: {
|
||
type: 3,
|
||
classifyId: classifyId
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
var data = toJson(data, 1);
|
||
if(data.status == 1) {
|
||
var html = '';
|
||
data = data.data;
|
||
$.each(data, function() {
|
||
html += '<div class="reco_res" data-goodsId="' + this.goodsId + '"><img src="' + ectImgUrl(this.goodsImg) + '" class="reco_img" /><p class="p1">' + this.goodsName + '</p><p class="p2">¥ ' + this.shopPrice + '</p></div>'
|
||
});
|
||
$('.mujireco').html(html);
|
||
$('.mujireco').eq(0).attr('id', 'reco_1');
|
||
$('.reco_img').height($('.reco_img').width());
|
||
} else {
|
||
|
||
}
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
|
||
mui.ajax(llUrl(recomlistUrl), {
|
||
data: {
|
||
classifyId: classifyId
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
// var data = toJson(data,1);
|
||
if(data.status == 1) {
|
||
var html = '';
|
||
var data = data.data;
|
||
$.each(data, function() {
|
||
html += '<div class="nav_block" data-recomId="' + this.recomId + '">' + this.recomName + '</div>';
|
||
})
|
||
$('.nav').html(html);
|
||
|
||
$('.nav_block').eq(0).addClass('on');
|
||
recomId=$('.nav_block').eq(0).attr('data-recomId');
|
||
// console.log(recomId)
|
||
getMsg(recomId, 1, 10, classifyId,recomGoodsUrl);
|
||
} 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(recomId, num, 10, classifyId,recomGoodsUrl);
|
||
}
|
||
}
|
||
})
|
||
$('.nav').on('tap', '.nav_block', function() {
|
||
recomId = $(this).attr('data-recomId');
|
||
isOver = 1;
|
||
num = 1;
|
||
getMsg(recomId, num, 10, classifyId,recomGoodsUrl);
|
||
console.log(recomId)
|
||
})
|
||
//广告跳转
|
||
|
||
$('.rec_food').on('tap', 'img', function() {
|
||
openAds($(this));
|
||
});
|
||
//banner跳转
|
||
$('#top_banner').on('tap', '.swiper-slide', function() {
|
||
openAds($(this));
|
||
});
|
||
//展示跳转
|
||
$('.mujireco').on('tap', '.reco_res', function() {
|
||
var data_id = this.attributes["data-goodsId"].nodeValue;
|
||
// console.log(this.attributes["data-id"].nodeValue);
|
||
mui.openWindow({
|
||
url: 'details.html',
|
||
id: 'details.html' + data_id,
|
||
styles: {
|
||
top: '0px', //新页面顶部位置
|
||
bottom: '0px', //新页面底部位置
|
||
width: '100%', //新页面宽度,默认为100%
|
||
height: '100%' //新页面高度,默认为100%
|
||
},
|
||
extras: {
|
||
data_id: data_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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
})
|
||
}) |