Init Repo

This commit is contained in:
root
2019-09-06 23:53:10 +08:00
commit f0ef89dfbb
7905 changed files with 914138 additions and 0 deletions

586
static/app2/js/shoppingcart.js Executable file
View File

@ -0,0 +1,586 @@
var num = 1;
var isOver = 1;
$('.mui-action-back').show();
function getMsg(pageNum, pagesizeNum) {
var data_msg = {
page: pageNum ? pageNum : 1,
pagesize: pagesizeNum ? pagesizeNum : 10
}
if (isOver == 0) {
return;
} else {
isOver = 0;
}
mui.ajax(qlgUrl('app/Articles/headLine'), {
// mui.ajax(kxUrl('app/Articles/headLine'), {
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) {
$('.recommend_con').html(
'<p style="float: left;width: 100%;text-align: center;padding-bottom: 9px; margin-top:10px">没有更多内容</p>');
} else if (pageNum > 1) {
$('.recommend_con').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 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" style="display:none"><span>可用木吉抵扣20%货款</span></div></div><img style="display:none;" class="icon_icon" src="../img/icon_sscl.png" alt="" /></div>';
});
if (pageNum == 1) {
$('.recommend_con').html(html);
} else if (pageNum > 1) {
$('.recommend_con').append(html);
}
$('.recommend_title').css('display', 'block');
$('.rcb_title span').each(function() {
if ($(this).attr('data-goodsId') == 1) {
$(this).css('display', 'none');
}
})
$('.rcb_img').height($('.rcb_img').width());
isOver = 1;
} else {
mui.alert(data.msg)
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
}
mui.plusReady(function() {
// var scroll = mui('.mui-scroll-wrapper').scroll({
// deceleration: 0.002 //flick 减速系数系数越大滚动速度越慢滚动距离越小默认值0.0006
// });
window.addEventListener('refresh', function(e) {
location.reload();
})
getMsg(num, 10);
function getCost() {
var cost = 0;
$('.check2').each(function() {
if ($(this).children().hasClass('check_1')) {
cost += ((+$(this).siblings('.b_con_r1').children('.bz').children('.cost').children('o').html()) * (+$(this).siblings(
'.b_con_r1').children('.bz').children('.num').children('o').html()))
}
})
$('.js_r span j').html('¥' + cost.toFixed(2));
}
function isChecks() {
$('.check1').each(function() {
var isChecks = 1;
$(this).parent().siblings().children().find('.checks').each(function() {
if ($(this).hasClass('check_0')) {
isChecks = 0;
}
})
if (isChecks == 0) {
$(this).children().removeClass('check_1').addClass('check_0');
} else {
$(this).children().removeClass('check_0').addClass('check_1');
}
})
}
mui.ajax(qlgUrl('app/carts/index'), {
// mui.ajax(hyhUrl('app/carts/index'), {
data: {},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) { //服务器返回响应,根据响应结果,分析是否登录成功;
var data = toJson(data, 1);
if (data.status == 1) {
data = data.data;
var html = '';
$('header').html('购物车(' + data.all_carts_num + ')');
var allids = [];
$.each(data.carts, function() {
var ids = [];
$.each(this.list, function() {
ids.push(this.cartId);
allids.push(this.cartId);
});
var idsStr = ids.join(',');
html += '<div class="block"><div class="b_title clearfix"><div class="check1" data-idsStr="' + idsStr +
'"><div class="checks check_0"></div></div><img src="../img/icon_shop.png" /><div class="b_link"><a href="#" data-shopId="' +
this.shopId + '">' + this.shopName +
'</a></div><img style="display:none;" src="../img/icon_right.png" /><div class="btn_bj">编辑</div></div><div class="bcon">';
$.each(this.list, function() {
html += '<div class="b_con shadown_wai clearfix"><div class="check2" data-cartId="' + this.cartId +
'" data-cartNum="' + this.cartNum + '" data-isCheck="' + this.isCheck +
'"><div class="checks check_0"></div></div><img class="s_img" src="' + hyhImgUrl(this.goodsImg) +
'" /><div class="b_con_r1" data-goodsId="' + this.goodsId + '" style="display: block;"><p class="p1">' +
this.goodsName + '</p><p class="p2">';
$.each(this.specNames, function() {
html += this.catName + ':' + this.itemName + ';';
});
var price;
if (this.specPrice != null) {
price = this.specPrice;
} else {
price = this.shopPrice;
}
html += '</p><div class="bz clearfix"><span class="cost">¥<o>' + price +
'</o>&nbsp;&nbsp;</span><del stye="display:none;" class="oldcost">¥' + this.marketPrice +
'</del><span class="num">×<o>' + this.cartNum +
'</o></span></div></div><div class="b_con_r2 clearfix" style="display: none;"><div class="b_con_r2_l"><div class="changenum clearfix" data-cartId="' +
this.cartId + '"><img class="jian" src="../img/jian.png" /><input type="number" name="" id="" value="' +
this.cartNum +
'" /><img class="jia" src="../img/jia.png" /></div></div><div class="b_con_r2_r"><div class="b_con_r2_del" data-cartId="' +
this.cartId + '">删除</div></div></div></div>';
});
html += '</div></div>';
});
var allIdsStr = allids.join(',');
$('.con_').html(html)
$('.check').attr('data-allIdsStr', allIdsStr);
$('.checks').each(function() {
if ($(this).parent().attr('data-isCheck') == '1') {
$(this).removeClass('check_0').addClass('check_1');
}
})
getCost();
isChecks();
} else {
mui.alert(data.msg)
}
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
$('.con_').on('tap', '.b_link', function() {
var shopId = $(this).children('a').attr('data-shopId');
var url = 'storeout.html';
if (shopId == 1) {
// url='self_shop.html'
}
mui.openWindow({
url: url,
id: url + 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', '.b_con_r1', function() {
var data_id = $(this).attr('data-goodsId');
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
})
$('.check').on('tap', function() {
var isCheck;
var ids = $(this).attr('data-allIdsStr');
if ($('.check').children('.checks').hasClass('check_0')) {
$('.check').children('.checks').removeClass('check_0').addClass('check_1');
$('.check1').children('.checks').removeClass('check_0').addClass('check_1');
$('.check2').children('.checks').removeClass('check_0').addClass('check_1');
isCheck = 1;
} else {
$('.check').children('.checks').removeClass('check_1').addClass('check_0');
$('.check1').children('.checks').removeClass('check_1').addClass('check_0');
$('.check2').children('.checks').removeClass('check_1').addClass('check_0');
isCheck = 0;
}
getCost();
isChecks();
mui.ajax(qlgUrl('app/carts/batchChangeCartGoods'), {
data: {
ids: ids,
isCheck: isCheck
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) { //服务器返回响应,根据响应结果,分析是否;登录成功;
var data = toJson(data);
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
});
$('.con_').on('tap', '.check1', function(e) {
e.stopPropagation();
var that = $(this);
var isCheck;
var ids = $(this).attr('data-idsStr');
$('.check').children('.checks').removeClass('check_1').addClass('check_0');
if (that.children('.checks').hasClass('check_0')) {
isCheck = 1;
that.children('.checks').removeClass('check_0').addClass('check_1');
that.parent().siblings().children().find('.check2').children('.checks').removeClass('check_0').addClass(
'check_1');
} else {
isCheck = 0;
that.children('.checks').removeClass('check_1').addClass('check_0');
that.parent().siblings().children().find('.check2').children('.checks').removeClass('check_1').addClass(
'check_0');
}
getCost();
isChecks();
that.attr('disabled', 'disabled');
mui.ajax(qlgUrl('app/carts/batchChangeCartGoods'), {
data: {
ids: ids,
isCheck: isCheck
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) { //服务器返回响应,根据响应结果,分析是否;登录成功;
var data = toJson(data);
that.removeAttr('disabled');
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
});
$('.con_').on('tap', '.check2', function(e) {
////console.log()
e.stopPropagation();
var isCheck;
var cartId = $(this).attr('data-cartId');
var that = $(this);
var buyNum = $(this).attr('data-cartNum');
$('.check').children('.checks').removeClass('check_1').addClass('check_0');
if ($(this).children().hasClass('check_0')) {
$(this).parent().parent().siblings().children('.check1').children('.checks').removeClass('check_1').addClass(
'check_0');
$(this).children('.checks').removeClass('check_0').addClass('check_1');
isCheck = 1;
} else {
$(this).children('.checks').removeClass('check_1').addClass('check_0');
isCheck = 0;
}
getCost();
isChecks()
$(this).attr('disabled', 'disabled');
mui.ajax(qlgUrl('app/carts/changeCartGoods'), {
data: {
id: cartId,
isCheck: isCheck,
buyNum: buyNum
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) { //服务器返回响应,根据响应结果,分析是否;登录成功;
var data = toJson(data, 1);
that.removeAttr('disabled');
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
});
$('.con_').on('tap', '.btn_bj', function(e) {
e.stopPropagation()
if ($(this).html() == '编辑') {
$(this).html('完成');
$(this).parent().siblings().children().find('.b_con_r1').css('display', 'none');
$(this).parent().siblings().children().find('.b_con_r2').css('display', 'block');
} else {
$(this).html('编辑');
$(this).parent().siblings().children().find('.b_con_r2').css('display', 'none');
$(this).parent().siblings().children().find('.b_con_r1').css('display', 'block');
var inputArr = $(this).parent().siblings().find('input')
$(this).parent().siblings().find('.num').each(function(num) {
$(this).html('×<o>' + inputArr.eq(num).val() + '</o>');
})
}
// //console.log($(this).parent().siblings().find('.commodity_num'))
// //console.log($(this).parent().siblings().find('input'));
if ($(this).html() == '完成') {
return;
}
getCost()
})
$('.con_').on('tap', '.jia', function() {
// //console.log($(this).siblings('input').val())
var that = $(this);
var cartId = $(this).parent().attr('data-cartId')
var num = +$(this).siblings('input').val() + 1;
if (num <= 0) {
mui.alert('购买数最小为1');
return;
}
$('.jia').attr('disabled', 'disabled');
$('.jian').attr('disabled', 'disabled');
$('input').attr('disabled', 'disabled');
mui.ajax(hyhUrl('app/carts/changeCartGoods'), {
data: {
id: cartId,
buyNum: num
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) { //服务器返回响应,根据响应结果,分析是否;登录成功;
var data = toJson(data, 1);
that.siblings('input').val(num);
$('.jia').removeAttr('disabled');
$('.jian').removeAttr('disabled');
$('input').removeAttr('disabled');
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
})
$('.con_').on('tap', '.jian', function() {
var that = $(this);
var cartId = $(this).parent().attr('data-cartId')
var num = +$(this).siblings('input').val() - 1;
if (num <= 0) {
mui.alert('购买数最小为1');
return;
}
$('.jia').attr('disabled', 'disabled');
$('.jian').attr('disabled', 'disabled');
$('input').attr('disabled', 'disabled');
mui.ajax(qlgUrl('app/carts/changeCartGoods'), {
data: {
id: cartId,
buyNum: num
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) { //服务器返回响应,根据响应结果,分析是否;登录成功;
var data = toJson(data, 1);
that.siblings('input').val(num);
$('.jia').removeAttr('disabled');
$('.jian').removeAttr('disabled');
$('input').removeAttr('disabled');
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
})
$('.con_').on('blur', 'input', function() {
var that = $(this);
var cartId = $(this).parent().attr('data-cartId')
var num = +$(this).val();
if (num <= 0) {
mui.alert('购买数最小为1');
return;
}
$('.jia').attr('disabled', 'disabled');
$('.jian').attr('disabled', 'disabled');
$('input').attr('disabled', 'disabled');
mui.ajax(qlgUrl('app/carts/changeCartGoods'), {
data: {
id: cartId,
buyNum: num
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) { //服务器返回响应,根据响应结果,分析是否;登录成功;
var data = toJson(data, 1);
that.siblings('input').val(num);
$('.jia').removeAttr('disabled');
$('.jian').removeAttr('disabled');
$('input').removeAttr('disabled');
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
})
$('.con_').on('tap', '.b_con_r2_del', function() {
var cartId = $(this).attr('data-cartId');
if (confirm('确定删除?')) {
mui.ajax(hyhUrl('app/carts/delCart'), {
data: {
id: cartId
},
dataType: 'json', //服务器返回json格式数据
type: 'post', //HTTP请求类型
timeout: 10000, //超时时间设置为10秒
success: function(data) { //服务器返回响应,根据响应结果,分析是否;登录成功;
var data = toJson(data, 1);
location.reload();
},
error: function(xhr, type, errorThrown) { //异常处理;
// mui.alert(type);
}
});
}
})
// $('.changeclass').on('tap', '.selectclass', function() {
// $('.mui-backdrop').show();
// })
//选择类型
// $('.cclass1').on('tap', '.block', function() {
// $(this).addClass('on').siblings().removeClass('on');
// $(this).parent().attr('data-class', $(this).html());
// })
// $('.closecclass').on('tap', function() {
// $('.mui-backdrop').css('display', 'none');
// })
// $('.ensure').on('tap', function() {
// $('.mui-backdrop').css('display', 'none');
// })
mui('.js').on('tap', '.btn_tj', function() {
var check_length = $('.check_1').length;
if (check_length == 0) {
mui.alert('请选择商品结算!');
return;
}
mui.openWindow({
url: 'confirmOrder.html',
id: 'confirmOrder.html',
styles: {
top: '0px', //新页面顶部位置
bottom: '0px', //新页面底部位置
width: '100%', //新页面宽度默认为100%
height: '100%' //新页面高度默认为100%
},
extras: {
// data_id: data_id
type: 0
// ..... //自定义扩展参数,可以用来处理页面间传值
},
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, //等待框背景区域高度,默认根据内容自动计算合适高度
// ......
}
}
})
setTimeout(function() {
JZL.closeWindow(plus.webview.currentWebview().id);
}, 1000)
})
document.querySelector('.mui-scroll-wrapper').addEventListener('scroll', function(e) {
if (scroll.y == scroll.maxScrollY) {
if (isOver == 1) {
num++;
getMsg(num, 10);
}
}
})
})