clearing.html 53 KB

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