channel-clearing.html 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  8. <title>结算</title>
  9. <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
  10. <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
  11. <link rel="stylesheet" type="text/css" href="css/main.css" />
  12. <style>
  13. .mui-input-group .mui-input-row{height: 40px;padding-top: 0;}
  14. .no-line:after,.no-line:before{display: none;}
  15. .line{border-bottom: 1px solid rgba(0,0,0,.1);}
  16. </style>
  17. <script type="text/javascript">
  18. // 屏蔽分享
  19. window.hiddenAllWechatMenu = true;
  20. </script>
  21. </head>
  22. <body>
  23. <div>
  24. <!--头部选项卡-->
  25. <div id="pro-top-menu" class="mui-segmented-control sales_transportation_type">
  26. <!--(默认选中哪个就加上mui-active),其他不加-->
  27. <a class="mui-control-item mui-active " val="1" href="#item1">邮寄</a>
  28. <a class="mui-control-item " val="2" href="#item2">自提</a>
  29. </div>
  30. </div>
  31. <div class="mui-content" style="padding-bottom: 56px;">
  32. <div id="item1" class="mui-control-content mui-active">
  33. <div class="address-cantainner">
  34. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed">
  35. <li class="mui-table-view-cell">
  36. <div class="mui-table">
  37. <!--没有选地址时显示的div-->
  38. <div class="mui-table-cell mui-col-xs-12 table-middle btn-add-address">
  39. <div class="add-address"><span class="iconfont icon-jia"></span>添加收货地址</div>
  40. </div>
  41. <!--选择微信地址后显示的div-->
  42. <div id="user-address-div" style="display: none;">
  43. <!--<div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle">
  44. <p><span class="iconfont icon-dingwei"></span></p>
  45. </div>
  46. <div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle">
  47. <div>收货人:林笑笑 <span class="mui-pull-right">16899996678</span></div>
  48. <p>收货地址:广东省深圳市福田区莲花街道深圳特区 报业大厦12b</p>
  49. </div>
  50. <div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle">
  51. <p><span class="mui-icon mui-icon-arrowright"></span></p>
  52. </div>-->
  53. </div>
  54. </div>
  55. </li>
  56. </ul>
  57. </div>
  58. </div>
  59. <div id="item2" class="mui-control-content">
  60. <div class="mui-content-padded">
  61. <form class="mui-input-group no-line">
  62. <div class="mui-input-row line">
  63. <label style="width: 100%;"><span class="iconfont icon-dingwei" style="font-size: 16px;margin-right: 8px;"></span>自提点:<span id="selfAddressName"></span></label>
  64. </div>
  65. <div class="mui-input-row line">
  66. <label style="width: 25%;">姓名信息</label>
  67. <input style="width: 75%;" id="selfLifting-addressName" value="" type="text" maxlength="8" placeholder="请输入您的姓名">
  68. </div>
  69. <div class="mui-input-row line">
  70. <label style="width: 25%;">手机号码</label>
  71. <input style="width: 75%;" id="selfLifting-addressTel" value="" type="tel" maxlength="11" placeholder="请输入手机号码">
  72. </div>
  73. <div class="mui-input-row">
  74. <label style="width: 100%;padding: 11px 0;"><h6>(请确认信息,如您在自提现场,请咨询工作人员)</label>
  75. </div>
  76. </form>
  77. </div>
  78. </div>
  79. <div class="clearing-box">
  80. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed shopping-cart-list">
  81. </ul>
  82. <ul class="mui-table-view">
  83. <li class="mui-table-view-cell" id="ul-youhuiquan" style="padding-left:7px;display: none;">
  84. <a class="mui-navigate-right btn-youhuiquan">
  85. 优惠券<span class="mui-pull-right cl-red">未选择优惠券</span>
  86. </a>
  87. </li>
  88. <li>
  89. <div class="mui-input-row">
  90. <label class="lbl-remarks">订单备注</label>
  91. <input class="ipt-remarks" id="textarea" type="text" placeholder="选填:您对订单有特殊要求,可以在此备注">
  92. </div>
  93. </li>
  94. </ul>
  95. <div class="mui-content-padded mui-text-right">合计:<span class="pro-price">¥<span class="count_price">0.0</span></span>
  96. </div>
  97. </div>
  98. <div class="buy-footer1">
  99. <table class="tb-clearing">
  100. <tr>
  101. <td class="quanxuan">
  102. 共<span id="pro-count" class="cl-red">0</span>件商品
  103. </td>
  104. <td class="mui-text-center">需支付:<span class="count_price_box">¥<span class="pay_price">0.0</span></span>
  105. </td>
  106. <td>
  107. <a id="go-pay" class="mui-btn mui-pull-right add_gwc go-clearing">立即支付</a>
  108. </td>
  109. </tr>
  110. </table>
  111. </div>
  112. </div>
  113. <!-- 加载ing begin-->
  114. <div class="loading covers">
  115. <div class="loading-bj"></div>
  116. <p>正在加载...</p>
  117. </div>
  118. <!-- 加载ing end -->
  119. <script src="js/mui.min.js"></script>
  120. <script src="js/jquery-2.1.1.min.js"></script>
  121. <script src="js/main.js"></script>
  122. <script src="js/wechat-utils-1.0.js"></script>
  123. <script>
  124. window.addEventListener('pageshow', function(e) {
  125. // 通过persisted属性判断是否存在 BF Cache
  126. if(e.persisted) {
  127. location.reload();
  128. }
  129. });
  130. var userIntegral = 0; // 用户可用积分
  131. var meonyProportion = 0; // 兑换比例:1个积分=?分钱
  132. var payTotal = 0.0; // 支付总金额
  133. var userInputIntegral = 0; // 抵扣积分
  134. var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求
  135. var cartIdStr = ""; // 购物车ID
  136. var usePayMoney = 0;
  137. var ipt_balance = 0;
  138. var yhq_val = 0;
  139. var used_balance = 0;
  140. var yhq_type = 1;
  141. var yhq_id = '';
  142. var orderItem; //获取订单项信息
  143. var couponMoney = 0; //新人卷 - 优惠金额
  144. var isAllSelfLiftin = 1; //是否能够自提,默认能够
  145. var channelType = getParam("channelType"); //渠道类型
  146. var channelId = getParam("channelId"); //渠道id
  147. if(channelType == null || channelId == null ){
  148. channelType = 0;
  149. channelId=0;
  150. }
  151. //var wechatAddr = new Object();
  152. mui.ready(function() {
  153. var parameter = {}; //ajax参数json集合
  154. var cartidList = '';
  155. if(!window.sessionStorage) {
  156. mui.alert("您的浏览器不支持sessionStorage");
  157. } else {
  158. //读取上一个页面带过来的sessionStorage
  159. pay_data = JSON.parse(sessionStorage.getItem('pay_data'));
  160. if(pay_data != null) {
  161. cartidList = pay_data.text[0]; //购物项id集合
  162. parameter["cartIds"] = cartidList;
  163. parameter["isCustomize"] = 1;
  164. parameter["channelType"] = channelType;
  165. parameter["channelId"] = channelId;
  166. $.ajax(base_path + '/wechat/order/payBefore', {
  167. data: parameter,
  168. dataType: 'json',
  169. type: 'get',
  170. xhrFields: {
  171. withCredentials: true
  172. },
  173. crossDomain: true,
  174. timeout: 15000,
  175. success: function(dt) {
  176. if(dt.isRedirect) {
  177. location.href = dt.redirectURL;
  178. } else {
  179. if(dt.status == true) {
  180. // 购物项遍历
  181. console.log(dt);
  182. orderItem = dt.data.cartItems; //订单项信息
  183. mui.each(dt.data.cartItems, function(index) {
  184. if(this.productType == 101){ //刷头类
  185. var brPrice = this.productPrice; //优惠券金额
  186. if(couponMoney == 0 || couponMoney < brPrice){
  187. couponMoney = brPrice;
  188. }
  189. }
  190. })
  191. var liNote = "";
  192. var yhq_str = "";
  193. if(dt.data.couponItems!=null && typeof(dt.data.couponItems)!=undefined &&
  194. dt.data.couponItems.length > 0 && channelType==0 && channelId ==0) {
  195. $("#ul-youhuiquan").show();
  196. var str = '';
  197. mui.each(dt.data.couponItems, function() {
  198. var couponReduce = this.couponReduce,val='';
  199. //if(this.couponIsNewPeople == 1){ //新人卷
  200. // couponReduce = couponMoney;
  201. //}
  202. if(this.couponType==2){
  203. val=(couponReduce/10).toFixed(1)+"折";
  204. }else{
  205. val='¥' + ((couponReduce) / 100).toFixed(2);
  206. }
  207. str += '<li class="my-table-view-cell" style="opacity:.5;margin:20px 0;"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">'+ this.couponName +':'+val+'<h6>有效期至:' + this.couponUseEndDate + '</h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="radio" type="radio" class="mui-pull-left" val="' + (this.couponReduce / 100).toFixed(2) + '" couponid="' + this.couponItemId + '" couponType="' + this.couponId + '" zhekou="'+this.couponType+'" couponIsNewPeople="'+ this.couponIsNewPeople +'"/></div></div></li>';
  208. });
  209. str += '<li class="my-table-view-cell" style="opacity:.5;margin:20px 0;"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">不使用优惠券<h6></h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="radio" type="radio" class="mui-pull-left"/></div></div></li>';
  210. $("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: 25px 15px; overflow: scroll;max-height: 420px;">' + str + '</ul><button class="mui-btn my-btn-block my-btn-user-know" disabled="disabled">确认</button><span class="iconfont icon-guanbi"></span></div>');
  211. }
  212. var proCount = 0;
  213. mui.each(dt.data.cartItems, function(index) {
  214. if(this.productType == 101){ //刷头类
  215. var brPrice = this.productPrice; //优惠券金额
  216. if(couponMoney == 0 || couponMoney < brPrice){
  217. couponMoney = brPrice;
  218. }
  219. }
  220. var num = this.cartNum;
  221. proCount += num;
  222. var total = (num * this.productPrice / 100).toFixed(2); //购物车小计,单位分,保留两位小数
  223. var productId = this.cartProductId;
  224. /* 如果为自提,将说明 */
  225. var selfDesc = "";
  226. if(this.isSelfLifting != 1){
  227. selfDesc = "(提示:该产品不支持自提)";
  228. isAllSelfLiftin = 2;
  229. }
  230. liNote += '<div class="mui-table"><div class="mui-table-cell mui-col-xs-5"><img class="mui-media-object wh-100" src="' + this.productIntroduceImg + '"></div><div class="mui-table-cell table-middle mui-col-xs-7" style="line-height:2.5">' + this.productName + '<h6>颜色:' + this.productColor + '<span class="center">数量:' + num + '</span></h6><div>单价¥' + (this.productPrice / 100).toFixed(2) + '</div></div></div>';
  231. liNote += '<div class="cl-red">'+ selfDesc +'</div>';
  232. });
  233. var $productListUl = $(".shopping-cart-list");
  234. $productListUl.empty();
  235. $productListUl.append(liNote);
  236. // 保存数据
  237. payTotal = dt.data.payTotal; // 支付金额,单位分
  238. cartIdStr = dt.data.cartId; // 购物车ID
  239. //默认自己拉出地址
  240. if(dt.data.addressInfo != undefined && dt.data.addressInfo != null) {
  241. $(".btn-add-address").hide();
  242. $("#user-address-div").html('<div class="mui-table"><div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle"><p><span class="iconfont icon-dingwei"></span></p></div><div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle"><div>收货人:' + dt.data.addressInfo.salesAddressName + ' <span class="mui-pull-right">' + dt.data.addressInfo.salesAddressTel + '</span></div><p>收货地址:' + dt.data.addressInfo.salesAddressInfo + '</p></div><div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle"><p><span class="mui-icon mui-icon-arrowright"></span></p></div></div>').show();
  243. //给微信参数赋值
  244. wechatAddr.status = true;
  245. wechatAddr.detailInfo = dt.data.addressInfo.salesAddressInfo;
  246. wechatAddr.userName = dt.data.addressInfo.salesAddressName;
  247. wechatAddr.userTel = dt.data.addressInfo.salesAddressTel;
  248. wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum;
  249. /* 给自提姓名电话赋值 */
  250. $("#selfLifting-addressName").val(dt.data.addressInfo.salesAddressName);
  251. $("#selfLifting-addressTel").val(dt.data.addressInfo.salesAddressTel);
  252. }else{
  253. wechatAddr.status = false;
  254. }
  255. $("#selfAddressName").html(dt.data.channelName);
  256. $(".count_price,.pay_price").text((dt.data.payTotal / 100).toFixed(2));
  257. $("#pro-count").text(proCount);
  258. $(".loading").hide().css("opacity", "0"); //隐藏(正在加载...)
  259. } else {
  260. mui.alert("获取数据失败!", function() {
  261. location.href = "shopping-cart.html";
  262. });
  263. }
  264. }
  265. },
  266. error: function(xhr, type, errorThrown) {
  267. console.log(xhr);
  268. mui.alert("获取数据失败,网络错误!")
  269. }
  270. });
  271. } else {
  272. mui.alert("sessionStorage异常!", function() {
  273. location.href = "index.html";
  274. })
  275. }
  276. }
  277. // var str = "";
  278. // for(i = 0; i < 3; i++) {
  279. // str += '<div class="mui-table"><div class="mui-table-cell mui-col-xs-5"><img class="mui-media-object wh-100" src="images/pro-bai.png"></div><div class="mui-table-cell table-middle mui-col-xs-7" style="line-height:2.5">柔性声波牙刷<h6>颜色:极光白<span class="center">数量:2</span></h6><div>¥2999.00</div></div></div>';
  280. // }
  281. // document.querySelector('.shopping-cart-list').innerHTML = str;
  282. });
  283. //callback为用户点击蒙版时自动执行的回调;
  284. var mask = mui.createMask(function() {
  285. $(".my-picker").removeClass("active"); //隐藏弹窗
  286. });
  287. //现金券弹窗
  288. $(document).on('tap', '.btn-youhuiquan', function() {
  289. mask.show();
  290. // if($(".my-picker").length==0){
  291. // var li = '<li class="my-table-view-cell" style="opacity:.5;margin:20px 0;"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">现金券:¥99.9<h6>有效期至:2017-12-12</h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="radio" type="radio" class="mui-pull-left" /></div></div></li>';
  292. // var str = '';
  293. // for(i = 0; i < 17; i++) {
  294. // str += li;
  295. // }
  296. // $("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: 25px 15px; overflow: scroll;max-height: 420px;">' + str + '</ul><button class="mui-btn my-btn-block my-btn-user-know" disabled="disabled">确认使用</button><span class="iconfont icon-guanbi"></span></div>');
  297. // }
  298. // setTimeout(function() {
  299. if($(".my-picker").length > 0) {
  300. $(".my-picker").addClass("active");
  301. }
  302. // }, 500);
  303. });
  304. //确认使用
  305. $(document).on('tap', '.my-btn-user-know', function() {
  306. //console.log("确认使用");
  307. if(typeof($(".my-picker input[name=radio]:checked").attr("couponid")) != "undefined") {
  308. $(".btn-youhuiquan").attr("couponid", $(".my-picker input[name=radio]:checked").attr("couponid"));
  309. yhq_id = $(".my-picker input[name=radio]:checked").attr("couponid");
  310. $(".btn-youhuiquan span").text("-¥" + $(".my-picker input[name=radio]:checked").attr("val"));
  311. var couponIsNewPeople = $(".my-picker input[name=radio]:checked").attr("couponIsNewPeople");
  312. var couponType = $(".my-picker input[name=radio]:checked").attr("couponType");
  313. var price = 0;
  314. /*只减去刷头的钱*/
  315. if(couponIsNewPeople == 1){ //标识为新人卷
  316. if(couponType == 20000){
  317. var brushCouponPrice = 0; //刷头优惠总金额
  318. var otherPrice = 0;//其他商品总金额
  319. var couponPrice = $(".my-picker input[name=radio]:checked").attr("val"); //优惠券金额
  320. mui.each(orderItem,function(index){
  321. if(this.productType == 101){ //刷头类
  322. var brPrice = this.productPrice; //优惠券金额
  323. if(brushCouponPrice == 0 || brushCouponPrice < brPrice){
  324. brushCouponPrice = brPrice;
  325. }
  326. }
  327. });
  328. brushCouponPrice = accDiv(brushCouponPrice,100);
  329. price = accSub($(".count_price").text(),brushCouponPrice); //刷头减去优惠券
  330. $(".btn-youhuiquan span").text("-¥" + brushCouponPrice); //减去优惠金额赋值
  331. }else if(couponType == 40000){
  332. var brushPrice = 0; //刷头总金额
  333. var otherPrice = 0;//其他商品总金额
  334. var couponPrice = $(".my-picker input[name=radio]:checked").attr("val"); //优惠券金额
  335. mui.each(orderItem,function(index){
  336. if(this.productType == 101){
  337. brushPrice = accAdd(brushPrice,this.productPrice*this.cartNum);
  338. }else{
  339. otherPrice = accAdd(otherPrice,this.productPrice*this.cartNum);
  340. }
  341. });
  342. brushPrice = accDiv(brushPrice,100);
  343. otherPrice = accDiv(otherPrice,100);
  344. brushPrice = accSub(brushPrice,couponPrice); //刷头减去优惠券
  345. if(brushPrice <= 0){
  346. brushPrice = 0;
  347. }
  348. price = accAdd(brushPrice,otherPrice);
  349. }
  350. }else{
  351. if($(".my-picker input[name=radio]:checked").attr("zhekou")==2){
  352. price = accMul($(".count_price").text(),$(".my-picker input[name=radio]:checked").attr("val"));
  353. // price =parseInt($(".count_price").text()*$(".my-picker input[name=radio]:checked").attr("val"));
  354. $(".btn-youhuiquan span").text("-¥"+accSub($(".count_price").text(),price)); //减去折扣优惠金额赋值
  355. }else{
  356. price = accSub($(".count_price").text(),$(".my-picker input[name=radio]:checked").attr("val"));
  357. }
  358. }
  359. if(price <= 0) {
  360. price = 0.0; //判断商品价格减去现金券价格若<0 则显示0
  361. }
  362. $(".pay_price").text(price);
  363. } else {
  364. yhq_id = '';
  365. $(".btn-youhuiquan").removeAttr("couponid");
  366. $(".btn-youhuiquan span").text("不使用现金券");
  367. $(".pay_price").text($(".count_price").text());
  368. }
  369. $(".my-picker").removeClass("active"); //隐藏弹窗
  370. $(".mui-backdrop").remove(); //移除遮罩层
  371. });
  372. //单选事件
  373. $(document).on('tap', '.my-picker .my-table-view-cell', function() {
  374. $(this).find("input[name=radio]").prop("checked", true);
  375. $(this).css("opacity", "1");
  376. $(this).siblings().css("opacity", ".5");
  377. $(".my-btn-user-know").removeAttr("disabled").addClass("active");
  378. });
  379. //关闭弹窗
  380. $(document).on('tap', '.icon-guanbi', function() {
  381. $(".mui-backdrop").remove(); //移除遮罩层
  382. $(".my-picker").removeClass("active"); //隐藏弹窗
  383. });
  384. // 获取微信共享地址
  385. $(document).on('tap', '.btn-add-address,#user-address-div', function() {
  386. editAddrV1(
  387. function(res) {
  388. // 用户成功拉出地址
  389. var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  390. wechatAddr.status = true;
  391. wechatAddr.detailInfo = address;
  392. wechatAddr.postalCode = res.postalCode;
  393. wechatAddr.userName = res.userName;
  394. wechatAddr.userTel = res.telNumber;
  395. wechatAddr.nationalCode = res.nationalCode;
  396. $(".btn-add-address").hide();
  397. $("#user-address-div").html('<div class="mui-table"><div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle"><p><span class="iconfont icon-dingwei"></span></p></div><div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle"><div>收货人:' + wechatAddr.userName + ' <span class="mui-pull-right">' + wechatAddr.userTel + '</span></div><p>收货地址:' + wechatAddr.detailInfo + '</p></div><div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle"><p><span class="mui-icon mui-icon-arrowright"></span></p></div></div>').show();
  398. },
  399. function() {
  400. console.log(1232);
  401. if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  402. wechatAddr.status = true;
  403. } else {
  404. wechatAddr.status = false;
  405. // 用户取消拉出地址
  406. mui.alert("您没有选择收货地址!");
  407. }
  408. }
  409. );
  410. });
  411. // 去支付
  412. $(document).on('tap', '#go-pay', function() {
  413. var addressName,addressTel;
  414. var salesTransportationType = 1; //邮寄
  415. var val = $(".sales_transportation_type").find(".mui-active").eq(0).attr("val");
  416. if(parseInt(val) == 2){ //自提
  417. salesTransportationType = 2; //自提
  418. if(isAllSelfLiftin != 1){
  419. mui.toast("当前订单中有无法自提的物品,请重新选择商品!");
  420. return false;
  421. }
  422. /* 给自提姓名电话赋值 */
  423. addressName = $("#selfLifting-addressName").val();
  424. addressTel = $("#selfLifting-addressTel").val();
  425. if(addressName == null || addressName == ""){
  426. mui.toast("请填写您的姓名");
  427. return false;
  428. }
  429. var chinese_rsg = /^[\u4e00-\u9fa5]+$/;
  430. if(!chinese_rsg.test(addressName)){
  431. mui.toast("请正确填写您的姓名!");
  432. return false;
  433. }
  434. if(addressName.length > 10){
  435. mui.toast("请正确填写您的姓名!");
  436. return false;
  437. }
  438. if(addressTel == null || addressTel == ""){
  439. mui.toast("请填写您的电话号码");
  440. return false;
  441. }
  442. wechatAddr.status = true;
  443. }else{
  444. salesTransportationType = 1;
  445. addressName = wechatAddr.userName;
  446. addressTel = wechatAddr.userTel;
  447. }
  448. var remark = $("#textarea").val();
  449. var ch_en_num = /^[A-Za-z0-9 _\[\]\【\】\{\}\{\}\(\)\(\)\《\》\<\>\,\,\.\。\、\!\!\~\·\@\#\¥\$\%\^\…\&\—\:\:\;\;\‘\’\'\'\"\"\“\”\?\?\-\=\|\*\+\-\u4e00-\u9fa5]{0,100}$/;
  450. if(ch_en_num.test(remark)) {
  451. //console.log("备注验证通过")
  452. } else {
  453. mui.alert("备注格式错误!仅支持中/英文,数字,普通符号");
  454. return false;
  455. }
  456. if(wechatAddr.status) {
  457. // if($('#user-address-div').html() == null || $('#user-address-div').html() == '') {
  458. // wechatAddr.status = false;
  459. // mui.toast("请选择收货信息!");
  460. // return ;
  461. // }
  462. if(isPay) {
  463. isPay = false; // 锁定请求按钮
  464. /* 组装数据 */
  465. var dataArgs = {
  466. "orderAddressInfo": wechatAddr.detailInfo,
  467. "orderAddressPostNum": wechatAddr.postalCode,
  468. "orderAddressMoblie":addressTel,
  469. "orderAddressName": addressName,
  470. "cartIdStr": cartIdStr
  471. };
  472. if(yhq_id != '') {
  473. dataArgs["couponId"] = yhq_id;
  474. }
  475. if(remark != '') {
  476. dataArgs["orderUserRemark"] = remark;
  477. }
  478. dataArgs["isCustomize"] = 1;
  479. dataArgs["channelType"] = channelType;
  480. dataArgs["channelId"] = channelId;
  481. dataArgs["salesTransportationType"] = salesTransportationType;
  482. $.ajax(base_path + '/wechat/order/pay', { // 提交订单,准备支付
  483. data: dataArgs,
  484. dataType: 'json',
  485. type: 'post',
  486. xhrFields: {
  487. withCredentials: true
  488. },
  489. crossDomain: true,
  490. timeout: 15000,
  491. success: function(dt) {
  492. // layer.closeAll();
  493. //mui.alert(dt.resultCode=="500");
  494. if(dt.resultCode == "500") {
  495. mui.alert(dt.message);
  496. isPay = true;
  497. return;
  498. };
  499. if(dt.data.info == "isOK") {
  500. location.href = 'pay-win.html?orderId=' + dt.data.orderId + "&dates=" + new Date().getTime()
  501. return;
  502. };
  503. if(dt.status) {
  504. var str = dt.data.info;
  505. var obj = JSON.parse("{" + str + "}");
  506. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  507. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  508. $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  509. data: {
  510. "orderId": dt.data.orderId
  511. },
  512. dataType: 'json',
  513. xhrFields: {
  514. withCredentials: true
  515. },
  516. crossDomain: true,
  517. type: 'get',
  518. timeout: 15000,
  519. success: function(dataobj) {
  520. if(dataobj.isRedirect) {
  521. location.href = dataobj.redirectURL;
  522. } else {
  523. if(dataobj.status == true) { // 支付成功
  524. location.href = "pay-win.html?orderId=" + dataobj.data + "&dates=" + new Date().getTime();
  525. } else {
  526. location.href = "order-details.html?orderId=" + dataobj.data + "&dates=" + new Date().getTime(); // 前往订单详情
  527. }
  528. }
  529. },
  530. error: function(xhr, type, errorThrown) {
  531. console.log(xhr);
  532. }
  533. });
  534. } else {
  535. isPay = true;
  536. mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!", function() {
  537. location.href = "order-details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  538. });
  539. }
  540. });
  541. } else {
  542. isPay = true;
  543. mui.alert(dt.message);
  544. location.href = "order-details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  545. }
  546. },
  547. error: function(xhr, type, errorThrown) {
  548. isPay = true;
  549. // layer.closeAll();
  550. mui.alert("您的网络异常,请刷新重试!");
  551. return;
  552. }
  553. });
  554. } else {
  555. mui.alert("正在请求支付中~~请稍后!");
  556. return;
  557. }
  558. } else {
  559. mui.alert("请选择收货地址!");
  560. return;
  561. }
  562. });
  563. </script>
  564. </body>
  565. </html>