You've already forked qlg.tsgz.moe
186 lines
7.2 KiB
JavaScript
Executable File
186 lines
7.2 KiB
JavaScript
Executable File
var scroll = mui('.con').scroll();
|
|
mui.plusReady(function() {
|
|
var autoCatId;
|
|
var num = 1;
|
|
var isOver = 1;
|
|
mui.ajax(hyhUrl('addon/hyhbrandsrec-hyhBrandsrec-getBrandList'), {
|
|
data: {},
|
|
dataType: 'json', //服务器返回json格式数据
|
|
type: 'post', //HTTP请求类型
|
|
timeout: 10000, //超时时间设置为10秒;
|
|
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
|
data = toJson(data);
|
|
if(data.status == 1) {
|
|
data = data.data;
|
|
var html = '';
|
|
var html1 = '';
|
|
$.each(data.brandlist_rec, function() {
|
|
html += '<div class="scroll_top_block" data-brandId="' + this.brandId + '"><img src="' + chengUrl(this.brandImg) + '" /><p>' + this.brandName + '</p></div>';
|
|
});
|
|
autoCatId = data.brand_list[0].catId;
|
|
$.each(data.brand_list, function() {
|
|
html1 += '<a class="mui-control-item" data-catId="' + this.catId + '">' + this.catName + '</a>';
|
|
});
|
|
$('.scroll_top').html(html);
|
|
$('.nav').html(html1);
|
|
document.getElementsByClassName('mui-control-item')[0].classList.add('mui-active')
|
|
$('.scroll_top_block').height($('.scroll_top_block').width());
|
|
$('.scroll_top_block img').height($('.scroll_top_block img').width());
|
|
getData(autoCatId, 6, 1);
|
|
|
|
} else {
|
|
alert('发生错误请刷新后重试!');
|
|
// location.reload();
|
|
}
|
|
},
|
|
error: function(xhr, type, errorThrown) { //异常处理;
|
|
// alert(type);
|
|
}
|
|
});
|
|
function getData(catIdNum, pageSizeNum, pageNum) {
|
|
if(isOver == 1) {
|
|
isOver = 0;
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
var autoData = {
|
|
catId: catIdNum,
|
|
pageSize: pageSizeNum ? pageSizeNum : 6,
|
|
page: pageNum ? pageNum : 1
|
|
}
|
|
mui.ajax(chengUrl('addon/hyhbrandsrec-hyhBrandsrec-getBrandCatList'), {
|
|
data: autoData,
|
|
dataType: 'json', //服务器返回json格式数据
|
|
type: 'post', //HTTP请求类型
|
|
timeout: 10000, //超时时间设置为10秒;
|
|
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
|
var data = toJson(data);
|
|
if(data.status == 1) {
|
|
data = data.data;
|
|
var html = '';
|
|
if(data.Rows == '' && pageNum > 1) {
|
|
$('.scroll_con').append('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;">没有更多商品</p>');
|
|
|
|
return;
|
|
} else if(data.Rows == '') {
|
|
$('.scroll_con').html('<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px;margin-top:20px;">没有商品</p>');
|
|
return;
|
|
}
|
|
|
|
$.each(data.Rows, function() {
|
|
html += '<div class="scroll_con_block" id="' + num + '"><div class="scb_title" data-shopId="' + this.shopId + '"><img src="' + chengUrl(this.shopImg) + '" /><p>' + this.shopName + '</p><span class="s1">官方旗舰店</span><span class="s2">进店看看</span></div><div class="scroll_con_con clearfix">';
|
|
|
|
$.each(this.list, function() {
|
|
html += '<div class="scc_block" data-goodsId="' + this.goodsId + '"><img src="' + this.goodsImg + '" /><p>' + this.goodsName + '</p><span>¥' + this.shopPrice + '</span></div>'
|
|
});
|
|
|
|
html += '</div></div>'
|
|
|
|
});
|
|
if(pageNum == 1) {
|
|
$('.scroll_con').html(html);
|
|
} else {
|
|
$('.scroll_con').append(html);
|
|
}
|
|
|
|
$('.scc_block img').height($('.scc_block img').width());
|
|
|
|
isOver = 1;
|
|
|
|
} else {
|
|
alert('发生错误请刷新后重试!');
|
|
// location.reload();
|
|
}
|
|
},
|
|
error: function(xhr, type, errorThrown) { //异常处理;
|
|
// alert(type);
|
|
}
|
|
});
|
|
}
|
|
document.querySelector('.con').addEventListener('scroll', function(e) {
|
|
if(scroll.y == scroll.maxScrollY) {
|
|
if(isOver == 1) {
|
|
num += 1;
|
|
getData(autoCatId, 6, num);
|
|
}
|
|
}
|
|
})
|
|
mui('.nav').on('tap', '.mui-control-item', function() {
|
|
autoCatId = $(this).attr('data-catId');
|
|
num = 1;
|
|
isOver = 1;
|
|
getData(autoCatId, 6, num);
|
|
})
|
|
//跳商店页面
|
|
$('.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: {
|
|
// 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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
|
// ......
|
|
}
|
|
}
|
|
})
|
|
})
|
|
//跳商品页面
|
|
$('.con').on('tap', '.scc_block', function() {
|
|
var goodsId = $(this).attr('data-goodsId');
|
|
mui.openWindow({
|
|
url: 'details.html',
|
|
id: 'details.html'+goodsId,
|
|
styles: {
|
|
top: '0px', //新页面顶部位置
|
|
bottom: '0px', //新页面底部位置
|
|
width: '100%', //新页面宽度,默认为100%
|
|
height: '100%' //新页面高度,默认为100%
|
|
},
|
|
extras: {
|
|
data_id: goodsId
|
|
// ..... //自定义扩展参数,可以用来处理页面间传值
|
|
},
|
|
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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
|
// ......
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
}) |