clearing_备份.html 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904
  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. var isSpell=2; //不能拼单
  191. var orderId=getParam('orderId');
  192. var isSpellstr='';
  193. var productId='';
  194. var colorId='';
  195. mui.ready(function() {
  196. if(isSpell==1){
  197. isSpellstr='&isSpell=1';
  198. }
  199. var name,value;
  200. var str=location.href; //取得整个地址栏
  201. var num=str.indexOf("?")
  202. str=str.substr(num+1); //取得所有参数
  203. var $productListUl = $("#products-list-ul");
  204. $.ajax(base_path+'/order/payBefore?'+str, {
  205. dataType: 'json',
  206. type: 'POST',
  207. timeout: 15000,
  208. xhrFields: {
  209. withCredentials: true
  210. },
  211. crossDomain: true,
  212. success: function(dt) {
  213. if(dt.status == true) {
  214. // 购物项遍历
  215. //console.log(dt)
  216. var liNote = "";
  217. var cNum = 0;
  218. user38Interests=dt.data.user38Interests;
  219. if(dt.data.balance == 0) {
  220. $(".pay_ipt_box").hide();
  221. } else {
  222. used_balance = accDiv(dt.data.balance, 100);
  223. $('#used_balance').html("¥ " + accDiv(dt.data.balance, 100));
  224. }
  225. var yhq_str = "";
  226. if(dt.data.couponItems.length == 0 || !dt.data.disable) {
  227. $(".forward").hide();$("#vipSub").hide();
  228. } else {
  229. if(isSpell!=1){
  230. //如果购买商品只有饮水机滤芯,则不能使用优惠券
  231. var c=0,flag=false;
  232. var btnArray = ['否', '是'];
  233. mui(dt.data.couponItems).each(function(index) {
  234. if(this.couponId==10000){
  235. c++;
  236. }
  237. });
  238. mui(dt.data.cartItems).each(function(index) {
  239. if(this.cartColorId==7){
  240. t1+=this.cartNum;
  241. }else if(this.cartColorId==8){
  242. t2+=this.cartNum;
  243. }else{
  244. all_t++;
  245. }
  246. });
  247. if(c>0){
  248. if((t1==0 && t2==0) || all_t==0){
  249. $(".dhq-dalog").show();
  250. }else{
  251. flag=true;
  252. }
  253. $(document).on('tap', '.enter', function() {
  254. if($(".dhq-dalog input[type=radio]:checked").length>0){
  255. flag=true;
  256. exchangeColorId=$(".dhq-dalog input[type=radio]:checked").val();
  257. $.ajax(base_path + '/cart/get_exchange?dates=' + new Date().getTime(), {
  258. data: {
  259. "couponId": 10000
  260. },
  261. dataType: 'json',
  262. xhrFields: {
  263. withCredentials: true
  264. },
  265. crossDomain: true,
  266. type: 'post',
  267. async:false,
  268. timeout: 15000,
  269. success: function(dts) {
  270. console.log(dts);
  271. //if(dts.status==true){
  272. if (dt.isRedirect) {
  273. location.href = dt.redirectURL;
  274. } else {
  275. console.log("t1="+t1+",t2="+t2+",all_t="+all_t);
  276. mui(dts.data).each(function(index) {
  277. if(exchangeColorId==this.colorId){
  278. 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))){
  279. $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>');
  280. }else{
  281. yhq_val = $("#forward input[yhq_type=3]").val();
  282. if(yhq_val == undefined) {
  283. yhq_val = 0
  284. }else{
  285. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  286. }
  287. }
  288. }
  289. });
  290. }
  291. //}
  292. },
  293. error: function(xhr, type, errorThrown) {
  294. console.log(xhr);
  295. }
  296. });
  297. $("#forward input[couponid=10000]").prop('checked',true);
  298. var yhq_check=$("input[name=radio1]:checked");
  299. yhq_val = yhq_check.val();
  300. yhq_type = yhq_check.attr("yhq_type");
  301. var yhq_id = yhq_check.attr("couponid");
  302. if(yhq_val == undefined) {
  303. yhq_val = 0
  304. } else {
  305. if(yhq_type == 3){
  306. if(yhq_id==10000){
  307. if(yhq_val > (usePayMoney - ipt_balance)) {
  308. yhq_check.removeAttr("checked");
  309. yhq_val = 0;
  310. mui.alert(' ', '当前优惠券不可用', function() {});
  311. }
  312. $("#yhq_name").html(yhq_check.prev().html());
  313. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  314. $("#accSub,#accSub>div:first-child").show();
  315. if($(".dhq-last-add").length>0){
  316. yhq_val = 0;
  317. }
  318. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  319. }
  320. }
  321. }
  322. $(".dhq-dalog").hide();
  323. }else{
  324. console.log("请选择要兑换的滤芯");
  325. }
  326. });
  327. //下次兑换
  328. $(document).on('tap', '.nexts', function() {
  329. $("#forward input[couponid=10000]").removeAttr('checked').prop("disabled","disabled");
  330. $(".dhq-dalog").hide();
  331. flag=false;
  332. if(user38Interests==1){
  333. console.log(usePayMoney>=2000 && usePayMoney<3000)
  334. if(usePayMoney>=2000 && usePayMoney<3000){
  335. $("#user2000").show();
  336. $("#user-pay-money-span").html(usePayMoney);
  337. }else if(usePayMoney>=3000){
  338. $("#user-pay-money-span").html((usePayMoney-100));
  339. $("#user2000,#user3000").show();
  340. }else{
  341. $("#user2000,#user3000").hide();
  342. $("#user-pay-money-span").html(usePayMoney);
  343. }
  344. }else{
  345. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  346. }
  347. console.log("899")
  348. });
  349. }
  350. if (dt.data.disable) {
  351. mui(dt.data.couponItems).each(function(index) {
  352. var checked='';
  353. console.log(flag)
  354. if((this.couponId==10000 && flag) || this.couponId==10002){
  355. checked='checked';
  356. }
  357. 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>';
  358. });
  359. $(".my-popover").html(yhq_str + '<div class="mui-input-row mui-radio"><label>不使用优惠券</label><input name="radio1" value="1" type="radio"></div>');
  360. $("#yhq_count").html(dt.data.couponItems.length);
  361. if(t1==0 && t2==0){
  362. $("#forward input[couponid=10001]").removeAttr('checked').prop("disabled","disabled");
  363. }
  364. }
  365. }else{
  366. $(".forward").hide();$("#vipSub").hide();
  367. productId=dt.data.cartItems[0].cartProductId;
  368. colorId=dt.data.cartItems[0].cartColorId;
  369. }
  370. }
  371. for(let i = 0; i < dt.data.cartItems.length; i++) {
  372. pro_all_count+=dt.data.cartItems[i].cartNum;
  373. // 购物车小计,分--元
  374. let total = dt.data.cartItems[i].cartNum * dt.data.cartItems[i].productDiscount / 100;
  375. let pro_color = switchcolor(dt.data.cartItems[i].cartColorId);
  376. let colorImg = switchColorImg(dt.data.cartItems[i].cartColorId);
  377. let cartProductId = dt.data.cartItems[i].cartProductId;
  378. let colorId=dt.data.cartItems[i].cartColorId;
  379. let productDiscount = dt.data.cartItems[i].productDiscount;
  380. if(isSpell==1){
  381. total = dt.data.cartItems[i].cartNum * dt.data.cartItems[i].colorSpellAmount / 100;
  382. if(this.productIsSpell==2){
  383. productDiscount=dt.data.cartItems[i].colorSpellAmount;
  384. }else{
  385. productDiscount=dt.data.cartItems[i].productDiscount;
  386. }
  387. }
  388. total = total.toFixed(2); // 保留两位小数
  389. let num = dt.data.cartItems[i].cartNum;
  390. if (dt.data.cartItems[i].productDiscount / 100 == 3280) {
  391. liNote = liNote +
  392. "<li class='mui-table-view-cell mui-media'>" +
  393. "<a>" +
  394. "<span class='mui-media-object mui-pull-left wh-100'> <img src='" + dt.data.cartItems[i].colorImg + "'></span>" +
  395. "<div class='mui-media-body' style='padding: 3% 0 3% 0;'>" +
  396. "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "</div>" +
  397. "<div><small class='mui-h6'>" + dt.data.cartItems[i].productColor + " x "+dt.data.cartItems[i].cartNum+"</small></div>"+
  398. "</div>" +
  399. "<div class='price_sp cl-gwc' id='product-" + cartProductId + "' price='" + productDiscount + "'>¥" + total + "</div>"+
  400. "</a>" +
  401. "</li>";
  402. cNum = cNum + num ;
  403. showIs = true;
  404. } else {
  405. liNote = liNote +
  406. "<li class='mui-table-view-cell mui-media'>" +
  407. "<a>" +
  408. "<span class='mui-media-object mui-pull-left wh-100'> <img src='" + dt.data.cartItems[i].colorImg + "'></span>" +
  409. "<div class='mui-media-body' style='padding: 3% 0 3% 0;'>" +
  410. "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "</div>" +
  411. "<div><small class='mui-h6'>" + dt.data.cartItems[i].productColor + " x "+dt.data.cartItems[i].cartNum+"</small></div>"+
  412. "</div>" +
  413. "<div class='price_sp cl-gwc' id='product-" + cartProductId + "' price='" + productDiscount + "'>¥" + total + "</div>"+
  414. "</a>" +
  415. "</li>";
  416. }
  417. if(dt.data.cartItems[i].cartColorId==5 && dt.data.cartItems[i].cartProductId==38){
  418. accVipSub+=(100* dt.data.cartItems[i].cartNum);
  419. }
  420. }
  421. if (showIs){
  422. liNote = liNote +
  423. "<li class='mui-table-view-cell mui-media'>" +
  424. "<a>" +
  425. "<span class='mui-media-object mui-pull-left wh-100'> <img src='//s.iamberry.com/watero/wechat/images/2C83538AC3039E693358_20161202182946_8118.jpg'></span>" +
  426. "<div class='mui-media-body'>" +
  427. "<div class='wt-space gwc_tit'>" +
  428. '赠送' + "<span id='giveNum'>" + cNum + '</span>' + '套三年滤芯' +
  429. "<span class='price_sp cl-gwc mui-pull-right' id='product-39' price='39'>¥" + 0 + "</span></div>" +
  430. "<small class='gwc_pp'>颜色:" + '无' + "</small>" +
  431. "</div>" +
  432. "</a>" +
  433. "</li>"
  434. }
  435. $productListUl.empty();
  436. $productListUl.append(liNote);
  437. dt.data.userIntegral = dt.data.userIntegral - 1;
  438. // 保存数据
  439. meonyProportion = dt.data.meonyProportion; // 兑换比例
  440. payTotal = dt.data.payTotal; // 支付金额,单位分
  441. userIntegral = dt.data.userIntegral; // 用户可用积分
  442. cartIdStr = dt.data.cartId; // 购物车ID
  443. // 替换数据
  444. usePayMoney = accDiv(dt.data.payTotal, 100);
  445. $("#total").val(usePayMoney.toFixed(2) + " 元");
  446. $("#user-integral-span").html(dt.data.userIntegral);
  447. if(dt.data.userIsVip==2 && isSpell!=1){
  448. $("#vip_price").text("- ¥"+(accVipSub).toFixed(2));
  449. $("#vipSub").show();
  450. usePayMoney-=accVipSub;
  451. }
  452. if(user38Interests==1){
  453. if(usePayMoney>=2000 && usePayMoney<3000){
  454. $("#user2000").show();
  455. $("#user3000").hide();
  456. $("#user-pay-money-span").html(usePayMoney);
  457. }else if(usePayMoney>=3000){
  458. $("#user-pay-money-span").html((usePayMoney-100));
  459. $("#user2000,#user3000").show();
  460. }else{
  461. $("#user-pay-money-span").html(usePayMoney);
  462. $("#user2000,#user3000").hide();
  463. }
  464. }else{
  465. $("#user-pay-money-span").html(usePayMoney);
  466. }
  467. //默认自己拉出地址
  468. if(dt.data.addressInfo != undefined && dt.data.addressInfo != null) {
  469. $(".btn-add-address").hide();
  470. $("#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();
  471. //给微信参数赋值
  472. wechatAddr.status = true;
  473. wechatAddr.detailInfo = dt.data.addressInfo.salesAddressInfo;
  474. wechatAddr.userName = dt.data.addressInfo.salesAddressName;
  475. wechatAddr.userTel = dt.data.addressInfo.salesAddressTel;
  476. wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum;
  477. }
  478. var yhq_check=$("input[name=radio1]:checked");
  479. yhq_val = yhq_check.val();
  480. yhq_type = yhq_check.attr("yhq_type");
  481. enough=yhq_check.attr("enough");
  482. if(yhq_val == undefined) {
  483. yhq_val = 0
  484. } else {
  485. if(yhq_type == 1) {
  486. if(accDiv(payTotal, 100)>=enough){
  487. if(yhq_val > usePayMoney) {
  488. yhq_check.removeAttr("checked");
  489. yhq_val = 0;
  490. mui.alert(' ', '当前优惠券不可用', function() {});
  491. }
  492. $("#yhq_name").html(yhq_check.prev().html());
  493. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  494. $("#accSub,#accSub>div:first-child").show();
  495. console.log(usePayMoney)
  496. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  497. $(".dhq-last-add").hide();
  498. exchangeColorId='';
  499. }else{
  500. yhq_check.removeAttr("checked");
  501. yhq_val = 0;
  502. mui.alert(' ', '当前商品金额不满足使用条件', function() {});
  503. }
  504. }else if(yhq_type == 3){
  505. if(yhq_val > (usePayMoney - ipt_balance)) {
  506. yhq_check.removeAttr("checked");
  507. yhq_val = 0;
  508. mui.alert(' ', '当前优惠券不可用', function() {});
  509. }
  510. $("#yhq_name").html(yhq_check.prev().html());
  511. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  512. $("#accSub,#accSub>div:first-child").show();
  513. console.log(yhq_val)
  514. if($(".dhq-last-add").length>0){
  515. yhq_val = 0;
  516. }
  517. console.log("998")
  518. if(user38Interests==1){
  519. if((usePayMoney - yhq_val - ipt_balance)>=2000 && (usePayMoney - yhq_val - ipt_balance)<3000){
  520. $("#user2000").show();
  521. $("#user3000").hide();
  522. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  523. }else if((usePayMoney - yhq_val - ipt_balance)>=3000){
  524. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance-100).toFixed(2));
  525. $("#user2000,#user3000").show();
  526. }else{
  527. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  528. $("#user2000,#user3000").hide();
  529. }
  530. }else{
  531. $("#user2000,#user3000").hide();
  532. $("#user-pay-money-span").html(usePayMoney);
  533. }
  534. }else {
  535. yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_check.val(), usePayMoney) * 100) / 100);
  536. $("#yhq_name").html(yhq_check.prev().html());
  537. $("#yhq_price").html("- ¥"+yhq_val);
  538. $("#accSub,#accSub>div:first-child").show();
  539. $(".dhq-last-add").hide();
  540. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  541. exchangeColorId='';
  542. }
  543. }
  544. $("#pro-count").text(pro_all_count);//总件数
  545. } else {
  546. mui.alert(dt.message);
  547. }
  548. },
  549. error: function(xhr, type, errorThrown) {
  550. console.log(xhr);
  551. }
  552. });
  553. // 获取微信共享地址
  554. $(document).on('tap', '.btn-add-address,#user-address-div', function() {
  555. editAddrV1(
  556. function(res) {
  557. // 用户成功拉出地址
  558. var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  559. wechatAddr.status = true;
  560. wechatAddr.detailInfo = address;
  561. wechatAddr.postalCode = res.postalCode;
  562. wechatAddr.userName = res.userName;
  563. wechatAddr.userTel = res.telNumber;
  564. wechatAddr.nationalCode = res.nationalCode;
  565. $(".btn-add-address").hide();
  566. $("#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();
  567. },
  568. function() {
  569. if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  570. wechatAddr.status = true;
  571. } else {
  572. wechatAddr.status = false;
  573. // 用户取消拉出地址
  574. mui.alert("您没有选择收货地址!");
  575. }
  576. }
  577. );
  578. });
  579. // 积分数量改变时
  580. mui('body').on('change', '#input-user-integral', function() {
  581. var inputUserIntegral = $("#input-user-integral").val();
  582. $.trim(inputUserIntegral);
  583. var r = /^[1-9]+\d*$/;
  584. if(!r.test(inputUserIntegral)) {
  585. $("#input-user-integral").val(userInputIntegral);
  586. return false;
  587. }
  588. inputUserIntegral = parseInt(inputUserIntegral);
  589. if(inputUserIntegral > userIntegral) {
  590. $("#input-user-integral").val(userInputIntegral);
  591. return false;
  592. }
  593. if((inputUserIntegral * meonyProportion) > payTotal) {
  594. $("#input-user-integral").val(userInputIntegral);
  595. return false;
  596. }
  597. // 置换数据
  598. userInputIntegral = inputUserIntegral;
  599. var temp = (userInputIntegral * meonyProportion / 100).toFixed(2);
  600. $("#integral-money-span").html(temp);
  601. temp = ((payTotal - (userInputIntegral * meonyProportion)) / 100).toFixed(2);
  602. $("#user-pay-money-span").html(temp);
  603. });
  604. //去支付
  605. mui('body').on('tap', '.btn-weixin-pay', function() {
  606. //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)))){
  607. // if($(".dhq-last-add").is(":visible")){
  608. // console.log(exchangeColorId)
  609. // }
  610. // }
  611. var yhq_id = $("input[name=radio1]:checked").attr('id');
  612. if(yhq_id == undefined) {
  613. yhq_id = "";
  614. }
  615. var remark = $("#textarea").val();
  616. var pattern = new RegExp("[ `~!@#$^&*()=|{}':;'\\[\\]<>/?~!@#¥……&*()——|{}【】‘;:”“'、?]")
  617. if(remark != "") {
  618. $.trim(remark);
  619. if(pattern.test(remark)) {
  620. mui.alert("请不要输入中文、字母、数字以外的特殊字符!");
  621. return;
  622. }
  623. if(!(remark.length >= 0 && remark.length <= 100)) {
  624. mui.alert("备注字数长度在0-100之间!");
  625. return;
  626. }
  627. }
  628. if(wechatAddr.status) {
  629. if(isPay) {
  630. isPay = false; // 锁定请求按钮
  631. layer.open({
  632. type: 2,
  633. shadeClose: false,
  634. content: "正在请求加载订单信息..."
  635. }); // 调用加载弹出层
  636. /* 组装数据 */
  637. var dataArgs = {
  638. "orderAddressInfo": wechatAddr.detailInfo,
  639. "orderAddressPostNum": wechatAddr.postalCode,
  640. "orderAddressMoblie": wechatAddr.userTel,
  641. "orderAddressName": wechatAddr.userName,
  642. "cartIdStr": cartIdStr,
  643. "orderIntegralNum": userInputIntegral,
  644. "orderUserRemark": remark,
  645. "couponId": yhq_id,
  646. "balancePayAmount": accMul(ipt_balance, 100)
  647. };
  648. // 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)))){
  649. if($(".dhq-last-add").is(":visible")){
  650. exchangeColorId=$(".dhq-dalog input[type=radio]:checked").val();
  651. dataArgs["exchangeColorId"] = exchangeColorId;
  652. }
  653. if(isSpell==1){
  654. dataArgs['isSpell']=isSpell;
  655. }
  656. if(orderId!='' && orderId!=null){
  657. dataArgs['spellOrderId']=orderId;
  658. }
  659. // }
  660. $.ajax(base_path+'/order/pay', { // 提交订单,准备支付
  661. data: dataArgs,
  662. dataType: 'json',
  663. type: 'POST',
  664. timeout: 15000,
  665. xhrFields: {
  666. withCredentials: true
  667. },
  668. crossDomain: true,
  669. success: function(dt) {
  670. if (dt.isRedirect) {
  671. location.href = dt.redirectURL;
  672. } else {
  673. layer.closeAll();
  674. //mui.alert(dt.resultCode=="500");
  675. if(dt.resultCode == "500") {
  676. mui.alert(dt.message);
  677. isPay = true;
  678. return;
  679. };
  680. if(dt.data.info == "isOK") {
  681. location.href = 'pay_win.html?orderId=' + dt.data.orderId + isSpellstr;
  682. return;
  683. };
  684. if(dt.status) {
  685. var str = dt.data.info;
  686. var obj = JSON.parse("{" + str + "}");
  687. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  688. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  689. var orderIds = {
  690. "orderId": dt.data.orderId
  691. };
  692. layer.open({
  693. type: 2,
  694. shadeClose: false,
  695. content: "正在请求加载订单信息..."
  696. }); // 调用加载弹出层
  697. $.ajax(base_path + '/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  698. data: {
  699. "orderId": dt.data.orderId
  700. },
  701. dataType: 'json',
  702. xhrFields: {
  703. withCredentials: true
  704. },
  705. crossDomain: true,
  706. type: 'get',
  707. timeout: 15000,
  708. success: function(dataobj) {
  709. if(dataobj.isRedirect) {
  710. location.href = dataobj.redirectURL;
  711. } else {
  712. if(dataobj.status == true) { // 支付成功
  713. if(isSpell==1 && orderId==null){
  714. location.href='pay_add_group.html?productId='+productId+'&colorId='+colorId+'&orderid='+orderIds.orderId+'&isSpell=1'
  715. }else{
  716. location.href = "pay_win.html?orderId=" + orderIds.orderId
  717. }
  718. } else {
  719. setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000); // 前往订单详情
  720. }
  721. }
  722. },
  723. error: function(xhr, type, errorThrown) {
  724. console.log(xhr);
  725. }
  726. });
  727. } else {
  728. isPay = true;
  729. // mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!");
  730. location.href = "order_details.html?orderId=" + dt.data.orderId + isSpellstr; // 前往订单详情
  731. }
  732. });
  733. } else {
  734. isPay = true;
  735. mui.alert(dt.message);
  736. location.href = "order_details.html?orderId=" + dt.data.orderId + isSpellstr; // 前往订单详情
  737. }
  738. }
  739. },
  740. error: function(xhr, type, errorThrown) {
  741. isPay = true;
  742. layer.closeAll();
  743. mui.alert("您的网络异常,请刷新重试!");
  744. return;
  745. }
  746. });
  747. } else {
  748. mui.alert("正在请求支付中~~请稍后!");
  749. return;
  750. }
  751. } else {
  752. mui.alert("请选择收货地址!");
  753. return;
  754. }
  755. });
  756. //选择优惠券
  757. mui('body').on('tap', '.mui-popover-action li>a', function() {
  758. var a = this,parent;
  759. //根据点击按钮,反推当前是哪个actionsheet
  760. for(parent = a.parentNode; parent != document.body; parent = parent.parentNode) {
  761. if(parent.classList.contains('mui-popover-action')) {
  762. break;
  763. }
  764. }
  765. //关闭actionsheet
  766. mui('#' + parent.id).popover('toggle');
  767. var yhq_check=$("input[name=radio1]:checked");
  768. yhq_val = yhq_check.val();
  769. yhq_type = yhq_check.attr("yhq_type");
  770. var yhq_id=yhq_check.attr("couponid"),enough=yhq_check.attr("enough");
  771. if(yhq_val == undefined) {
  772. yhq_val = 0
  773. } else {
  774. if(yhq_type == 1) {
  775. if(accDiv(payTotal, 100)>=enough){
  776. if(yhq_val > usePayMoney) {
  777. yhq_check.removeAttr("checked");
  778. yhq_val = 0;
  779. mui.alert(' ', '当前优惠券不可用', function() {});
  780. }
  781. $("#yhq_name").html(yhq_check.prev().html());
  782. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  783. $("#accSub,#accSub>div:first-child").show();
  784. $("#user-pay-money-span").html((accDiv(payTotal, 100) -yhq_val- ipt_balance).toFixed(2));
  785. $(".dhq-last-add").hide();
  786. exchangeColorId='';
  787. }else{
  788. yhq_check.removeAttr("checked");
  789. yhq_val = 0;
  790. mui.alert(' ', '当前商品金额不满足使用条件', function() {});
  791. }
  792. }else if(yhq_type == 3){
  793. if(yhq_id==10000){
  794. if(yhq_val > (usePayMoney - ipt_balance)) {
  795. $("input[couponid=10000]:checked").removeAttr("checked");
  796. yhq_val = 0;
  797. mui.alert(' ', '当前优惠券不可用', function() {});
  798. }
  799. $("#yhq_name").html($("input[couponid=10000]:checked").prev().html());
  800. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  801. $("#accSub,#accSub>div:first-child").show();
  802. $(".dhq-last-add").show();
  803. console.log(yhq_val)
  804. if($(".dhq-last-add").length>0){
  805. yhq_val = 0;
  806. }
  807. }else if(yhq_id==10001){
  808. $("#yhq_name").html(yhq_check.prev().html());
  809. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  810. $("#accSub,#accSub>div:first-child").show();
  811. $(".dhq-last-add").hide();
  812. exchangeColorId='';
  813. }
  814. //$("#user-pay-money-span").html((usePayMoney -yhq_val- ipt_balance).toFixed(2));
  815. } else {
  816. yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_check.val(), usePayMoney) * 100) / 100);
  817. $("#yhq_name").html(yhq_check.prev().html());
  818. $("#yhq_price").html("- ¥"+yhq_val);
  819. $("#accSub,#accSub>div:first-child").show();
  820. //$("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  821. $(".dhq-last-add").hide();
  822. exchangeColorId='';
  823. }
  824. if(user38Interests==1){
  825. if((usePayMoney - yhq_val - ipt_balance)>=2000 && (usePayMoney - yhq_val - ipt_balance)<3000){
  826. $("#user2000").show();
  827. $("#user3000").hide();
  828. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  829. }else if((usePayMoney - yhq_val - ipt_balance)>=3000){
  830. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance-100).toFixed(2));
  831. $("#user2000,#user3000").show();
  832. }else{
  833. $("#user2000,#user3000").hide();
  834. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  835. }
  836. }else{
  837. $("#user2000,#user3000").hide();
  838. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  839. }
  840. }
  841. });
  842. document.querySelector('.loading-bg').style.display = 'none';
  843. });
  844. // 校验订单状态
  845. function checkOrderStatus(orderId) {
  846. $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  847. data: {
  848. "orderId": orderId
  849. },
  850. dataType: 'json',
  851. xhrFields: {
  852. withCredentials: true
  853. },
  854. crossDomain: true,
  855. type: 'get',
  856. timeout: 15000,
  857. success: function(dataobj) {
  858. if(dataobj.isRedirect) {
  859. location.href = dataobj.redirectURL;
  860. } else {
  861. if(dataobj.status == true) { // 支付成功
  862. if(isSpell==1 && orderId==null){
  863. location.href='pay_add_group.html?productId='+productId+'&colorId='+colorId+'&orderid='+dataobj.data+'&isSpell=1'
  864. }else{
  865. location.href = "pay_win.html?orderId=" + dataobj.data
  866. }
  867. } else {
  868. location.href = 'order_details.html?orderId=' + orderId + isSpellstr; // 前往订单详情
  869. }
  870. }
  871. },
  872. error: function(xhr, type, errorThrown) {
  873. console.log(xhr);
  874. }
  875. });
  876. };
  877. </script>
  878. </body>
  879. </html>