219 lines
10 KiB
JavaScript
Executable File
219 lines
10 KiB
JavaScript
Executable File
$('.con').html('');
|
||
$('.con').css('padding','0');
|
||
var shopId = localStorage.getItem('shopId');
|
||
|
||
mui.init({
|
||
pullRefresh: {
|
||
container: '#pullrefresh',
|
||
down: {
|
||
style: 'circle', //必选,下拉刷新样式,目前支持原生5+ ‘circle’ 样式
|
||
color: '#2BD009', //可选,默认“#2BD009” 下拉刷新控件颜色
|
||
height: '50px', //可选,默认50px.下拉刷新控件的高度,
|
||
range: '100px', //可选 默认100px,控件可下拉拖拽的范围
|
||
offset: '0px', //可选 默认0px,下拉刷新控件的起始位置
|
||
// auto: true, //可选,默认false.首次加载自动上拉刷新一次
|
||
contentdown: "下拉可以刷新", //可选,在下拉可刷新状态时,下拉刷新控件上显示的标题内容
|
||
contentover: "释放立即刷新", //可选,在释放可刷新状态时,下拉刷新控件上显示的标题内容
|
||
contentrefresh: "正在刷新...", //可选,正在刷新状态时,下拉刷新控件上显示的标题内容
|
||
callback: pulldownRefresh //必选,刷新函数,根据具体业务来编写,比如通过ajax从服务器获取新数据;
|
||
},
|
||
up: {
|
||
contentrefresh: '正在加载...',
|
||
callback: pullupRefresh
|
||
}
|
||
}
|
||
});
|
||
var count = 1;
|
||
|
||
function pullupRefresh() {
|
||
setTimeout(function() {
|
||
mui('#pullrefresh').pullRefresh().endPullupToRefresh();
|
||
count += 1;
|
||
// console.log(order_class)
|
||
mui.ajax(hyhUrl('app/Shops/getShopGoods'), {
|
||
data: {
|
||
page: count,
|
||
shopId: shopId,
|
||
pageSize: 10,
|
||
msort: 6,
|
||
mdesc: 1
|
||
},
|
||
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 = '';
|
||
var obj = {};
|
||
$.each(data.Rows, function() {
|
||
if(!obj[this.saleTime]) {
|
||
obj[this.saleTime] = [this]
|
||
} else {
|
||
obj[this.saleTime].push(this)
|
||
}
|
||
|
||
});
|
||
for(var i in obj) {
|
||
|
||
if(obj[i].length == 1) {
|
||
html += '<div class="con_two con_goods" style="padding:0 2%;"><div class="co_title clearfix"><div class="hengxian"></div><p>本店' + obj[i][0].saleTime + '上新</p><div class="hengxian"></div></div><div class="ct_con shadown_wai" data-id="' + obj[i][0].goodsId + '"><img class="rcb_img" src="' + hyhImgUrl(obj[i][0].goodsImg) + '" alt="" /><div class="rcb_con"><div class="rcb_title"><span style="display: none;">自营</span>' + obj[i][0].goodsName + '</div><div class="rcb_pay">¥' + obj[i][0].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>'
|
||
} else {
|
||
html += '<div class="con_one"><div class="co_title clearfix"><div class="hengxian"></div><p>本店' + obj[i][0].saleTime + '上新</p><div class="hengxian"></div></div><div class="cnxh_con clearfix">'
|
||
$.each(obj[i], function() {
|
||
html += '<div class="recommend_con_block shadown_wai" data-id="' + this.goodsId + '"><img class="rcb_img" src="' + hyhImgUrl(this.goodsImg) + '" alt="" /><div class="rcb_con"><div class="rcb_title"><span style="display: none;">自营</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>'
|
||
});
|
||
html += '</div></div>'
|
||
|
||
}
|
||
|
||
}
|
||
|
||
$('.con').append(html);
|
||
// $('.cnxh_block img').height($('.cnxh_block img').width());
|
||
// $('.rcb_img').height($('.rcb_img').width());
|
||
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
}, 500);
|
||
}
|
||
|
||
/**
|
||
* 下拉刷新具体业务实现
|
||
*/
|
||
function pulldownRefresh() {
|
||
setTimeout(function() {
|
||
window.location.reload();
|
||
mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
|
||
}, 1500);
|
||
}
|
||
mui.plusReady(function() {
|
||
mui.ajax(hyhUrl('app/Shops/getShopGoods'), {
|
||
data: {
|
||
shopId: shopId,
|
||
pageSize: 10,
|
||
page: 1,
|
||
msort: 6,
|
||
mdesc: 1
|
||
},
|
||
dataType: 'json', //服务器返回json格式数据
|
||
type: 'post', //HTTP请求类型
|
||
timeout: 10000, //超时时间设置为10秒;
|
||
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
|
||
var data = toJson(data);
|
||
data = data.data;
|
||
|
||
var html = '';
|
||
var obj = {};
|
||
$.each(data.Rows, function() {
|
||
if(!obj[this.saleTime]) {
|
||
obj[this.saleTime] = [this]
|
||
} else {
|
||
obj[this.saleTime].push(this)
|
||
}
|
||
|
||
});
|
||
for(var i in obj) {
|
||
if(obj[i].length == 1) {
|
||
html += '<div class="con_two con_goods" style="padding:0 2%;"><div class="co_title clearfix"><div class="hengxian"></div><p>本店' + obj[i][0].saleTime + '上新</p><div class="hengxian"></div></div><div class="ct_con shadown_wai" data-id="' + obj[i][0].goodsId + '"><img class="rcb_img" src="' + hyhImgUrl(obj[i][0].goodsImg) + '" alt="" /><div class="rcb_con"><div class="rcb_title"><span style="display: none;">自营</span>' + obj[i][0].goodsName + '</div><div class="rcb_pay">¥' + obj[i][0].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>'
|
||
} else {
|
||
html += '<div class="con_one"><div class="co_title clearfix"><div class="hengxian"></div><p>本店' + obj[i][0].saleTime + '上新</p><div class="hengxian"></div></div><div class="cnxh_con clearfix">'
|
||
$.each(obj[i], function() {
|
||
html += '<div class="recommend_con_block shadown_wai" data-id="' + this.goodsId + '"><img class="rcb_img" src="' + hyhImgUrl(this.goodsImg) + '" alt="" /><div class="rcb_con"><div class="rcb_title"><span style="display: none;">自营</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>'
|
||
});
|
||
html += '</div></div>'
|
||
|
||
}
|
||
|
||
}
|
||
|
||
$('.con').html(html);
|
||
// $('.ct_con img').height($('.ct_con img').width());
|
||
// $('.rcb_img').height($('.rcb_img').width());
|
||
|
||
},
|
||
error: function(xhr, type, errorThrown) { //异常处理;
|
||
// alert(type);
|
||
}
|
||
});
|
||
|
||
setInterval(function() {
|
||
// $('.cnxh_block img').height($('.cnxh_block img').width());
|
||
// $('.cnxh_block').height($('.cnxh_block').width() * 266 / 198);
|
||
$('.recommend_con_block img').height($('.recommend_con_block img').width());
|
||
$('.ct_con img').height($('.ct_con img').width());
|
||
}, 200)
|
||
$('.con').on('tap', '.ct_con', function() {
|
||
var good_id = $(this).attr('data-id');
|
||
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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
})
|
||
$('.con').on('tap', '.recommend_con_block', function() {
|
||
var good_id = $(this).attr('data-id');
|
||
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, //等待框背景区域高度,默认根据内容自动计算合适高度
|
||
// ......
|
||
}
|
||
}
|
||
})
|
||
})
|
||
}) |