clearing.html 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title></title>
  6. <meta name="Expires" content="0">
  7. <meta name="Cache-Control" content="no-store, no-cache, must-revalidate">
  8. <meta name="Cache-Control" content="post-check=0, pre-check=0">
  9. <meta name="Pragma" content="no-cache">
  10. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
  11. <meta name="apple-mobile-web-app-capable" content="yes">
  12. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  13. <link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/mui.min.css?v=2016111701" />
  14. <link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/iconfont.css?v=2016111701" />
  15. <link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/style.css?v=2016111701" />
  16. <link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/clearing.css?v=2016111701" />
  17. <style>
  18. .my-yhq-tab>li{margin: 0;}
  19. .clearing-count{border-bottom: 30px solid #fff;}
  20. .mui-table-view-cell:after,.mui-table-view:before,.mui-table-view:after{left: 10px;right:10px;}
  21. .my-yhq-tab:before{left: 10px;right: 10px;}
  22. .my-yhq-tab:after{display: none;}
  23. .address-cantainner{margin:14px 14px 0 14px;background-color: #f3f3f3;text-align: center;}
  24. .address-cantainner .mui-table-view-cell{background-color: #f3f3f3;border-radius: 5px;padding: 11px 8px;}
  25. .address-cantainner .mui-table-view-cell.mui-active{background-color: #f3f3f3;}
  26. .address-cantainner .mui-table{max-height: 80px;min-height: 42px;}
  27. .address-cantainner .add-address{height: 20px;position: relative;width: 150px; margin: 0 auto;}
  28. .address-cantainner .icon-jia{position: absolute;left:0%;top: 0;font-size: 20px;}
  29. .address-cantainner p{font-size: 12px;}
  30. .icon-dingwei{color: #f16071;}
  31. .btn-add-address{height: 20px;line-height: 20px; position: relative;width: 110px; margin: 0 auto;text-align: right;color: #666;}
  32. .btn-add-address .icon-jia{position: absolute;left:0%;top: 0;font-size: 20px;}
  33. .table-top{vertical-align: top;}
  34. .table-bottom{vertical-align: bottom;}
  35. .table-middle{vertical-align: middle;}
  36. .gwc_tit{margin-bottom: 10px}
  37. .wh-100{background-color: #f3f3f3;border-radius: 10px;}
  38. .my-grid-view-no:after,.my-grid-view-no:before,.my-grid-view-no .mui-table-view-cell:after,.order-view-no:after,.order-view-no:before,.order-view-no>li:after{display: none !important;height: 0;}
  39. </style>
  40. <script type="text/javascript">
  41. // 屏蔽分享
  42. window.hiddenAllWechatMenu = true;
  43. </script>
  44. </head>
  45. <body style="background: #fff">
  46. <div class="loading-bg">
  47. <div class="mui-loading">
  48. <div class="mui-spinner">
  49. </div>
  50. &nbsp;&nbsp;加载中...
  51. </div>
  52. </div>
  53. <div class="mui-content" style="padding-bottom: 50px !important;background: #FFF;">
  54. <div class="address-cantainner">
  55. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed">
  56. <li class="mui-table-view-cell">
  57. <div class="mui-table">
  58. <!--没有选地址时显示的div-->
  59. <div class="mui-table-cell mui-col-xs-12 table-middle btn-add-address">
  60. <div class="add-address"><span class="iconfont icon-jia"></span>添加收货地址</div>
  61. </div>
  62. <div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle btn-add-address">
  63. <p><span class="mui-icon mui-icon-location"></span></p>
  64. </div>
  65. <!--选择微信地址后显示的div-->
  66. <div id="user-address-div" style="display: none;">
  67. <!--<div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle">
  68. <p><span class="iconfont icon-dingwei"></span></p>
  69. </div>
  70. <div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle">
  71. <div>收货人:林笑笑 <span class="mui-pull-right">16899996678</span></div>
  72. <p>收货地址:广东省深圳市福田区莲花街道深圳特区 报业大厦12b</p>
  73. </div>-->
  74. </div>
  75. </div>
  76. </li>
  77. </ul>
  78. </div>
  79. <!--<ul class="mui-table-view more">-->
  80. <!--<li class="mui-table-view-cell line-color" style="padding:20px 10px;">-->
  81. <!--<div style="display: none;" id="user-address-div"></div>-->
  82. <!--<a class="check_address" id="open-wechat-addres-a">-->
  83. <!--<span>请选择收货地址!</span><span class="mui-icon mui-icon-forward icon-r-c"></span>-->
  84. <!--</a>-->
  85. <!--</li>-->
  86. <!--</ul>-->
  87. <ul class="mui-table-view mui-table-view-chevron my-grid-view-no" id="products-list-ul">
  88. <li class="mui-table-view-cell mui-media" id="load-li">
  89. &nbsp;&nbsp;加载产品信息中...
  90. </li>
  91. </ul>
  92. <ul class="mui-table-view my-yhq-tab">
  93. <li class="mui-table-view-cell forward" style="margin: 0">
  94. <a href="#forward" class="mui-navigate-right">
  95. <div class="mui-media-body">
  96. 我的优惠券<span class="yhq-right"><span class="cl-red" id="yhq_count">0</span>张可使用</span>
  97. </div>
  98. </a>
  99. </li>
  100. <div style="padding: 10px 15px 0 15px;display: none;">可用余额:<span class="cl-red" id="used_balance">¥0.00</span></div>
  101. <li class="mui-table-view-cell pay_ipt_box" style="padding: 0;display: none;">
  102. <div class="mui-input-group">
  103. <div class="mui-input-row">
  104. <label>输入使用金额:</label>
  105. <input id="pay_ipt" type="number" placeholder="(如699)">
  106. </div>
  107. </div>
  108. </li>
  109. <li class="mui-table-view-cell" style="padding: 0;margin: 0;">
  110. <div class="mui-input-group">
  111. <div class="mui-input-row">
  112. <label>订单备注:</label>
  113. <input style="font-size: 12px" type="text" placeholder="(选填:订单要求,可以在此备注)" id="textarea">
  114. </div>
  115. </div>
  116. </li>
  117. <li class="mui-table-view-cell" style="padding: 0;margin: 0;">
  118. <div class="mui-input-group">
  119. <div class="mui-input-row">
  120. <label>商品金额:</label>
  121. <input style="font-size: 12px;text-align: right;" type="text" readonly="readonly" placeholder="(选填:订单要求,可以在此备注)" id="total">
  122. </div>
  123. </div>
  124. </li>
  125. <li class="mui-table-view-cell" id="vipSub" style="display: none;">
  126. <div style="display: block;"><span>VIP专享(1年滤芯套装)</span><span class="mui-pull-right"><span id="vip_price">- ¥0</span></span></div>
  127. </li>
  128. <li class="mui-table-view-cell" id="accSub">
  129. <div><span id="yhq_name"></span><span class="mui-pull-right"><span id="yhq_price"></span></span></div>
  130. <div>账户余额:<span class="mui-pull-right cl-red">- ¥<span id="used_buy">0</span></span></div>
  131. </li>
  132. </ul>
  133. <div class="clearing-count" style="text-align: right;">订单合计:<font class="cl-red">¥</font><span class="cl-red" id="user-pay-money-span">加载中...</span></div>
  134. <div class="pay_weixin">
  135. <button type="button" class="mui-btn mui-btn-success mui-btn-block btn-weixin-pay" id="btn-weixin-pay" style="border-radius: 0;background-color: #55c0dc;border-color: #55c0dc;">立即支付</button>
  136. </div>
  137. </div>
  138. <div id="forward" class="mui-popover mui-popover-action mui-popover-bottom">
  139. <div class="mui-input-group mui-table-view-radio my-popover ">
  140. </div>
  141. <ul class="mui-table-view">
  142. <li class="mui-table-view-cell">
  143. <a href="#forward"><b>确定</b></a>
  144. </li>
  145. </ul>
  146. </div>
  147. <script src="//s.iamberry.com/watero/js/mui.min.js?v=2016111701"></script>
  148. <script src="//s.iamberry.com/watero/js/jquery-2.1.1.min.js"></script>
  149. <script src="/watero/common/shop/js/page/main.js?v=20170622"></script>
  150. <script src="//s.iamberry.com/watero/js/shop/wechat-utils-1.0.js?v=201706001"></script>
  151. <script src="//s.iamberry.com/watero/js/shop/layer.js"></script>
  152. <script>
  153. var userIntegral = 0; // 用户可用积分
  154. var meonyProportion = 0; // 兑换比例:1个积分=?分钱
  155. var payTotal = 0.0; // 支付总金额
  156. var userInputIntegral = 0; // 抵扣积分
  157. var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求
  158. var cartIdStr = ""; // 购物车ID
  159. var usePayMoney = 0;
  160. var ipt_balance = 0;
  161. var yhq_val = 0;
  162. var used_balance = 0;
  163. var yhq_type = 1;
  164. var showIs = false;
  165. var accVipSub=0;
  166. mui.ready(function() {
  167. var name,value;
  168. var str=location.href; //取得整个地址栏
  169. var num=str.indexOf("?")
  170. str=str.substr(num+1); //取得所有参数
  171. mui.ajax(base_path+'/order/payBefore?'+str, {
  172. dataType: 'json',
  173. type: 'POST',
  174. timeout: 15000,
  175. success: function(dt) {
  176. if(dt.status == true) {
  177. // 购物项遍历
  178. //console.log(dt)
  179. var liNote = "";
  180. var cNum = 0;
  181. if(dt.data.balance == 0) {
  182. $(".pay_ipt_box").hide();
  183. } else {
  184. used_balance = accDiv(dt.data.balance, 100);
  185. $('#used_balance').html("¥ " + accDiv(dt.data.balance, 100));
  186. }
  187. var yhq_str = "";
  188. if(dt.data.couponItems.length == 0 || !dt.data.disable) {
  189. $(".forward").hide();
  190. } else {
  191. $("#yhq_count").html(dt.data.couponItems.length);
  192. //如果购买商品只有饮水机滤芯,则不能使用优惠券
  193. if (dt.data.disable) {
  194. mui(dt.data.couponItems).each(function(index) {
  195. yhq_str += '<div class="mui-input-row mui-radio"><label>' + this.couponName + '</label><input name="radio1" value="' + accDiv(this.couponReduce, 100) + '" type="radio" id="' + this.couponItemId + '" yhq_type="' + this.couponType + '"></div>';
  196. });
  197. $(".my-popover").html(yhq_str + '<div class="mui-input-row mui-radio"><label>不使用优惠券</label><input name="radio1" value="1" type="radio"></div>');
  198. }
  199. }
  200. for(var i = 0; i < dt.data.cartItems.length; i++) {
  201. var total = dt.data.cartItems[i].cartNum * dt.data.cartItems[i].productPrice / 100; // 购物车小计,分-->元
  202. var pro_color = switchcolor(dt.data.cartItems[i].cartColorId);
  203. var colorImg = switchColorImg(dt.data.cartItems[i].cartColorId);
  204. total = total.toFixed(2); // 保留两位小数
  205. var productId = dt.data.cartItems[i].cartProductId;
  206. var colorId=dt.data.cartItems[i].cartColorId;
  207. var price = dt.data.cartItems[i].productPrice;
  208. var num = dt.data.cartItems[i].cartNum;
  209. if (dt.data.cartItems[i].productPrice / 100 == 3280) {
  210. liNote = liNote +
  211. "<li class='mui-table-view-cell mui-media'>" +
  212. "<a>" +
  213. "<span class='mui-media-object mui-pull-left wh-100'> <img src='" + dt.data.cartItems[i].productIntroduceImg + "'></span>" +
  214. "<div class='mui-media-body' style='padding: 5% 0;'>" +
  215. "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "</div>" +
  216. "<div><small class='mui-h6 mui-pull-right'>" + pro_color + "x"+dt.data.cartItems[i].cartNum+"</small></div>"+
  217. "</div>" +
  218. "<div class='price_sp cl-gwc' id='product-" + productId + "' price='" + price + "'>¥" + total + "</div>"+
  219. "</a>" +
  220. "</li>";
  221. cNum = cNum + num ;
  222. showIs = true;
  223. } else {
  224. liNote = liNote +
  225. "<li class='mui-table-view-cell mui-media'>" +
  226. "<a>" +
  227. "<span class='mui-media-object mui-pull-left wh-100'> <img src='" + dt.data.cartItems[i].productIntroduceImg + "'></span>" +
  228. "<div class='mui-media-body' style='padding: 5% 0;'>" +
  229. "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "</div>" +
  230. "<div><small class='mui-h6 mui-pull-right'>" + pro_color + "x"+dt.data.cartItems[i].cartNum+"</small></div>"+
  231. "</div>" +
  232. "<div class='price_sp cl-gwc' id='product-" + productId + "' price='" + price + "'>¥" + total + "</div>"+
  233. "</a>" +
  234. "</li>";
  235. }
  236. if(dt.data.cartItems[i].cartColorId==5 && dt.data.cartItems[i].cartProductId==38){
  237. accVipSub+=(100* dt.data.cartItems[i].cartNum);
  238. }
  239. }
  240. if (showIs)
  241. {
  242. liNote = liNote +
  243. "<li class='mui-table-view-cell mui-media'>" +
  244. "<a>" +
  245. "<span class='mui-media-object mui-pull-left wh-100'> <img src='//w.iamberry.com/watero/common/images/uploadimages/image/20161202/2C83538AC3039E693358_20161202182946_8118.jpg'></span>" +
  246. "<div class='mui-media-body'>" +
  247. "<div class='wt-space gwc_tit'>" +
  248. '赠送' + "<span id='giveNum'>" + cNum + '</span>' + '套三年滤芯' +
  249. "<span class='price_sp cl-gwc mui-pull-right' id='product-39' price='39'>¥" + 0 + "</span></div>" +
  250. "<small class='gwc_pp'>颜色:" + '无' + "</small>" +
  251. "</div>" +
  252. "</a>" +
  253. "</li>"
  254. }
  255. var $productListUl = $("#products-list-ul");
  256. $productListUl.empty();
  257. $productListUl.append(liNote);
  258. dt.data.userIntegral = dt.data.userIntegral - 1;
  259. // 保存数据
  260. meonyProportion = dt.data.meonyProportion; // 兑换比例
  261. payTotal = dt.data.payTotal; // 支付金额,单位分
  262. userIntegral = dt.data.userIntegral; // 用户可用积分
  263. cartIdStr = dt.data.cartId; // 购物车ID
  264. // 替换数据
  265. usePayMoney = accDiv(dt.data.payTotal, 100);
  266. $("#total").val(usePayMoney.toFixed(2) + " 元");
  267. $("#user-integral-span").html(dt.data.userIntegral);
  268. if(dt.data.userIsVip==2){
  269. $("#vip_price").text("- ¥"+(accVipSub).toFixed(2));
  270. $("#vipSub").show();
  271. usePayMoney-=accVipSub;
  272. }
  273. $("#user-pay-money-span").html(usePayMoney.toFixed(2) + " 元");
  274. //默认自己拉出地址
  275. if(dt.data.addressInfo != undefined && dt.data.addressInfo != null) {
  276. $(".btn-add-address").hide();
  277. $("#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();
  278. //给微信参数赋值
  279. wechatAddr.status = true;
  280. wechatAddr.detailInfo = dt.data.addressInfo.salesAddressInfo;
  281. wechatAddr.userName = dt.data.addressInfo.salesAddressName;
  282. wechatAddr.userTel = dt.data.addressInfo.salesAddressTel;
  283. wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum;
  284. }
  285. } else {
  286. mui.alert(dt.message);
  287. }
  288. },
  289. error: function(xhr, type, errorThrown) {
  290. errorfn(xhr);
  291. }
  292. });
  293. // 获取微信共享地址
  294. $(document).on('tap', '.btn-add-address,#user-address-div', function() {
  295. editAddrV1(
  296. function(res) {
  297. // 用户成功拉出地址
  298. var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  299. wechatAddr.status = true;
  300. wechatAddr.detailInfo = address;
  301. wechatAddr.postalCode = res.postalCode;
  302. wechatAddr.userName = res.userName;
  303. wechatAddr.userTel = res.telNumber;
  304. wechatAddr.nationalCode = res.nationalCode;
  305. $(".btn-add-address").hide();
  306. $("#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();
  307. },
  308. function() {
  309. if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  310. wechatAddr.status = true;
  311. } else {
  312. wechatAddr.status = false;
  313. // 用户取消拉出地址
  314. mui.alert("您没有选择收货地址!");
  315. }
  316. }
  317. );
  318. });
  319. // mui('body').on('tap', '#open-wechat-addres-a,#user-address-div', function() {
  320. // editAddrV1(
  321. // function(res) {
  322. // // 用户成功拉出地址
  323. // var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  324. // wechatAddr.status = true;
  325. // wechatAddr.detailInfo = address;
  326. // wechatAddr.postalCode = res.postalCode;
  327. // wechatAddr.userName = res.userName;
  328. // wechatAddr.userTel = res.telNumber;
  329. // wechatAddr.nationalCode = res.nationalCode;
  330. //
  331. // $("#user-address-div").empty().append(
  332. // "收货人:" + wechatAddr.userName + "<span class='ml-5'>" + wechatAddr.userTel + "</span>" +
  333. // "<a>" +
  334. // "<p class='shipping_address wt-space'>" + wechatAddr.detailInfo + "<span class='mui-icon mui-icon-arrowright icon-r-c'></span></p>" +
  335. // "</a>");
  336. // $("#user-address-div").show();
  337. // $("#open-wechat-addres-a").hide();
  338. // },
  339. // function() {
  340. // if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  341. // wechatAddr.status = true;
  342. // } else {
  343. // wechatAddr.status = false;
  344. // // 用户取消拉出地址
  345. // mui.alert("您没有选择收货地址!");
  346. // }
  347. // }
  348. // );
  349. //
  350. // });
  351. // 积分数量改变时
  352. mui('body').on('change', '#input-user-integral', function() {
  353. var inputUserIntegral = $("#input-user-integral").val();
  354. $.trim(inputUserIntegral);
  355. var r = /^[1-9]+\d*$/;
  356. if(!r.test(inputUserIntegral)) {
  357. $("#input-user-integral").val(userInputIntegral);
  358. return false;
  359. }
  360. inputUserIntegral = parseInt(inputUserIntegral);
  361. if(inputUserIntegral > userIntegral) {
  362. $("#input-user-integral").val(userInputIntegral);
  363. return false;
  364. }
  365. if((inputUserIntegral * meonyProportion) > payTotal) {
  366. $("#input-user-integral").val(userInputIntegral);
  367. return false;
  368. }
  369. // 置换数据
  370. userInputIntegral = inputUserIntegral;
  371. var temp = (userInputIntegral * meonyProportion / 100).toFixed(2);
  372. $("#integral-money-span").html(temp);
  373. temp = ((payTotal - (userInputIntegral * meonyProportion)) / 100).toFixed(2);
  374. $("#user-pay-money-span").html(temp);
  375. });
  376. // 去支付
  377. mui('body').on('tap', '.btn-weixin-pay', function() {
  378. var yhq_id = $("input[name=radio1]:checked").attr('id');
  379. if(yhq_id == undefined) {
  380. yhq_id = "";
  381. }
  382. var remark = $("#textarea").val();
  383. var pattern = new RegExp("[ `~!@#$^&*()=|{}':;'\\[\\]<>/?~!@#¥……&*()——|{}【】‘;:”“'、?]")
  384. if(remark != "") {
  385. $.trim(remark);
  386. if(pattern.test(remark)) {
  387. mui.alert("请不要输入中文、字母、数字以外的特殊字符!");
  388. return;
  389. }
  390. if(!(remark.length >= 0 && remark.length <= 100)) {
  391. mui.alert("备注字数长度在0-100之间!");
  392. return;
  393. }
  394. }
  395. if(wechatAddr.status) {
  396. if(isPay) {
  397. isPay = false; // 锁定请求按钮
  398. layer.open({
  399. type: 2,
  400. shadeClose: false,
  401. content: "正在请求加载订单信息..."
  402. }); // 调用加载弹出层
  403. /* 组装数据 */
  404. var dataArgs = {
  405. "orderAddressInfo": wechatAddr.detailInfo,
  406. "orderAddressPostNum": wechatAddr.postalCode,
  407. "orderAddressMoblie": wechatAddr.userTel,
  408. "orderAddressName": wechatAddr.userName,
  409. "cartIdStr": cartIdStr,
  410. "orderIntegralNum": userInputIntegral,
  411. "orderUserRemark": remark,
  412. "couponId": yhq_id,
  413. "balancePayAmount": accMul(ipt_balance, 100)
  414. };
  415. mui.ajax('/watero/wechat/order/pay', { // 提交订单,准备支付
  416. data: dataArgs,
  417. dataType: 'json',
  418. type: 'POST',
  419. timeout: 15000,
  420. success: function(dt) {
  421. layer.closeAll();
  422. //mui.alert(dt.resultCode=="500");
  423. if(dt.resultCode == "500") {
  424. mui.alert(dt.message);
  425. isPay = true;
  426. return;
  427. };
  428. if(dt.data.info == "isOK") {
  429. mui.openWindow({
  430. url: domanUrl + base_path+"/order/paySuccess?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime()
  431. });
  432. return;
  433. };
  434. if(dt.status) {
  435. var str = dt.data.info;
  436. var obj = JSON.parse("{" + str + "}");
  437. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  438. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  439. var orderIds = {
  440. "orderId": dt.data.orderId
  441. };
  442. layer.open({
  443. type: 2,
  444. shadeClose: false,
  445. content: "正在请求加载订单信息..."
  446. }); // 调用加载弹出层
  447. var url = base_path+"/order/checkOrderPaySuccess";
  448. $.getJSON(url, {
  449. "s": new Date().getTime(),
  450. "orderId": dt.data.orderId
  451. }, function(data) {
  452. if(data.status == true) { // 支付成功
  453. window.location.href = base_path + "/order/paySuccess?orderId=" + orderIds.orderId + "&dates=" + new Date().getTime();
  454. } else {
  455. setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000);
  456. }
  457. });
  458. } else {
  459. isPay = true;
  460. // mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!");
  461. window.location.href = "/watero/pay/goOrderInfo?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  462. }
  463. });
  464. } else {
  465. isPay = true;
  466. mui.alert(dt.message);
  467. window.location.href = "/watero/pay/goOrderInfo?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  468. }
  469. },
  470. error: function(xhr, type, errorThrown) {
  471. isPay = true;
  472. layer.closeAll();
  473. mui.alert("您的网络异常,请刷新重试!");
  474. return;
  475. }
  476. });
  477. } else {
  478. mui.alert("正在请求支付中~~请稍后!");
  479. return;
  480. }
  481. } else {
  482. mui.alert("请选择收货地址!");
  483. return;
  484. }
  485. });
  486. mui('body').on('tap', '.mui-popover-action li>a', function() {
  487. var a = this,
  488. parent;
  489. //根据点击按钮,反推当前是哪个actionsheet
  490. for(parent = a.parentNode; parent != document.body; parent = parent.parentNode) {
  491. if(parent.classList.contains('mui-popover-action')) {
  492. break;
  493. }
  494. }
  495. //关闭actionsheet
  496. mui('#' + parent.id).popover('toggle');
  497. yhq_val = $("input[name=radio1]:checked").val();
  498. yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
  499. if(yhq_val == undefined) {
  500. yhq_val = 0
  501. } else {
  502. if(yhq_type == 1) {
  503. if(yhq_val > (usePayMoney - ipt_balance)) {
  504. $("input[name=radio1]:checked").removeAttr("checked");
  505. yhq_val = 0;
  506. mui.alert(' ', '当前优惠券不可用', function() {});
  507. }
  508. console.log($("input[name=radio1]:checked").prev().html());
  509. $("#yhq_name").html($("input[name=radio1]:checked").prev().html());
  510. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  511. $("#accSub,#accSub>div:first-child").show();
  512. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  513. }else if(yhq_type == 3){
  514. if(yhq_val > (usePayMoney - ipt_balance)) {
  515. $("input[name=radio1]:checked").removeAttr("checked");
  516. yhq_val = 0;
  517. mui.alert(' ', '当前优惠券不可用', function() {});
  518. }
  519. $("#yhq_name").html($("input[name=radio1]:checked").prev().html());
  520. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  521. $("#accSub,#accSub>div:first-child").show();
  522. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  523. } else {
  524. yhq_val = accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100);
  525. $("#yhq_name").html($("input[name=radio1]:checked").prev().html());
  526. $("#yhq_price").html("- ¥"+yhq_val);
  527. $("#accSub,#accSub>div:first-child").show();
  528. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  529. }
  530. }
  531. });
  532. mui.os.ios ? listener_ipt() : keyup_fn();
  533. var reg = /^(([1-9]\d*))$/;
  534. function keyup_fn() {
  535. $('body').on('blur', '#pay_ipt', function(e) {
  536. ipt_balance = $(this).val();
  537. if(reg.test(ipt_balance)) {
  538. if(ipt_balance > (usePayMoney - yhq_val)) {
  539. ipt_balance = (usePayMoney - yhq_val).toFixed(2);
  540. if(ipt_balance < 0) {
  541. ipt_balance = 0;
  542. $(this).val("");
  543. } else {
  544. $(this).val((usePayMoney - yhq_val).toFixed(2));
  545. }
  546. }
  547. if(ipt_balance > used_balance) {
  548. ipt_balance = used_balance;
  549. $(this).val(used_balance);
  550. }
  551. $('#used_buy').html(ipt_balance);
  552. var money = (usePayMoney - yhq_val).toFixed(2);
  553. money <= 0 ? money = 0 : money;
  554. $("#accSub,#accSub>div:last-child").show();
  555. $("#user-pay-money-span").html((money - ipt_balance).toFixed(2) + " 元");
  556. } else {
  557. mui.alert(' ', '您输入的数字有误,请重新输入', function() {
  558. $(this).val("");
  559. ipt_balance = 0;
  560. $('#used_buy').html(ipt_balance);
  561. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
  562. });
  563. }
  564. });
  565. }
  566. function listener_ipt() {
  567. document.getElementById('pay_ipt').onblur = function() {
  568. var th = this;
  569. ipt_balance = th.value;
  570. if(reg.test(ipt_balance)) {
  571. if(ipt_balance > (usePayMoney - yhq_val)) {
  572. ipt_balance = (usePayMoney - yhq_val).toFixed(2);
  573. if(ipt_balance < 0) {
  574. ipt_balance = 0;
  575. th.value = "";
  576. } else {
  577. th.value = (usePayMoney - yhq_val).toFixed(2);
  578. }
  579. }
  580. if(ipt_balance > used_balance) {
  581. th.value = used_balance;
  582. ipt_balance = used_balance;
  583. }
  584. $('#used_buy').html(ipt_balance);
  585. var money = (usePayMoney - yhq_val).toFixed(2);
  586. money <= 0 ? money = 0 : money;
  587. $("#accSub,#accSub>div:last-child").show();
  588. $("#user-pay-money-span").html((money - ipt_balance).toFixed(2) + " 元");
  589. } else {
  590. mui.alert(' ', '您输入的数字有误<br>请重新输入', function() {
  591. th.value = "";
  592. ipt_balance = 0;
  593. $('#used_buy').html(ipt_balance);
  594. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
  595. });
  596. }
  597. }
  598. }
  599. document.querySelector('.loading-bg').style.display = 'none';
  600. });
  601. // 校验订单状态
  602. function checkOrderStatus(orderId) {
  603. var url = base_path + "/order/checkOrderPaySuccess";
  604. var order = {
  605. "s": new Date().getTime(),
  606. "orderId": orderId
  607. };
  608. $.getJSON(url, order, function(data) {
  609. if(data.status == true) { // 支付成功
  610. window.location.href = base_path + "/order/paySuccess?orderId=" + orderId + "&dates=" + new Date().getTime();
  611. } else {
  612. window.location.href = '/watero/pay/goOrderInfo?orderId=' + orderId + "&dates=" + new Date().getTime();;
  613. }
  614. });
  615. }
  616. // 点击加号的事件
  617. function shoppAddEvent(productId,colorId) {
  618. mui.ajax(base_path + '/cart/addCart', {
  619. data: {
  620. "productId": productId,
  621. "carNum": 1,
  622. "colorId":colorId
  623. },
  624. dataType: 'json',
  625. type: 'GET',
  626. timeout: 15000,
  627. success: function(dt) {
  628. if(dt.status == true) {
  629. // 销售价
  630. var productObj = $("#product-" + productId);
  631. var price = parseInt(productObj.attr("price"));
  632. // total
  633. var total = payTotal + price;
  634. payTotal = total;
  635. // 修改数量
  636. var shoppNumObj = $("#shoppNum-" + productId);
  637. var num = parseInt(shoppNumObj.val());
  638. shoppNumObj.val(num + 1);
  639. /* $("#user-pay-money-span").html((payTotal / 100).toFixed(2)); */
  640. yhq_val = $("input[name=radio1]:checked").val();
  641. yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
  642. usePayMoney = accDiv(payTotal, 100);
  643. if(yhq_val == undefined) {
  644. yhq_val = 0
  645. }
  646. if(yhq_type == 2) {
  647. yhq_val = accSub(usePayMoney, (Math.floor(accMul(yhq_val, usePayMoney) * 100) / 100));
  648. $("#yhq_price").html(accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100));
  649. }
  650. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
  651. // 修改小计
  652. productObj.html("¥" + ((num + 1) * price / 100).toFixed(2));
  653. var temp = new Number($("#shoppNum-all").val());
  654. temp = temp + 3;
  655. $("#shoppNum-all").val(temp);
  656. if(showIs){
  657. var gNum = $("#giveNum").html();
  658. var rNum = parseInt(gNum) + 1;
  659. $("#giveNum").html(rNum);
  660. }
  661. } else {
  662. // 失败之后的事件
  663. mui.alert(dt.message);
  664. }
  665. },
  666. error: function(xhr, type, errorThrown) {}
  667. });
  668. }
  669. // 购物车减
  670. function shoppSubEvent(productId,colorId) {
  671. var shoppNumObj = $("#shoppNum-" + productId);
  672. var num = parseInt(shoppNumObj.val());
  673. if(num <= 1) {
  674. mui.alert("不能继续减少了哦!");
  675. return;
  676. }
  677. mui.ajax(base_path + '/cart/deleteCart', {
  678. data: {
  679. "productId": productId,
  680. "cartNum": 1,
  681. "colorId":colorId
  682. },
  683. dataType: 'json',
  684. type: 'GET',
  685. timeout: 15000,
  686. success: function(dt) {
  687. if(dt.status == true) {
  688. // 销售价
  689. var productObj = $("#product-" + productId);
  690. var price = parseInt(productObj.attr("price"));
  691. // total
  692. var total = payTotal - price;
  693. payTotal = total;
  694. // 修改数量
  695. var shoppNumObj = $("#shoppNum-" + productId);
  696. var num = parseInt(shoppNumObj.val());
  697. shoppNumObj.val(num - 1);
  698. /*$("#user-pay-money-span").html((payTotal / 100).toFixed(2));*/
  699. yhq_val = $("input[name=radio1]:checked").val();
  700. yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
  701. usePayMoney = accDiv(payTotal, 100);
  702. if(yhq_val == undefined) {
  703. yhq_val = 0
  704. }
  705. if(yhq_type == 2) {
  706. yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_val, usePayMoney) * 100) / 100);
  707. $("#yhq_price").html(accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100));
  708. if(ipt_balance > (usePayMoney - yhq_val)) {
  709. if((usePayMoney - yhq_val) <= 0) {
  710. ipt_balance = 0;
  711. $('#used_buy').html(ipt_balance);
  712. $('#pay_ipt').val("");
  713. } else {
  714. ipt_balance = (usePayMoney - yhq_val).toFixed(2);
  715. $('#used_buy').html(ipt_balance);
  716. $('#pay_ipt').val(ipt_balance);
  717. }
  718. }
  719. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
  720. } else {
  721. if((usePayMoney - yhq_val) < ipt_balance) {
  722. if((usePayMoney - yhq_val) <= 0) {
  723. ipt_balance = 0;
  724. $('#used_buy').html(ipt_balance);
  725. $('#pay_ipt').val("");
  726. } else {
  727. ipt_balance = (usePayMoney - yhq_val).toFixed(2);
  728. $('#used_buy').html(ipt_balance);
  729. $('#pay_ipt').val(ipt_balance);
  730. }
  731. }
  732. if(yhq_val > (usePayMoney - ipt_balance)) {
  733. mui.alert(' ', '当前优惠券不可用', function() {
  734. $("input[name=radio1]:checked").removeAttr("checked");
  735. yhq_val = 0;
  736. $("#yhq_price").html(yhq_val);
  737. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
  738. });
  739. }
  740. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
  741. }
  742. var temp = new Number($("#shoppNum-all").val());
  743. temp = temp - 3;
  744. $("#shoppNum-all").val(temp+"")
  745. productObj.html("¥" + ((num - 1) * price / 100).toFixed(2));
  746. if(showIs){
  747. var gNum = $("#giveNum").html();
  748. var rNum = parseInt(gNum) - 1;
  749. $("#giveNum").html(rNum);
  750. }
  751. } else {
  752. mui.alert(dt.message);
  753. }
  754. },
  755. error: function(xhr, type, errorThrown) {
  756. errorfn(xhr);
  757. }
  758. });
  759. }
  760. </script>
  761. </body>
  762. </html>