clearing.html 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  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);
  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. console.log(usePayMoney)
  466. if(accDiv(payTotal, 100)>=enough){
  467. if(yhq_val > usePayMoney) {
  468. yhq_check.removeAttr("checked");
  469. yhq_val = 0;
  470. mui.alert(' ', '当前优惠券不可用', function() {});
  471. }
  472. $("#yhq_name").html(yhq_check.prev().html());
  473. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  474. $("#accSub,#accSub>div:first-child").show();
  475. $("#user-pay-money-span").html((accDiv(payTotal, 100) -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 - yhq_val - ipt_balance).toFixed(2));
  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. exchangeColorId='';
  520. }
  521. }
  522. $("#pro-count").text(pro_all_count);//总件数
  523. } else {
  524. mui.alert(dt.message);
  525. }
  526. },
  527. error: function(xhr, type, errorThrown) {
  528. errorfn(xhr);
  529. }
  530. });
  531. // 获取微信共享地址
  532. $(document).on('tap', '.btn-add-address,#user-address-div', function() {
  533. editAddrV1(
  534. function(res) {
  535. // 用户成功拉出地址
  536. var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  537. wechatAddr.status = true;
  538. wechatAddr.detailInfo = address;
  539. wechatAddr.postalCode = res.postalCode;
  540. wechatAddr.userName = res.userName;
  541. wechatAddr.userTel = res.telNumber;
  542. wechatAddr.nationalCode = res.nationalCode;
  543. $(".btn-add-address").hide();
  544. $("#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();
  545. },
  546. function() {
  547. if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  548. wechatAddr.status = true;
  549. } else {
  550. wechatAddr.status = false;
  551. // 用户取消拉出地址
  552. mui.alert("您没有选择收货地址!");
  553. }
  554. }
  555. );
  556. });
  557. // mui('body').on('tap', '#open-wechat-addres-a,#user-address-div', function() {
  558. // editAddrV1(
  559. // function(res) {
  560. // // 用户成功拉出地址
  561. // var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  562. // wechatAddr.status = true;
  563. // wechatAddr.detailInfo = address;
  564. // wechatAddr.postalCode = res.postalCode;
  565. // wechatAddr.userName = res.userName;
  566. // wechatAddr.userTel = res.telNumber;
  567. // wechatAddr.nationalCode = res.nationalCode;
  568. //
  569. // $("#user-address-div").empty().append(
  570. // "收货人:" + wechatAddr.userName + "<span class='ml-5'>" + wechatAddr.userTel + "</span>" +
  571. // "<a>" +
  572. // "<p class='shipping_address wt-space'>" + wechatAddr.detailInfo + "<span class='mui-icon mui-icon-arrowright icon-r-c'></span></p>" +
  573. // "</a>");
  574. // $("#user-address-div").show();
  575. // $("#open-wechat-addres-a").hide();
  576. // },
  577. // function() {
  578. // if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  579. // wechatAddr.status = true;
  580. // } else {
  581. // wechatAddr.status = false;
  582. // // 用户取消拉出地址
  583. // mui.alert("您没有选择收货地址!");
  584. // }
  585. // }
  586. // );
  587. //
  588. // });
  589. // 积分数量改变时
  590. mui('body').on('change', '#input-user-integral', function() {
  591. var inputUserIntegral = $("#input-user-integral").val();
  592. $.trim(inputUserIntegral);
  593. var r = /^[1-9]+\d*$/;
  594. if(!r.test(inputUserIntegral)) {
  595. $("#input-user-integral").val(userInputIntegral);
  596. return false;
  597. }
  598. inputUserIntegral = parseInt(inputUserIntegral);
  599. if(inputUserIntegral > userIntegral) {
  600. $("#input-user-integral").val(userInputIntegral);
  601. return false;
  602. }
  603. if((inputUserIntegral * meonyProportion) > payTotal) {
  604. $("#input-user-integral").val(userInputIntegral);
  605. return false;
  606. }
  607. // 置换数据
  608. userInputIntegral = inputUserIntegral;
  609. var temp = (userInputIntegral * meonyProportion / 100).toFixed(2);
  610. $("#integral-money-span").html(temp);
  611. temp = ((payTotal - (userInputIntegral * meonyProportion)) / 100).toFixed(2);
  612. $("#user-pay-money-span").html(temp);
  613. });
  614. // 去支付
  615. mui('body').on('tap', '.btn-weixin-pay', function() {
  616. //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)))){
  617. // if($(".dhq-last-add").is(":visible")){
  618. // console.log(exchangeColorId)
  619. // }
  620. // }
  621. var yhq_id = $("input[name=radio1]:checked").attr('id');
  622. if(yhq_id == undefined) {
  623. yhq_id = "";
  624. }
  625. var remark = $("#textarea").val();
  626. var pattern = new RegExp("[ `~!@#$^&*()=|{}':;'\\[\\]<>/?~!@#¥……&*()——|{}【】‘;:”“'、?]")
  627. if(remark != "") {
  628. $.trim(remark);
  629. if(pattern.test(remark)) {
  630. mui.alert("请不要输入中文、字母、数字以外的特殊字符!");
  631. return;
  632. }
  633. if(!(remark.length >= 0 && remark.length <= 100)) {
  634. mui.alert("备注字数长度在0-100之间!");
  635. return;
  636. }
  637. }
  638. if(wechatAddr.status) {
  639. if(isPay) {
  640. isPay = false; // 锁定请求按钮
  641. layer.open({
  642. type: 2,
  643. shadeClose: false,
  644. content: "正在请求加载订单信息..."
  645. }); // 调用加载弹出层
  646. /* 组装数据 */
  647. var dataArgs = {
  648. "orderAddressInfo": wechatAddr.detailInfo,
  649. "orderAddressPostNum": wechatAddr.postalCode,
  650. "orderAddressMoblie": wechatAddr.userTel,
  651. "orderAddressName": wechatAddr.userName,
  652. "cartIdStr": cartIdStr,
  653. "orderIntegralNum": userInputIntegral,
  654. "orderUserRemark": remark,
  655. "couponId": yhq_id,
  656. "balancePayAmount": accMul(ipt_balance, 100)
  657. };
  658. // 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)))){
  659. if($(".dhq-last-add").is(":visible")){
  660. exchangeColorId=$(".dhq-dalog input[type=radio]:checked").val();
  661. console.log(exchangeColorId)
  662. dataArgs["exchangeColorId"] = exchangeColorId;
  663. }
  664. // }
  665. $.ajax(base_path+'/order/pay', { // 提交订单,准备支付
  666. data: dataArgs,
  667. dataType: 'json',
  668. type: 'POST',
  669. timeout: 15000,
  670. xhrFields: {
  671. withCredentials: true
  672. },
  673. crossDomain: true,
  674. success: function(dt) {
  675. if (dt.isRedirect) {
  676. location.href = dt.redirectURL;
  677. } else {
  678. layer.closeAll();
  679. //mui.alert(dt.resultCode=="500");
  680. if(dt.resultCode == "500") {
  681. mui.alert(dt.message);
  682. isPay = true;
  683. return;
  684. };
  685. if(dt.data.info == "isOK") {
  686. location.href = 'pay_win.html?orderId=' + dt.data.orderId + "&dates=" + new Date().getTime();
  687. return;
  688. };
  689. if(dt.status) {
  690. var str = dt.data.info;
  691. var obj = JSON.parse("{" + str + "}");
  692. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  693. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  694. var orderIds = {
  695. "orderId": dt.data.orderId
  696. };
  697. layer.open({
  698. type: 2,
  699. shadeClose: false,
  700. content: "正在请求加载订单信息..."
  701. }); // 调用加载弹出层
  702. $.ajax(base_path + '/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  703. data: {
  704. "orderId": dt.data.orderId
  705. },
  706. dataType: 'json',
  707. xhrFields: {
  708. withCredentials: true
  709. },
  710. crossDomain: true,
  711. type: 'get',
  712. timeout: 15000,
  713. success: function(dataobj) {
  714. if(dataobj.isRedirect) {
  715. location.href = dataobj.redirectURL;
  716. } else {
  717. if(dataobj.status == true) { // 支付成功
  718. location.href = "pay_win.html?orderId=" + orderIds.orderId + "&dates=" + new Date().getTime();
  719. } else {
  720. setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000); // 前往订单详情
  721. }
  722. }
  723. },
  724. error: function(xhr, type, errorThrown) {
  725. console.log(xhr);
  726. }
  727. });
  728. } else {
  729. isPay = true;
  730. // mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!");
  731. location.href = "order_details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  732. }
  733. });
  734. } else {
  735. isPay = true;
  736. mui.alert(dt.message);
  737. location.href = "order_details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  738. }
  739. }
  740. },
  741. error: function(xhr, type, errorThrown) {
  742. isPay = true;
  743. layer.closeAll();
  744. mui.alert("您的网络异常,请刷新重试!");
  745. return;
  746. }
  747. });
  748. } else {
  749. mui.alert("正在请求支付中~~请稍后!");
  750. return;
  751. }
  752. } else {
  753. mui.alert("请选择收货地址!");
  754. return;
  755. }
  756. });
  757. //选择优惠券
  758. mui('body').on('tap', '.mui-popover-action li>a', function() {
  759. var a = this,parent;
  760. //根据点击按钮,反推当前是哪个actionsheet
  761. for(parent = a.parentNode; parent != document.body; parent = parent.parentNode) {
  762. if(parent.classList.contains('mui-popover-action')) {
  763. break;
  764. }
  765. }
  766. //关闭actionsheet
  767. mui('#' + parent.id).popover('toggle');
  768. var yhq_check=$("input[name=radio1]:checked");
  769. yhq_val = yhq_check.val();
  770. yhq_type = yhq_check.attr("yhq_type");
  771. var yhq_id=yhq_check.attr("couponid"),enough=yhq_check.attr("enough");
  772. if(yhq_val == undefined) {
  773. yhq_val = 0
  774. } else {
  775. if(yhq_type == 1) {
  776. if(accDiv(payTotal, 100)>=enough){
  777. if(yhq_val > usePayMoney) {
  778. yhq_check.removeAttr("checked");
  779. yhq_val = 0;
  780. mui.alert(' ', '当前优惠券不可用', function() {});
  781. }
  782. $("#yhq_name").html(yhq_check.prev().html());
  783. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  784. $("#accSub,#accSub>div:first-child").show();
  785. $("#user-pay-money-span").html((accDiv(payTotal, 100) -yhq_val- ipt_balance).toFixed(2));
  786. $(".dhq-last-add").hide();
  787. exchangeColorId='';
  788. }else{
  789. yhq_check.removeAttr("checked");
  790. yhq_val = 0;
  791. mui.alert(' ', '当前商品金额不满足使用条件', function() {});
  792. }
  793. }else if(yhq_type == 3){
  794. if(yhq_id==10000){
  795. if(yhq_val > (usePayMoney - ipt_balance)) {
  796. $("input[couponid=10000]:checked").removeAttr("checked");
  797. yhq_val = 0;
  798. mui.alert(' ', '当前优惠券不可用', function() {});
  799. }
  800. $("#yhq_name").html($("input[couponid=10000]:checked").prev().html());
  801. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  802. $("#accSub,#accSub>div:first-child").show();
  803. $(".dhq-last-add").show();
  804. console.log(yhq_val)
  805. if($(".dhq-last-add").length>0){
  806. yhq_val = 0;
  807. }
  808. }else if(yhq_id==10001){
  809. $("#yhq_name").html(yhq_check.prev().html());
  810. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  811. $("#accSub,#accSub>div:first-child").show();
  812. $(".dhq-last-add").hide();
  813. exchangeColorId='';
  814. }
  815. //$("#user-pay-money-span").html((usePayMoney -yhq_val- ipt_balance).toFixed(2));
  816. } else {
  817. yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_check.val(), usePayMoney) * 100) / 100);
  818. $("#yhq_name").html(yhq_check.prev().html());
  819. $("#yhq_price").html("- ¥"+yhq_val);
  820. $("#accSub,#accSub>div:first-child").show();
  821. //$("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  822. $(".dhq-last-add").hide();
  823. exchangeColorId='';
  824. }
  825. if(user38Interests==1){
  826. if((usePayMoney - yhq_val - ipt_balance)>=2000 && (usePayMoney - yhq_val - ipt_balance)<3000){
  827. $("#user2000").show();
  828. $("#user3000").hide();
  829. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  830. }else if((usePayMoney - yhq_val - ipt_balance)>=3000){
  831. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance-100).toFixed(2));
  832. $("#user2000,#user3000").show();
  833. }else{
  834. $("#user2000,#user3000").hide();
  835. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  836. }
  837. }else{
  838. $("#user2000,#user3000").hide();
  839. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  840. }
  841. }
  842. });
  843. document.querySelector('.loading-bg').style.display = 'none';
  844. });
  845. // 校验订单状态
  846. function checkOrderStatus(orderId) {
  847. $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  848. data: {
  849. "orderId": orderId
  850. },
  851. dataType: 'json',
  852. xhrFields: {
  853. withCredentials: true
  854. },
  855. crossDomain: true,
  856. type: 'get',
  857. timeout: 15000,
  858. success: function(dataobj) {
  859. if(dataobj.isRedirect) {
  860. location.href = dataobj.redirectURL;
  861. } else {
  862. if(dataobj.status == true) { // 支付成功
  863. location.href = "pay-win.html?orderId=" + dataobj.data + "&dates=" + new Date().getTime();
  864. } else {
  865. location.href = 'order_details.html?orderId=' + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  866. }
  867. }
  868. },
  869. error: function(xhr, type, errorThrown) {
  870. console.log(xhr);
  871. }
  872. });
  873. };
  874. </script>
  875. </body>
  876. </html>