clearing.html 56 KB

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