clearing.html 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  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">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. console.log(yhq_val)
  274. if(yhq_val == undefined) {
  275. yhq_val = 0
  276. }else{
  277. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  278. }
  279. }
  280. }
  281. });
  282. }
  283. //}
  284. },
  285. error: function(xhr, type, errorThrown) {
  286. console.log(xhr);
  287. }
  288. });
  289. $("#forward input[couponid=10000]").prop('checked',true);
  290. yhq_val = $("input[name=radio1]:checked").val();
  291. yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
  292. var yhq_id = $("input[name=radio1]:checked").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. $("input[name=radio1]:checked").removeAttr("checked");
  300. yhq_val = 0;
  301. mui.alert(' ', '当前优惠券不可用', function() {});
  302. }
  303. $("#yhq_name").html($("input[name=radio1]:checked").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. if(this.couponId==10000 && flag){
  346. checked='checked';
  347. }
  348. 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 + '" '+checked+'/></div>';
  349. });
  350. $(".my-popover").html(yhq_str + '<div class="mui-input-row mui-radio"><label>不使用优惠券</label><input name="radio1" value="1" type="radio"></div>');
  351. $("#yhq_count").html(dt.data.couponItems.length);
  352. if(t1==0 && t2==0){
  353. $("#forward input[couponid=10001]").removeAttr('checked').prop("disabled","disabled");
  354. $("#yhq_count").html(dt.data.couponItems.length-1);
  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. yhq_val = $("input[name=radio1]:checked").val();
  458. yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
  459. if(yhq_val == undefined) {
  460. yhq_val = 0
  461. } else {
  462. if(yhq_type == 3){
  463. if(yhq_val > (usePayMoney - ipt_balance)) {
  464. $("input[name=radio1]:checked").removeAttr("checked");
  465. yhq_val = 0;
  466. mui.alert(' ', '当前优惠券不可用', function() {});
  467. }
  468. $("#yhq_name").html($("input[name=radio1]:checked").prev().html());
  469. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  470. $("#accSub,#accSub>div:first-child").show();
  471. console.log(yhq_val)
  472. if($(".dhq-last-add").length>0){
  473. yhq_val = 0;
  474. }
  475. console.log("998")
  476. if(user38Interests==1){
  477. if((usePayMoney - yhq_val - ipt_balance)>=2000 && (usePayMoney - yhq_val - ipt_balance)<3000){
  478. $("#user2000").show();
  479. $("#user3000").hide();
  480. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  481. }else if((usePayMoney - yhq_val - ipt_balance)>=3000){
  482. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance-100).toFixed(2));
  483. $("#user2000,#user3000").show();
  484. }else{
  485. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  486. $("#user2000,#user3000").hide();
  487. }
  488. }else{
  489. $("#user2000,#user3000").hide();
  490. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  491. }
  492. }
  493. }
  494. $("#pro-count").text(pro_all_count);//总件数
  495. } else {
  496. mui.alert(dt.message);
  497. }
  498. },
  499. error: function(xhr, type, errorThrown) {
  500. errorfn(xhr);
  501. }
  502. });
  503. // 获取微信共享地址
  504. $(document).on('tap', '.btn-add-address,#user-address-div', function() {
  505. editAddrV1(
  506. function(res) {
  507. // 用户成功拉出地址
  508. var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  509. wechatAddr.status = true;
  510. wechatAddr.detailInfo = address;
  511. wechatAddr.postalCode = res.postalCode;
  512. wechatAddr.userName = res.userName;
  513. wechatAddr.userTel = res.telNumber;
  514. wechatAddr.nationalCode = res.nationalCode;
  515. $(".btn-add-address").hide();
  516. $("#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();
  517. },
  518. function() {
  519. if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  520. wechatAddr.status = true;
  521. } else {
  522. wechatAddr.status = false;
  523. // 用户取消拉出地址
  524. mui.alert("您没有选择收货地址!");
  525. }
  526. }
  527. );
  528. });
  529. // mui('body').on('tap', '#open-wechat-addres-a,#user-address-div', function() {
  530. // editAddrV1(
  531. // function(res) {
  532. // // 用户成功拉出地址
  533. // var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  534. // wechatAddr.status = true;
  535. // wechatAddr.detailInfo = address;
  536. // wechatAddr.postalCode = res.postalCode;
  537. // wechatAddr.userName = res.userName;
  538. // wechatAddr.userTel = res.telNumber;
  539. // wechatAddr.nationalCode = res.nationalCode;
  540. //
  541. // $("#user-address-div").empty().append(
  542. // "收货人:" + wechatAddr.userName + "<span class='ml-5'>" + wechatAddr.userTel + "</span>" +
  543. // "<a>" +
  544. // "<p class='shipping_address wt-space'>" + wechatAddr.detailInfo + "<span class='mui-icon mui-icon-arrowright icon-r-c'></span></p>" +
  545. // "</a>");
  546. // $("#user-address-div").show();
  547. // $("#open-wechat-addres-a").hide();
  548. // },
  549. // function() {
  550. // if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  551. // wechatAddr.status = true;
  552. // } else {
  553. // wechatAddr.status = false;
  554. // // 用户取消拉出地址
  555. // mui.alert("您没有选择收货地址!");
  556. // }
  557. // }
  558. // );
  559. //
  560. // });
  561. // 积分数量改变时
  562. mui('body').on('change', '#input-user-integral', function() {
  563. var inputUserIntegral = $("#input-user-integral").val();
  564. $.trim(inputUserIntegral);
  565. var r = /^[1-9]+\d*$/;
  566. if(!r.test(inputUserIntegral)) {
  567. $("#input-user-integral").val(userInputIntegral);
  568. return false;
  569. }
  570. inputUserIntegral = parseInt(inputUserIntegral);
  571. if(inputUserIntegral > userIntegral) {
  572. $("#input-user-integral").val(userInputIntegral);
  573. return false;
  574. }
  575. if((inputUserIntegral * meonyProportion) > payTotal) {
  576. $("#input-user-integral").val(userInputIntegral);
  577. return false;
  578. }
  579. // 置换数据
  580. userInputIntegral = inputUserIntegral;
  581. var temp = (userInputIntegral * meonyProportion / 100).toFixed(2);
  582. $("#integral-money-span").html(temp);
  583. temp = ((payTotal - (userInputIntegral * meonyProportion)) / 100).toFixed(2);
  584. $("#user-pay-money-span").html(temp);
  585. });
  586. // 去支付
  587. mui('body').on('tap', '.btn-weixin-pay', function() {
  588. //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)))){
  589. // if($(".dhq-last-add").is(":visible")){
  590. // console.log(exchangeColorId)
  591. // }
  592. // }
  593. var yhq_id = $("input[name=radio1]:checked").attr('id');
  594. if(yhq_id == undefined) {
  595. yhq_id = "";
  596. }
  597. var remark = $("#textarea").val();
  598. var pattern = new RegExp("[ `~!@#$^&*()=|{}':;'\\[\\]<>/?~!@#¥……&*()——|{}【】‘;:”“'、?]")
  599. if(remark != "") {
  600. $.trim(remark);
  601. if(pattern.test(remark)) {
  602. mui.alert("请不要输入中文、字母、数字以外的特殊字符!");
  603. return;
  604. }
  605. if(!(remark.length >= 0 && remark.length <= 100)) {
  606. mui.alert("备注字数长度在0-100之间!");
  607. return;
  608. }
  609. }
  610. if(wechatAddr.status) {
  611. if(isPay) {
  612. isPay = false; // 锁定请求按钮
  613. layer.open({
  614. type: 2,
  615. shadeClose: false,
  616. content: "正在请求加载订单信息..."
  617. }); // 调用加载弹出层
  618. /* 组装数据 */
  619. var dataArgs = {
  620. "orderAddressInfo": wechatAddr.detailInfo,
  621. "orderAddressPostNum": wechatAddr.postalCode,
  622. "orderAddressMoblie": wechatAddr.userTel,
  623. "orderAddressName": wechatAddr.userName,
  624. "cartIdStr": cartIdStr,
  625. "orderIntegralNum": userInputIntegral,
  626. "orderUserRemark": remark,
  627. "couponId": yhq_id,
  628. "balancePayAmount": accMul(ipt_balance, 100)
  629. };
  630. // 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)))){
  631. if($(".dhq-last-add").is(":visible")){
  632. exchangeColorId=$(".dhq-dalog input[type=radio]:checked").val();
  633. console.log(exchangeColorId)
  634. dataArgs["exchangeColorId"] = exchangeColorId;
  635. }
  636. // }
  637. $.ajax(base_path+'/order/pay', { // 提交订单,准备支付
  638. data: dataArgs,
  639. dataType: 'json',
  640. type: 'POST',
  641. timeout: 15000,
  642. xhrFields: {
  643. withCredentials: true
  644. },
  645. crossDomain: true,
  646. success: function(dt) {
  647. if (dt.isRedirect) {
  648. location.href = dt.redirectURL;
  649. } else {
  650. layer.closeAll();
  651. //mui.alert(dt.resultCode=="500");
  652. if(dt.resultCode == "500") {
  653. mui.alert(dt.message);
  654. isPay = true;
  655. return;
  656. };
  657. if(dt.data.info == "isOK") {
  658. location.href = 'pay_win.html?orderId=' + dt.data.orderId + "&dates=" + new Date().getTime();
  659. return;
  660. };
  661. if(dt.status) {
  662. var str = dt.data.info;
  663. var obj = JSON.parse("{" + str + "}");
  664. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  665. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  666. var orderIds = {
  667. "orderId": dt.data.orderId
  668. };
  669. layer.open({
  670. type: 2,
  671. shadeClose: false,
  672. content: "正在请求加载订单信息..."
  673. }); // 调用加载弹出层
  674. $.ajax(base_path + '/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  675. data: {
  676. "orderId": dt.data.orderId
  677. },
  678. dataType: 'json',
  679. xhrFields: {
  680. withCredentials: true
  681. },
  682. crossDomain: true,
  683. type: 'get',
  684. timeout: 15000,
  685. success: function(dataobj) {
  686. if(dataobj.isRedirect) {
  687. location.href = dataobj.redirectURL;
  688. } else {
  689. if(dataobj.status == true) { // 支付成功
  690. location.href = "pay_win.html?orderId=" + orderIds.orderId + "&dates=" + new Date().getTime();
  691. } else {
  692. setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000); // 前往订单详情
  693. }
  694. }
  695. },
  696. error: function(xhr, type, errorThrown) {
  697. console.log(xhr);
  698. }
  699. });
  700. } else {
  701. isPay = true;
  702. // mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!");
  703. location.href = "order_details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  704. }
  705. });
  706. } else {
  707. isPay = true;
  708. mui.alert(dt.message);
  709. location.href = "order_details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  710. }
  711. }
  712. },
  713. error: function(xhr, type, errorThrown) {
  714. isPay = true;
  715. layer.closeAll();
  716. mui.alert("您的网络异常,请刷新重试!");
  717. return;
  718. }
  719. });
  720. } else {
  721. mui.alert("正在请求支付中~~请稍后!");
  722. return;
  723. }
  724. } else {
  725. mui.alert("请选择收货地址!");
  726. return;
  727. }
  728. });
  729. //选择优惠券
  730. mui('body').on('tap', '.mui-popover-action li>a', function() {
  731. var a = this,
  732. parent;
  733. //根据点击按钮,反推当前是哪个actionsheet
  734. for(parent = a.parentNode; parent != document.body; parent = parent.parentNode) {
  735. if(parent.classList.contains('mui-popover-action')) {
  736. break;
  737. }
  738. }
  739. //关闭actionsheet
  740. mui('#' + parent.id).popover('toggle');
  741. yhq_val = $("input[name=radio1]:checked").val();
  742. yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
  743. var yhq_id=$("input[name=radio1]:checked").attr("couponid");
  744. if(yhq_val == undefined) {
  745. yhq_val = 0
  746. } else {
  747. if(yhq_type == 1) {
  748. if(yhq_val > (usePayMoney - ipt_balance)) {
  749. $("input[name=radio1]:checked").removeAttr("checked");
  750. yhq_val = 0;
  751. mui.alert(' ', '当前优惠券不可用', function() {});
  752. }
  753. $("#yhq_name").html($("input[name=radio1]:checked").prev().html());
  754. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  755. $("#accSub,#accSub>div:first-child").show();
  756. //$("#user-pay-money-span").html((usePayMoney -yhq_val- ipt_balance).toFixed(2));
  757. $(".dhq-last-add").hide();
  758. exchangeColorId='';
  759. }else if(yhq_type == 3){
  760. if(yhq_id==10000){
  761. if(yhq_val > (usePayMoney - ipt_balance)) {
  762. $("input[couponid=10000]:checked").removeAttr("checked");
  763. yhq_val = 0;
  764. mui.alert(' ', '当前优惠券不可用', function() {});
  765. }
  766. $("#yhq_name").html($("input[couponid=10000]:checked").prev().html());
  767. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  768. $("#accSub,#accSub>div:first-child").show();
  769. $(".dhq-last-add").show();
  770. console.log(yhq_val)
  771. if($(".dhq-last-add").length>0){
  772. yhq_val = 0;
  773. }
  774. }else if(yhq_id==10001){
  775. $("#yhq_name").html($("input[name=radio1]:checked").prev().html());
  776. $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));
  777. $("#accSub,#accSub>div:first-child").show();
  778. $(".dhq-last-add").hide();
  779. exchangeColorId='';
  780. }
  781. //$("#user-pay-money-span").html((usePayMoney -yhq_val- ipt_balance).toFixed(2));
  782. } else {
  783. yhq_val = accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100);
  784. $("#yhq_name").html($("input[name=radio1]:checked").prev().html());
  785. $("#yhq_price").html("- ¥"+yhq_val);
  786. $("#accSub,#accSub>div:first-child").show();
  787. //$("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  788. $(".dhq-last-add").hide();
  789. exchangeColorId='';
  790. }
  791. if(user38Interests==1){
  792. if((usePayMoney - yhq_val - ipt_balance)>=2000 && (usePayMoney - yhq_val - ipt_balance)<3000){
  793. $("#user2000").show();
  794. $("#user3000").hide();
  795. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  796. }else if((usePayMoney - yhq_val - ipt_balance)>=3000){
  797. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance-100).toFixed(2));
  798. $("#user2000,#user3000").show();
  799. }else{
  800. $("#user2000,#user3000").hide();
  801. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  802. }
  803. }else{
  804. $("#user2000,#user3000").hide();
  805. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  806. }
  807. }
  808. });
  809. mui.os.ios ? listener_ipt() : keyup_fn();
  810. var reg = /^(([1-9]\d*))$/;
  811. function keyup_fn() {
  812. $('body').on('blur', '#pay_ipt', function(e) {
  813. ipt_balance = $(this).val();
  814. if(reg.test(ipt_balance)) {
  815. if(ipt_balance > (usePayMoney - yhq_val)) {
  816. ipt_balance = (usePayMoney - yhq_val).toFixed(2);
  817. if(ipt_balance < 0) {
  818. ipt_balance = 0;
  819. $(this).val("");
  820. } else {
  821. $(this).val((usePayMoney - yhq_val).toFixed(2));
  822. }
  823. }
  824. if(ipt_balance > used_balance) {
  825. ipt_balance = used_balance;
  826. $(this).val(used_balance);
  827. }
  828. $('#used_buy').html(ipt_balance);
  829. var money = (usePayMoney - yhq_val).toFixed(2);
  830. money <= 0 ? money = 0 : money;
  831. $("#accSub,#accSub>div:last-child").show();
  832. $("#user-pay-money-span").html((money - ipt_balance).toFixed(2));
  833. } else {
  834. mui.alert(' ', '您输入的数字有误,请重新输入', function() {
  835. $(this).val("");
  836. ipt_balance = 0;
  837. $('#used_buy').html(ipt_balance);
  838. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  839. });
  840. }
  841. });
  842. }
  843. function listener_ipt() {
  844. document.getElementById('pay_ipt').onblur = function() {
  845. var th = this;
  846. ipt_balance = th.value;
  847. if(reg.test(ipt_balance)) {
  848. if(ipt_balance > (usePayMoney - yhq_val)) {
  849. ipt_balance = (usePayMoney - yhq_val).toFixed(2);
  850. if(ipt_balance < 0) {
  851. ipt_balance = 0;
  852. th.value = "";
  853. } else {
  854. th.value = (usePayMoney - yhq_val).toFixed(2);
  855. }
  856. }
  857. if(ipt_balance > used_balance) {
  858. th.value = used_balance;
  859. ipt_balance = used_balance;
  860. }
  861. $('#used_buy').html(ipt_balance);
  862. var money = (usePayMoney - yhq_val).toFixed(2);
  863. money <= 0 ? money = 0 : money;
  864. $("#accSub,#accSub>div:last-child").show();
  865. $("#user-pay-money-span").html((money - ipt_balance).toFixed(2));
  866. } else {
  867. mui.alert(' ', '您输入的数字有误<br>请重新输入', function() {
  868. th.value = "";
  869. ipt_balance = 0;
  870. $('#used_buy').html(ipt_balance);
  871. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  872. });
  873. }
  874. }
  875. }
  876. document.querySelector('.loading-bg').style.display = 'none';
  877. });
  878. // 校验订单状态
  879. function checkOrderStatus(orderId) {
  880. $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  881. data: {
  882. "orderId": orderId
  883. },
  884. dataType: 'json',
  885. xhrFields: {
  886. withCredentials: true
  887. },
  888. crossDomain: true,
  889. type: 'get',
  890. timeout: 15000,
  891. success: function(dataobj) {
  892. if(dataobj.isRedirect) {
  893. location.href = dataobj.redirectURL;
  894. } else {
  895. if(dataobj.status == true) { // 支付成功
  896. location.href = "pay-win.html?orderId=" + dataobj.data + "&dates=" + new Date().getTime();
  897. } else {
  898. location.href = 'order_details.html?orderId=' + orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  899. }
  900. }
  901. },
  902. error: function(xhr, type, errorThrown) {
  903. console.log(xhr);
  904. }
  905. });
  906. };
  907. // 点击加号的事件
  908. function shoppAddEvent(productId,colorId) {
  909. $.ajax(base_path + '/cart/addCart', {
  910. data: {
  911. "productId": productId,
  912. "carNum": 1,
  913. "colorId":colorId
  914. },
  915. dataType: 'json',
  916. type: 'GET',
  917. timeout: 15000,
  918. xhrFields: {
  919. withCredentials: true
  920. },
  921. crossDomain: true,
  922. success: function(dt) {
  923. if (dt.isRedirect) {
  924. location.href = dt.redirectURL;
  925. } else {
  926. if(dt.status == true) {
  927. // 销售价
  928. var productObj = $("#product-" + productId);
  929. var price = parseInt(productObj.attr("price"));
  930. // total
  931. var total = payTotal + price;
  932. payTotal = total;
  933. // 修改数量
  934. var shoppNumObj = $("#shoppNum-" + productId);
  935. var num = parseInt(shoppNumObj.val());
  936. shoppNumObj.val(num + 1);
  937. /* $("#user-pay-money-span").html((payTotal / 100).toFixed(2)); */
  938. yhq_val = $("input[name=radio1]:checked").val();
  939. yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
  940. usePayMoney = accDiv(payTotal, 100);
  941. if(yhq_val == undefined) {
  942. yhq_val = 0
  943. }
  944. if(yhq_type == 2) {
  945. yhq_val = accSub(usePayMoney, (Math.floor(accMul(yhq_val, usePayMoney) * 100) / 100));
  946. $("#yhq_price").html(accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100));
  947. }
  948. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  949. // 修改小计
  950. productObj.html("¥" + ((num + 1) * price / 100).toFixed(2));
  951. var temp = new Number($("#shoppNum-all").val());
  952. temp = temp + 3;
  953. $("#shoppNum-all").val(temp);
  954. if(showIs){
  955. var gNum = $("#giveNum").html();
  956. var rNum = parseInt(gNum) + 1;
  957. $("#giveNum").html(rNum);
  958. }
  959. } else {
  960. // 失败之后的事件
  961. mui.alert(dt.message);
  962. }
  963. }
  964. },
  965. error: function(xhr, type, errorThrown) {}
  966. });
  967. }
  968. // 购物车减
  969. function shoppSubEvent(productId,colorId) {
  970. var shoppNumObj = $("#shoppNum-" + productId);
  971. var num = parseInt(shoppNumObj.val());
  972. if(num <= 1) {
  973. mui.alert("不能继续减少了哦!");
  974. return;
  975. }
  976. $.ajax(base_path + '/cart/deleteCart', {
  977. data: {
  978. "productId": productId,
  979. "cartNum": 1,
  980. "colorId":colorId
  981. },
  982. dataType: 'json',
  983. type: 'GET',
  984. timeout: 15000,
  985. xhrFields: {
  986. withCredentials: true
  987. },
  988. crossDomain: true,
  989. success: function(dt) {
  990. if (dt.isRedirect) {
  991. location.href = dt.redirectURL;
  992. } else {
  993. if(dt.status == true) {
  994. // 销售价
  995. var productObj = $("#product-" + productId);
  996. var price = parseInt(productObj.attr("price"));
  997. // total
  998. var total = payTotal - price;
  999. payTotal = total;
  1000. // 修改数量
  1001. var shoppNumObj = $("#shoppNum-" + productId);
  1002. var num = parseInt(shoppNumObj.val());
  1003. shoppNumObj.val(num - 1);
  1004. /*$("#user-pay-money-span").html((payTotal / 100).toFixed(2));*/
  1005. yhq_val = $("input[name=radio1]:checked").val();
  1006. yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
  1007. usePayMoney = accDiv(payTotal, 100);
  1008. if(yhq_val == undefined) {
  1009. yhq_val = 0
  1010. }
  1011. if(yhq_type == 2) {
  1012. yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_val, usePayMoney) * 100) / 100);
  1013. $("#yhq_price").html(accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100));
  1014. if(ipt_balance > (usePayMoney - yhq_val)) {
  1015. if((usePayMoney - yhq_val) <= 0) {
  1016. ipt_balance = 0;
  1017. $('#used_buy').html(ipt_balance);
  1018. $('#pay_ipt').val("");
  1019. } else {
  1020. ipt_balance = (usePayMoney - yhq_val).toFixed(2);
  1021. $('#used_buy').html(ipt_balance);
  1022. $('#pay_ipt').val(ipt_balance);
  1023. }
  1024. }
  1025. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  1026. } else {
  1027. if((usePayMoney - yhq_val) < ipt_balance) {
  1028. if((usePayMoney - yhq_val) <= 0) {
  1029. ipt_balance = 0;
  1030. $('#used_buy').html(ipt_balance);
  1031. $('#pay_ipt').val("");
  1032. } else {
  1033. ipt_balance = (usePayMoney - yhq_val).toFixed(2);
  1034. $('#used_buy').html(ipt_balance);
  1035. $('#pay_ipt').val(ipt_balance);
  1036. }
  1037. }
  1038. if(yhq_val > (usePayMoney - ipt_balance)) {
  1039. mui.alert(' ', '当前优惠券不可用', function() {
  1040. $("input[name=radio1]:checked").removeAttr("checked");
  1041. yhq_val = 0;
  1042. $("#yhq_price").html(yhq_val);
  1043. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  1044. });
  1045. }
  1046. $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
  1047. }
  1048. var temp = new Number($("#shoppNum-all").val());
  1049. temp = temp - 3;
  1050. $("#shoppNum-all").val(temp+"")
  1051. productObj.html("¥" + ((num - 1) * price / 100).toFixed(2));
  1052. if(showIs){
  1053. var gNum = $("#giveNum").html();
  1054. var rNum = parseInt(gNum) - 1;
  1055. $("#giveNum").html(rNum);
  1056. }
  1057. } else {
  1058. mui.alert(dt.message);
  1059. }
  1060. }
  1061. },
  1062. error: function(xhr, type, errorThrown) {
  1063. errorfn(xhr);
  1064. }
  1065. });
  1066. }
  1067. </script>
  1068. </body>
  1069. </html>