|
@@ -129,12 +129,19 @@ var yhq_id=''; mui.ready(function() {
|
|
var yhq_str = "";
|
|
var yhq_str = "";
|
|
if(dt.data.couponItems.length > 0) {
|
|
if(dt.data.couponItems.length > 0) {
|
|
$("#ul-youhuiquan").show();
|
|
$("#ul-youhuiquan").show();
|
|
- console.log("有优惠券" + dt.data.couponItems.length + "张")
|
|
|
|
|
|
+ //console.log("有优惠券" + dt.data.couponItems.length + "张")
|
|
var str='';
|
|
var str='';
|
|
- mui.each(dt.data.couponItems,function(){
|
|
|
|
- str+= '<li class="my-table-view-cell" style="opacity:.5"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">'+ this.couponName +':¥'+ ((this.couponReduce)/100).toFixed(2)+'<h6>有效期至:'+this.couponUseEndDate+'</h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="checkbox" val="'+(this.couponReduce/100).toFixed(2)+'" type="checkbox" class="mui-pull-left" id="'+this.couponItemId+'"/></div></div></li>';
|
|
|
|
|
|
+ mui.each(dt.data.couponItems,function(index){
|
|
|
|
+ var opacity=1,checked='checked';
|
|
|
|
+ if(index>0){
|
|
|
|
+ opacity=0.5;
|
|
|
|
+ checked='';
|
|
|
|
+ }
|
|
|
|
+ str+= '<li class="my-table-view-cell" style="opacity:'+opacity+'"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">优惠券:¥'+ ((this.couponReduce)/100).toFixed(2)+'<h6>有效期至:'+this.couponUseEndDate+'</h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="checkbox" val="'+(this.couponReduce/100).toFixed(2)+'" type="checkbox" '+checked+' class="mui-pull-left" id="'+this.couponItemId+'"/></div></div></li>';
|
|
});
|
|
});
|
|
- $("body").append('<div class="my-picker"><ul class="mui-table-view mui-table-view-striped mui-table-view-condensed my-grid-view-no" style="padding: 20px 0 30px 0;overflow: scroll;max-height: 400px;">' + str + '</ul><button class="mui-btn my-btn-block my-btn-buy-know" disabled="disabled">确认使用</button></div>');
|
|
|
|
|
|
+ $("body").append('<div class="my-picker"><ul class="mui-table-view mui-table-view-striped mui-table-view-condensed my-grid-view-no" style="padding: 20px 0 30px 0;overflow: scroll;max-height: 400px;">' + str + '</ul><button class="mui-btn my-btn-block my-btn-buy-know">确认使用</button></div>');
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
mui.each(dt.data.cartItems,function(index){
|
|
mui.each(dt.data.cartItems,function(index){
|
|
var num = this.cartNum;
|
|
var num = this.cartNum;
|
|
@@ -168,11 +175,24 @@ var yhq_id=''; mui.ready(function() {
|
|
wechatAddr.userTel = dt.data.addressInfo.salesAddressTel;
|
|
wechatAddr.userTel = dt.data.addressInfo.salesAddressTel;
|
|
wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum;
|
|
wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum;
|
|
}
|
|
}
|
|
- $(".count_price").text((dt.data.payTotal/100).toFixed(2));
|
|
|
|
|
|
+
|
|
$("#pro-count").text(dt.data.cartItems.length);
|
|
$("#pro-count").text(dt.data.cartItems.length);
|
|
|
|
+ if(dt.data.couponItems.length){
|
|
|
|
+ yhq_id=$("input[name=checkbox]:checked").attr('id');
|
|
|
|
+ $(".btn-youhuiquan>span").text("-¥"+$("input[name=checkbox]:checked").attr("val")).show();
|
|
|
|
+ var cout = $("input[name=checkbox]:checked").attr("val");
|
|
|
|
+ var count_price = payTotal - cout*100;
|
|
|
|
+ if(count_price <= 0) {
|
|
|
|
+ count_price = 0.0; //判断商品价格减去现金券价格若<0 则显示0
|
|
|
|
+ }
|
|
|
|
+ $(".count_price").text((count_price/100).toFixed(2));
|
|
|
|
+ }else{
|
|
|
|
+ $(".count_price").text((dt.data.payTotal/100).toFixed(2));
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
- mui.alert(dt.message);
|
|
|
|
- location.href = "shopping-cart.html?dates=" + new Date().getTime(); // 前往购物车
|
|
|
|
|
|
+ mui.alert(dt.message,function(){
|
|
|
|
+ location.href = "shopping-cart.html?dates=" + new Date().getTime(); // 前往购物车
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -257,133 +277,132 @@ var yhq_id=''; mui.ready(function() {
|
|
});
|
|
});
|
|
// 去支付
|
|
// 去支付
|
|
$(document).on('tap', '#go-pay', function() {
|
|
$(document).on('tap', '#go-pay', function() {
|
|
-
|
|
|
|
- var remark = $("#textarea").val();
|
|
|
|
- var ch_en_num = /^[A-Za-z0-9 _\[\]\【\】\{\}\{\}\(\)\(\)\《\》\<\>\,\,\.\。\、\!\!\~\·\@\#\¥\$\%\^\…\&\—\:\:\;\;\‘\’\'\'\"\"\“\”\?\?\-\=\|\*\+\-\u4e00-\u9fa5]{0,100}$/;
|
|
|
|
- if(ch_en_num.test(remark)){
|
|
|
|
- console.log("备注验证通过")
|
|
|
|
- }else{
|
|
|
|
- mui.alert("备注格式错误!仅支持中/英文,数字,普通符号");
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
- if(wechatAddr.status) {
|
|
|
|
- if(isPay) {
|
|
|
|
|
|
|
|
- isPay = false; // 锁定请求按钮
|
|
|
|
|
|
+ var remark = $("#textarea").val();
|
|
|
|
+ var ch_en_num = /^[A-Za-z0-9 _\[\]\【\】\{\}\{\}\(\)\(\)\《\》\<\>\,\,\.\。\、\!\!\~\·\@\#\¥\$\%\^\…\&\—\:\:\;\;\‘\’\'\'\"\"\“\”\?\?\-\=\|\*\+\-\u4e00-\u9fa5]{0,100}$/;
|
|
|
|
+ if(ch_en_num.test(remark)){
|
|
|
|
+ console.log("备注验证通过")
|
|
|
|
+ }else{
|
|
|
|
+ mui.alert("备注格式错误!仅支持中/英文,数字,普通符号");
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if(wechatAddr.status) {
|
|
|
|
+ if(isPay) {
|
|
|
|
+
|
|
|
|
+ isPay = false; // 锁定请求按钮
|
|
|
|
|
|
- /* 组装数据 */
|
|
|
|
- var dataArgs = {
|
|
|
|
- "orderAddressInfo": wechatAddr.detailInfo,
|
|
|
|
- "orderAddressPostNum": wechatAddr.postalCode,
|
|
|
|
- "orderAddressMoblie": wechatAddr.userTel,
|
|
|
|
- "orderAddressName": wechatAddr.userName,
|
|
|
|
- "cartIdStr": cartIdStr,
|
|
|
|
- "orderIntegralNum": 0,
|
|
|
|
- "orderUserRemark": remark,
|
|
|
|
- "couponId": yhq_id,
|
|
|
|
- "balancePayAmount": 0
|
|
|
|
- };
|
|
|
|
|
|
+ /* 组装数据 */
|
|
|
|
+ var dataArgs = {
|
|
|
|
+ "orderAddressInfo": wechatAddr.detailInfo,
|
|
|
|
+ "orderAddressPostNum": wechatAddr.postalCode,
|
|
|
|
+ "orderAddressMoblie": wechatAddr.userTel,
|
|
|
|
+ "orderAddressName": wechatAddr.userName,
|
|
|
|
+ "cartIdStr": cartIdStr,
|
|
|
|
+ "orderIntegralNum": 0,
|
|
|
|
+ "orderUserRemark": remark,
|
|
|
|
+ "couponId": yhq_id,
|
|
|
|
+ "balancePayAmount": 0
|
|
|
|
+ };
|
|
|
|
|
|
- $.ajax(base_path+'/wechat/order/pay', { // 提交订单,准备支付
|
|
|
|
- data: dataArgs,
|
|
|
|
- dataType: 'json',
|
|
|
|
- type: 'POST',
|
|
|
|
- xhrFields: {
|
|
|
|
- withCredentials: true
|
|
|
|
- },
|
|
|
|
- crossDomain: true,
|
|
|
|
- timeout: 15000,
|
|
|
|
- success: function(dt) {
|
|
|
|
- // layer.closeAll();
|
|
|
|
|
|
+ $.ajax(base_path+'/wechat/order/pay', { // 提交订单,准备支付
|
|
|
|
+ data: dataArgs,
|
|
|
|
+ dataType: 'json',
|
|
|
|
+ type: 'POST',
|
|
|
|
+ xhrFields: {
|
|
|
|
+ withCredentials: true
|
|
|
|
+ },
|
|
|
|
+ crossDomain: true,
|
|
|
|
+ timeout: 15000,
|
|
|
|
+ success: function(dt) {
|
|
|
|
+// layer.closeAll();
|
|
|
|
|
|
- //mui.alert(dt.resultCode=="500");
|
|
|
|
- if(dt.resultCode == "500") {
|
|
|
|
- mui.alert(dt.message);
|
|
|
|
- isPay = true;
|
|
|
|
- return;
|
|
|
|
- };
|
|
|
|
- if(dt.data.info == "isOK") {
|
|
|
|
- location.href = 'pay-win.html?orderId=' + dt.data.orderId + "&dates=" + new Date().getTime();
|
|
|
|
- return;
|
|
|
|
- };
|
|
|
|
- var orderId=dt.data.orderId;
|
|
|
|
- if(dt.status) {
|
|
|
|
- var str = dt.data.info;
|
|
|
|
- var obj = JSON.parse("{" + str + "}");
|
|
|
|
- WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
|
|
|
|
- //console.log(res)
|
|
|
|
- if(res.err_msg == 'get_brand_wcpay_request:ok') {
|
|
|
|
- $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
|
|
|
|
- data: {
|
|
|
|
- "orderId": orderId
|
|
|
|
- },
|
|
|
|
- dataType: 'json',
|
|
|
|
- xhrFields: {
|
|
|
|
- withCredentials: true
|
|
|
|
- },
|
|
|
|
- crossDomain: true,
|
|
|
|
- type: 'get',
|
|
|
|
- timeout: 15000,
|
|
|
|
- success: function(dataobj) {
|
|
|
|
- if(dataobj.isRedirect) {
|
|
|
|
- location.href = dataobj.redirectURL;
|
|
|
|
|
|
+ //mui.alert(dt.resultCode=="500");
|
|
|
|
+ if(dt.resultCode == "500") {
|
|
|
|
+ mui.alert(dt.message);
|
|
|
|
+ isPay = true;
|
|
|
|
+ return;
|
|
|
|
+ };
|
|
|
|
+ if(dt.data.info == "isOK") {
|
|
|
|
+ location.href = 'pay-win.html?orderId=' + dt.data.orderId + "&dates=" + new Date().getTime();
|
|
|
|
+ return;
|
|
|
|
+ };
|
|
|
|
+ var orderId=dt.data.orderId;
|
|
|
|
+ if(dt.status) {
|
|
|
|
+ var str = dt.data.info;
|
|
|
|
+ var obj = JSON.parse("{" + str + "}");
|
|
|
|
+ WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
|
|
|
|
+ //console.log(res)
|
|
|
|
+ if(res.err_msg == 'get_brand_wcpay_request:ok') {
|
|
|
|
+ $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
|
|
|
|
+ data: {
|
|
|
|
+ "orderId": orderId
|
|
|
|
+ },
|
|
|
|
+ dataType: 'json',
|
|
|
|
+ xhrFields: {
|
|
|
|
+ withCredentials: true
|
|
|
|
+ },
|
|
|
|
+ crossDomain: true,
|
|
|
|
+ type: 'get',
|
|
|
|
+ timeout: 15000,
|
|
|
|
+ success: function(dataobj) {
|
|
|
|
+ if(dataobj.isRedirect) {
|
|
|
|
+ location.href = dataobj.redirectURL;
|
|
|
|
+ } else {
|
|
|
|
+ if(dataobj.status == true) { // 支付成功
|
|
|
|
+ location.href = "pay-win.html?orderId=" + orderId + "&dates=" + new Date().getTime();
|
|
} else {
|
|
} else {
|
|
- if(dataobj.status == true) { // 支付成功
|
|
|
|
- location.href = "pay-win.html?orderId=" + orderId + "&dates=" + new Date().getTime();
|
|
|
|
- } else {
|
|
|
|
- location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
|
|
|
|
- }
|
|
|
|
|
|
+ location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
|
|
}
|
|
}
|
|
- },
|
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
|
- console.log(xhr);
|
|
|
|
- isPay = true;
|
|
|
|
- mui.alert("支付失败!网络错误");
|
|
|
|
}
|
|
}
|
|
- });
|
|
|
|
- // var orderIds = {
|
|
|
|
- // "orderId": dt.data.orderId
|
|
|
|
- // };
|
|
|
|
- // var url =base_path+"/wechat/order/checkOrderPaySuccess";
|
|
|
|
- // $.getJSON(url, {
|
|
|
|
- // "s": new Date().getTime(),
|
|
|
|
- // "orderId": dt.data.orderId
|
|
|
|
- // }, function(data) {
|
|
|
|
- // if(data.status == true) { // 支付成功
|
|
|
|
- // location.href = "pay-win.html?orderId=" + orderIds.orderId + "&dates=" + new Date().getTime();
|
|
|
|
- // } else {
|
|
|
|
- // setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000);
|
|
|
|
- // }
|
|
|
|
- // });
|
|
|
|
- } else {
|
|
|
|
- isPay = true;
|
|
|
|
- mui.alert("支付失败!请稍后重试!", function() {
|
|
|
|
- location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- isPay = true;
|
|
|
|
- mui.alert(dt.message);
|
|
|
|
- location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
|
|
|
+ },
|
|
|
|
+ error: function(xhr, type, errorThrown) {
|
|
|
|
+ console.log(xhr);
|
|
|
|
+ isPay = true;
|
|
|
|
+ mui.alert("支付失败!网络错误");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+// var orderIds = {
|
|
|
|
+// "orderId": dt.data.orderId
|
|
|
|
+// };
|
|
|
|
+// var url =base_path+"/wechat/order/checkOrderPaySuccess";
|
|
|
|
+// $.getJSON(url, {
|
|
|
|
+// "s": new Date().getTime(),
|
|
|
|
+// "orderId": dt.data.orderId
|
|
|
|
+// }, function(data) {
|
|
|
|
+// if(data.status == true) { // 支付成功
|
|
|
|
+// location.href = "pay-win.html?orderId=" + orderIds.orderId + "&dates=" + new Date().getTime();
|
|
|
|
+// } else {
|
|
|
|
+// setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000);
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+ } else {
|
|
|
|
+ isPay = true;
|
|
|
|
+ mui.alert("支付失败!请稍后重试!", function() {
|
|
|
|
+ location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
isPay = true;
|
|
isPay = true;
|
|
- // layer.closeAll();
|
|
|
|
- mui.alert("您的网络异常,请刷新重试!");
|
|
|
|
- return;
|
|
|
|
|
|
+ mui.alert(dt.message);
|
|
|
|
+ location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
|
|
}
|
|
}
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- mui.alert("正在请求支付中~~请稍后!");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ error: function(xhr, type, errorThrown) {
|
|
|
|
+ isPay = true;
|
|
|
|
+// layer.closeAll();
|
|
|
|
+ mui.alert("您的网络异常,请刷新重试!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
} else {
|
|
} else {
|
|
- mui.alert("请选择收货地址!");
|
|
|
|
|
|
+ mui.alert("正在请求支付中~~请稍后!");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ } else {
|
|
|
|
+ mui.alert("请选择收货地址!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
});
|
|
});
|
|
//实时监听文本框字数
|
|
//实时监听文本框字数
|
|
document.getElementById("textarea").addEventListener("input", function() {
|
|
document.getElementById("textarea").addEventListener("input", function() {
|