|
@@ -132,7 +132,7 @@ var yhq_id=''; mui.ready(function() {
|
|
|
console.log("有优惠券" + dt.data.couponItems.length + "张")
|
|
|
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.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>';
|
|
|
+ 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>';
|
|
|
});
|
|
|
$("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>');
|
|
|
}
|
|
@@ -257,132 +257,133 @@ var yhq_id=''; mui.ready(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) {
|
|
|
|
|
|
- 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; // 锁定请求按钮
|
|
|
+ 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;
|
|
|
- } else {
|
|
|
- if(dataobj.status == true) { // 支付成功
|
|
|
- location.href = "pay-win.html?orderId=" + orderId + "&dates=" + new Date().getTime();
|
|
|
+ //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 {
|
|
|
- location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
|
|
|
+ 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(); // 前往订单详情
|
|
|
+ }
|
|
|
}
|
|
|
+ },
|
|
|
+ error: function(xhr, type, errorThrown) {
|
|
|
+ console.log(xhr);
|
|
|
+ isPay = true;
|
|
|
+ mui.alert("支付失败!网络错误");
|
|
|
}
|
|
|
- },
|
|
|
- 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 {
|
|
|
+ });
|
|
|
+ // 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) {
|
|
|
isPay = true;
|
|
|
- mui.alert(dt.message);
|
|
|
- location.href = "order-details.html?orderId=" + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
|
|
|
+ // layer.closeAll();
|
|
|
+ mui.alert("您的网络异常,请刷新重试!");
|
|
|
+ return;
|
|
|
}
|
|
|
- },
|
|
|
- error: function(xhr, type, errorThrown) {
|
|
|
- isPay = true;
|
|
|
-// layer.closeAll();
|
|
|
- mui.alert("您的网络异常,请刷新重试!");
|
|
|
- return;
|
|
|
- }
|
|
|
- });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ mui.alert("正在请求支付中~~请稍后!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
} else {
|
|
|
- mui.alert("正在请求支付中~~请稍后!");
|
|
|
+ mui.alert("请选择收货地址!");
|
|
|
return;
|
|
|
}
|
|
|
- } else {
|
|
|
- mui.alert("请选择收货地址!");
|
|
|
- return;
|
|
|
- }
|
|
|
+
|
|
|
});
|
|
|
//实时监听文本框字数
|
|
|
document.getElementById("textarea").addEventListener("input", function() {
|