clearing.html 46 KB

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