clearing.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  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 {
  19. display: none;
  20. }
  21. .my-yhq-tab:before,
  22. .my-yhq-tab:after,
  23. .my-yhq-tab>li:after {
  24. display: none;
  25. }
  26. .my-yhq-tab>li {
  27. border-bottom: 8px solid #F2F2F2;
  28. color: #333;
  29. }
  30. .mui-switch {
  31. background: #bbb;
  32. height: 20px;
  33. border: 1px solid #bbb;
  34. padding: 0 5px;
  35. }
  36. .mui-switch:before {
  37. content: '';
  38. }
  39. .mui-switch.mui-active:before {
  40. content: '';
  41. }
  42. .mui-switch .mui-switch-handle {
  43. top: -6px;
  44. width: 30px;
  45. height: 30px;
  46. margin-left: 2px;
  47. }
  48. .clearing-box .mui-table-view-cell.mui-active,
  49. .mui-navigate-right.mui-active {
  50. background: #fff !important;
  51. }
  52. .mui-switch.mui-active {
  53. background: #74c7dd;
  54. border-color: #74c7dd;
  55. }
  56. .clearing-box .mui-table-view-cell {
  57. border-bottom: 8px solid #f2f2f2;
  58. }
  59. .clearing-box .mui-table-view-cell:after,
  60. .my-view-no-top:after {
  61. left: 0;
  62. display: none;
  63. }
  64. .shopping-cart-list {
  65. border-bottom: 8px solid #f2f2f2;
  66. }
  67. .clearing-box {
  68. margin: 0;
  69. padding-bottom: 0;
  70. }
  71. .icon-dingwei {
  72. font-size: 22px;
  73. color: #e06974;
  74. }
  75. .my-yhq-tab .mui-navigate-right:after{
  76. font-size: 20px;
  77. color: #999;
  78. right: 8px;
  79. }
  80. .btn-add-address .icon-jia{
  81. color: #999;
  82. left: 7px;
  83. }
  84. .address-cantainner .mui-icon-arrowright{
  85. font-size: 20px;
  86. color: #999;
  87. }
  88. #textarea::-webkit-input-placeholder{
  89. color: #999;
  90. }
  91. </style>
  92. <script type="text/javascript">
  93. // 屏蔽分享
  94. window.hiddenAllWechatMenu = true;
  95. </script>
  96. </head>
  97. <body style="background: #f2f2f2">
  98. <div class="loading-bg">
  99. <div class="mui-loading">
  100. <div class="mui-spinner">
  101. </div>
  102. &nbsp;&nbsp;加载中...
  103. </div>
  104. </div>
  105. <div class="mui-content" style="padding-bottom: 100px !important;background: #f2f2f2;">
  106. <div class="address-cantainner">
  107. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed">
  108. <li class="mui-table-view-cell">
  109. <div class="mui-table">
  110. <!--没有选地址时显示的div-->
  111. <div class="mui-table-cell mui-col-xs-12 table-middle btn-add-address">
  112. <div class="add-address"><span class="iconfont icon-jia"></span>添加收货地址</div>
  113. </div>
  114. <div class="mui-table-cell mui-col-xs-1 mui-text-right table-middle btn-add-address">
  115. <p><span class="mui-icon mui-icon-arrowright"></span></p>
  116. </div>
  117. <!--选择微信地址后显示的div-->
  118. <div id="user-address-div" style="display: none;">
  119. <!--<div class="mui-table-cell mui-col-xs-1 mui-text-left table-middle">
  120. <p><span class="iconfont icon-dingwei"></span></p>
  121. </div>
  122. <div class="mui-table-cell mui-col-xs-10 mui-text-left table-middle">
  123. <div>收货人:林笑笑 <span class="mui-pull-right">16899996678</span></div>
  124. <p>收货地址:广东省深圳市福田区莲花街道深圳特区 报业大厦12b</p>
  125. </div>-->
  126. </div>
  127. </div>
  128. </li>
  129. </ul>
  130. </div>
  131. <!--<ul class="mui-table-view more">-->
  132. <!--<li class="mui-table-view-cell line-color" style="padding:20px 10px;">-->
  133. <!--<div style="display: none;" id="user-address-div"></div>-->
  134. <!--<a class="check_address" id="open-wechat-addres-a">-->
  135. <!--<span>请选择收货地址!</span><span class="mui-icon mui-icon-forward icon-r-c"></span>-->
  136. <!--</a>-->
  137. <!--</li>-->
  138. <!--</ul>-->
  139. <ul class="mui-table-view mui-table-view-chevron my-grid-view-no" id="products-list-ul" style="border-bottom: 8px solid #f2f2f2;">
  140. <li class="mui-table-view-cell mui-media" id="load-li">
  141. &nbsp;&nbsp;加载产品信息中...
  142. </li>
  143. </ul>
  144. <ul class="mui-table-view my-yhq-tab">
  145. <li class="mui-table-view-cell forward" style="margin: 0">
  146. <a href="#forward" class="mui-navigate-right">
  147. <div class="mui-media-body">
  148. 优惠券<span class="yhq-right"><span class="cl-red" id="yhq_count" style="display: none;">0</span></span>
  149. </div>
  150. </a>
  151. </li>
  152. <li class="mui-table-view-cell show_integral" style="display: none;" >
  153. 可用积分 <span style="margin-left: 10px;" class="integral_num">0</span>,抵扣¥<span class="integral_money">0</span>
  154. <!-- 开关打开状态,多了一个.mui-active类 -->
  155. <div class="mui-switch mui-switch-mini mui-active" id="mySwitch">
  156. <div class="mui-switch-handle"></div>
  157. </div>
  158. </li>
  159. <div style="padding: 10px 15px 0 15px;display: none;">可用余额:<span class="cl-red" id="used_balance">¥0.00</span></div>
  160. <li class="mui-table-view-cell pay_ipt_box" style="padding: 0;display: none;">
  161. <div class="mui-input-group">
  162. <div class="mui-input-row">
  163. <label>输入使用金额:</label>
  164. <input id="pay_ipt" type="number" placeholder="(如699)">
  165. </div>
  166. </div>
  167. </li>
  168. <li class="mui-table-view-cell" style="padding: 0;margin: 0;">
  169. <div class="mui-input-group">
  170. <div class="mui-input-row">
  171. <label>订单备注</label>
  172. <input style="font-size: 12px" type="text" placeholder="(选填:特殊要求,可以在此备注)" id="textarea">
  173. </div>
  174. </div>
  175. </li>
  176. <li class="mui-table-view-cell" style="padding: 0;margin: 0;display: none;">
  177. <div class="mui-input-group">
  178. <div class="mui-input-row">
  179. <label>商品金额:</label>
  180. <input style="font-size: 12px;text-align: right;" type="text" readonly="readonly" placeholder="(选填:订单要求,可以在此备注)" id="total">
  181. </div>
  182. </div>
  183. </li>
  184. <li class="mui-table-view-cell" id="vipSub" style="display: none;">
  185. <div><span>VIP专享(1年滤芯套装)</span><span class="mui-pull-right"><span id="vip_price">- ¥0</span></span>
  186. </div>
  187. </li>
  188. <li class="mui-table-view-cell" id="accSub">
  189. <div><span id="yhq_name"></span><span class="mui-pull-right"><span id="yhq_price"></span></span>
  190. </div>
  191. <div>账户余额:<span class="mui-pull-right cl-red">- ¥<span id="used_buy">0</span></span>
  192. </div>
  193. </li>
  194. <li class="mui-table-view-cell" id="user2000" style="display: none;">
  195. <div><span>全场购满2000元</span><span class="mui-pull-right"><span id="user_2000">赠Aiberle电动牙刷1支</span></span>
  196. </div>
  197. </li>
  198. <li class="mui-table-view-cell" id="user3000" style="display: none;">
  199. <div><span>全场购满3000元</span><span class="mui-pull-right">- ¥<span id="user_3000">100</span></span>
  200. </div>
  201. </li>
  202. </ul>
  203. <!--<div class="clearing-count" style="text-align: right;">订单合计:<font class="cl-red">¥</font><span class="cl-red" id="user-pay-money-span">加载中...</span></div>-->
  204. <div class="buy-footer1">
  205. <table class="tb-clearing">
  206. <tbody>
  207. <tr>
  208. <td>
  209. 共<span><span id="pro-count">0</span>件</span>
  210. </td>
  211. <td class="mui-text-center">合计:<span class="count_price_box">¥<span class="cl-red" id="user-pay-money-span">0.0</span></span>
  212. </td>
  213. <td>
  214. <a id="btn-weixin-pay" class="mui-btn mui-pull-right add_gwc btn-weixin-pay" style="min-width: 120px;">支付</a>
  215. </td>
  216. </tr>
  217. </tbody>
  218. </table>
  219. </div>
  220. <!--<div class="pay_weixin">
  221. <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>
  222. </div>-->
  223. </div>
  224. <div id="forward" class="mui-popover mui-popover-action mui-popover-bottom">
  225. <div class="mui-input-group mui-table-view-radio my-popover ">
  226. </div>
  227. <ul class="mui-table-view">
  228. <li class="mui-table-view-cell">
  229. <a href="#forward"><b>确定</b></a>
  230. </li>
  231. </ul>
  232. </div>
  233. <div class="dhq-dalog">
  234. <div>
  235. <div class="titles">请选择免费兑换产品
  236. <p>(您有1张T1/T2滤芯兑换券)</p>
  237. </div>
  238. <div>
  239. <form class="mui-input-group">
  240. <div class="mui-input-row mui-radio mui-left">
  241. <label>兑换T1滤芯</label>
  242. <input name="radio2" type="radio" value="7" />
  243. </div>
  244. <div class="mui-input-row mui-radio mui-left">
  245. <label>兑换T2滤芯</label>
  246. <input name="radio2" type="radio" value="8" />
  247. </div>
  248. </form>
  249. </div>
  250. <div class="btn-boxs">
  251. <button type="button" class="mui-btn nexts">下次兑换</button>
  252. <button type="button" class="mui-btn enter">确认兑换</button>
  253. </div>
  254. </div>
  255. </div>
  256. <script src="js/mui.min.js"></script>
  257. <script src="js/jquery-2.1.1.min.js"></script>
  258. <script src="js/main.js"></script>
  259. <script src="js/page/wechat-utils-1.0.js"></script>
  260. <script src="js/page/layer.js"></script>
  261. <script>
  262. var userIntegral = 0; // 用户可用积分
  263. var meonyProportion = 0; // 兑换比例:1个积分=?分钱
  264. var payTotal = 0.0; // 支付总金额
  265. var userInputIntegral = 0; // 抵扣积分
  266. var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求
  267. var cartIdStr = ""; // 购物车ID
  268. var pro_all_count = 0;
  269. var usePayMoney = 0;
  270. var constUsePayMoney = 0;
  271. var ipt_balance = 0;
  272. var yhq_val = 0;
  273. var used_balance = 0;
  274. var yhq_type = 1;
  275. var showIs = false;
  276. var accVipSub = 0;
  277. var exchangeColorId = '';
  278. var t1 = 0,
  279. t2 = 0,
  280. all_t = 0;
  281. var user38Interests = 2;
  282. var isSpell = 2; //不能拼单
  283. var orderId = getParam('orderId');
  284. // var isSpellstr = '';
  285. var productId = '';
  286. var colorId = '';
  287. var wechatAddr = new Object();
  288. var mypayTotal = 0; //后台返回总计
  289. var userIsVip=1; //是否为vip :1:非vip 2:vip
  290. var userIntegralUsed = 1; // 是否使用积分 1:使用 2:不使用
  291. var userIntegralUsedNumber = 1; //积分使用量
  292. mui.ready(function() {
  293. var name, value;
  294. var str = location.href; //取得整个地址栏
  295. var num = str.indexOf("?")
  296. str = str.substr(num + 1); //取得所有参数
  297. var $productListUl = $("#products-list-ul");
  298. $.ajax(base_path + '/order/payBefore?' + str, {
  299. dataType: 'json',
  300. type: 'POST',
  301. timeout: 15000,
  302. xhrFields: {
  303. withCredentials: true
  304. },
  305. crossDomain: true,
  306. success: function(dt) {
  307. if(dt.status == true) {
  308. // 购物项遍历
  309. //console.log(dt)
  310. var liNote = "";
  311. var cNum = 0;
  312. user38Interests = dt.data.user38Interests;
  313. if(dt.data.balance == 0) {
  314. $(".pay_ipt_box").hide();
  315. } else {
  316. used_balance = accDiv(dt.data.balance, 100);
  317. $('#used_balance').html("¥ " + accDiv(dt.data.balance, 100));
  318. }
  319. if(dt.data.couponItems.length == 0 || !dt.data.disable) {
  320. $(".forward").hide();
  321. $("#vipSub").hide();
  322. } else {
  323. setLvXin(dt);
  324. }
  325. for(let i = 0; i < dt.data.cartItems.length; i++) {
  326. pro_all_count += dt.data.cartItems[i].cartNum;
  327. // 购物车小计,分--元
  328. let total = dt.data.cartItems[i].cartNum * dt.data.cartItems[i].productDiscount / 100;
  329. let pro_color = switchcolor(dt.data.cartItems[i].cartColorId);
  330. let colorImg = switchColorImg(dt.data.cartItems[i].cartColorId);
  331. let cartProductId = dt.data.cartItems[i].cartProductId;
  332. let colorId = dt.data.cartItems[i].cartColorId;
  333. let productDiscount = dt.data.cartItems[i].productDiscount;
  334. total = total.toFixed(2); // 保留两位小数
  335. let num = dt.data.cartItems[i].cartNum;
  336. liNote = liNote +
  337. "<li class='mui-table-view-cell mui-media'>" +
  338. "<a>" +
  339. "<span class='mui-media-object mui-pull-left wh-100'> <img src='" + dt.data.cartItems[i].colorImg + "'></span>" +
  340. "<div class='mui-media-body' style='padding: 3% 0 3% 0;'>" +
  341. "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "</div>" +
  342. "<div><small class='mui-h6'>" + dt.data.cartItems[i].productColor + " x " + dt.data.cartItems[i].cartNum + "</small></div>" +
  343. "</div>" +
  344. "<div class='price_sp cl-gwc' id='product-" + cartProductId + "' price='" + productDiscount + "'>¥" + total + "</div>" +
  345. "</a>" +
  346. "</li>";
  347. if(dt.data.cartItems[i].cartColorId == 5 && dt.data.cartItems[i].cartProductId == 38) {
  348. accVipSub += (100 * dt.data.cartItems[i].cartNum);
  349. }
  350. }
  351. $productListUl.empty();
  352. $productListUl.append(liNote);
  353. // 保存数据
  354. meonyProportion = dt.data.meonyProportion; // 兑换比例
  355. payTotal = dt.data.payTotal; // 支付金额,单位分
  356. usePayMoney = dt.data.payTotal; // 支付金额,单位分
  357. constUsePayMoney = dt.data.payTotal; // 支付金额,单位分-不因积分而改变
  358. userIntegral = dt.data.userIntegral; // 用户可用积分
  359. cartIdStr = dt.data.cartId; // 购物车ID
  360. //计算积分能换算的钱
  361. var myUserIntegral = 0;
  362. if(dt.data.userIsVip == 2 && dt.data.userIntegral > 0){
  363. $('.show_integral').show();
  364. //积分赋值
  365. $('.integral_num').text(dt.data.userIntegral);
  366. var myUserIntegral = dt.data.userIntegral;
  367. myUserIntegral = parseInt(accDiv(myUserIntegral, 10));
  368. userIntegralUsedNumber = myUserIntegral
  369. $('.integral_money').text(myUserIntegral)
  370. }else{
  371. $('.show_integral').hide();
  372. userIntegralUsed = 2;
  373. }
  374. mypayTotal = dt.data.payTotal
  375. userIsVip = dt.data.userIsVip;
  376. setMoney();
  377. //默认自己拉出地址
  378. if(dt.data.addressInfo != undefined && dt.data.addressInfo != null) {
  379. $(".btn-add-address").hide();
  380. $("#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();
  381. //给微信参数赋值
  382. wechatAddr.status = true;
  383. wechatAddr.detailInfo = dt.data.addressInfo.salesAddressInfo;
  384. wechatAddr.userName = dt.data.addressInfo.salesAddressName;
  385. wechatAddr.userTel = dt.data.addressInfo.salesAddressTel;
  386. wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum;
  387. }
  388. } else {
  389. mui.alert(dt.message);
  390. }
  391. },
  392. error: function(xhr, type, errorThrown) {
  393. console.log(xhr);
  394. }
  395. });
  396. // 获取微信共享地址
  397. $(document).on('tap', '.btn-add-address,#user-address-div', function() {
  398. editAddrV1(
  399. function(res) {
  400. // 用户成功拉出地址
  401. var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  402. wechatAddr.status = true;
  403. wechatAddr.detailInfo = address;
  404. wechatAddr.postalCode = res.postalCode;
  405. wechatAddr.userName = res.userName;
  406. wechatAddr.userTel = res.telNumber;
  407. wechatAddr.nationalCode = res.nationalCode;
  408. $(".btn-add-address").hide();
  409. $("#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();
  410. },
  411. function() {
  412. if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  413. wechatAddr.status = true;
  414. } else {
  415. wechatAddr.status = false;
  416. // 用户取消拉出地址
  417. mui.alert("您没有选择收货地址!");
  418. }
  419. }
  420. );
  421. });
  422. //去支付
  423. mui('body').on('tap', '.btn-weixin-pay', function() {
  424. var yhq_id = $("input[name=radio1]:checked").attr('id');
  425. if(yhq_id == undefined) {
  426. yhq_id = "";
  427. }
  428. var remark = $("#textarea").val();
  429. var pattern = new RegExp("[ `~!@#$^&*()=|{}':;'\\[\\]<>/?~!@#¥……&*()——|{}【】‘;:”“'、?]")
  430. if(remark != "") {
  431. $.trim(remark);
  432. if(pattern.test(remark)) {
  433. mui.alert("请不要输入中文、字母、数字以外的特殊字符!");
  434. return;
  435. }
  436. if(!(remark.length >= 0 && remark.length <= 100)) {
  437. mui.alert("备注字数长度在0-100之间!");
  438. return;
  439. }
  440. }
  441. userInputIntegral = 0;
  442. if(userIntegralUsed == 1){
  443. userInputIntegral = $('.integral_money').text();
  444. userInputIntegral = accMul(userInputIntegral,10)
  445. }
  446. if(wechatAddr.status) {
  447. if(isPay) {
  448. isPay = false; // 锁定请求按钮
  449. layer.open({
  450. type: 2,
  451. shadeClose: false,
  452. content: "正在请求加载订单信息..."
  453. }); // 调用加载弹出层
  454. /* 组装数据 */
  455. var dataArgs = {
  456. "orderAddressInfo": wechatAddr.detailInfo,
  457. "orderAddressPostNum": wechatAddr.postalCode,
  458. "orderAddressMoblie": wechatAddr.userTel,
  459. "orderAddressName": wechatAddr.userName,
  460. "cartIdStr": cartIdStr,
  461. "orderIntegralNum": userInputIntegral,
  462. "orderUserRemark": remark,
  463. "couponId": yhq_id,
  464. "balancePayAmount": accMul(ipt_balance, 100)
  465. };
  466. if($(".dhq-last-add").is(":visible")) {
  467. exchangeColorId = $(".dhq-dalog input[type=radio]:checked").val();
  468. dataArgs["exchangeColorId"] = exchangeColorId;
  469. }
  470. if(isSpell == 1) {
  471. dataArgs['isSpell'] = isSpell;
  472. }
  473. if(orderId != '' && orderId != null) {
  474. dataArgs['spellOrderId'] = orderId;
  475. }
  476. // }
  477. $.ajax(base_path + '/order/pay', { // 提交订单,准备支付
  478. data: dataArgs,
  479. dataType: 'json',
  480. type: 'POST',
  481. timeout: 15000,
  482. xhrFields: {
  483. withCredentials: true
  484. },
  485. crossDomain: true,
  486. success: function(dt) {
  487. if(dt.isRedirect) {
  488. location.href = dt.redirectURL;
  489. } else {
  490. layer.closeAll();
  491. //mui.alert(dt.resultCode=="500");
  492. if(dt.resultCode == "500") {
  493. mui.alert(dt.message);
  494. isPay = true;
  495. return;
  496. };
  497. if(dt.data.info == "isOK") {
  498. location.href = 'pay_win.html?orderId=' + dt.data.orderId;
  499. return;
  500. };
  501. if(dt.status) {
  502. var str = dt.data.info;
  503. var obj = JSON.parse("{" + str + "}");
  504. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  505. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  506. var orderIds = {
  507. "orderId": dt.data.orderId
  508. };
  509. layer.open({
  510. type: 2,
  511. shadeClose: false,
  512. content: "正在请求加载订单信息..."
  513. }); // 调用加载弹出层
  514. $.ajax(base_path + '/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  515. data: {
  516. "orderId": dt.data.orderId
  517. },
  518. dataType: 'json',
  519. xhrFields: {
  520. withCredentials: true
  521. },
  522. crossDomain: true,
  523. type: 'get',
  524. timeout: 15000,
  525. success: function(dataobj) {
  526. if(dataobj.isRedirect) {
  527. location.href = dataobj.redirectURL;
  528. } else {
  529. if(dataobj.status == true) { // 支付成功
  530. if(isSpell == 1 && orderId == null) {
  531. location.href = 'pay_add_group.html?productId=' + productId + '&colorId=' + colorId + '&orderid=' + orderIds.orderId + '&isSpell=1'
  532. } else {
  533. location.href = "pay_win.html?orderId=" + orderIds.orderId
  534. }
  535. } else {
  536. setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000); // 前往订单详情
  537. }
  538. }
  539. },
  540. error: function(xhr, type, errorThrown) {
  541. console.log(xhr);
  542. }
  543. });
  544. } else {
  545. isPay = true;
  546. location.href = "order_details.html?orderId=" + dt.data.orderId ; // 前往订单详情
  547. }
  548. });
  549. } else {
  550. isPay = true;
  551. mui.alert(dt.message);
  552. location.href = "order_details.html?orderId=" + dt.data.orderId ; // 前往订单详情
  553. }
  554. }
  555. },
  556. error: function(xhr, type, errorThrown) {
  557. isPay = true;
  558. layer.closeAll();
  559. mui.alert("您的网络异常,请刷新重试!");
  560. return;
  561. }
  562. });
  563. } else {
  564. mui.alert("正在请求支付中~~请稍后!");
  565. return;
  566. }
  567. } else {
  568. mui.alert("请选择收货地址!");
  569. return;
  570. }
  571. });
  572. //选择优惠券
  573. mui('body').on('tap', '.mui-popover-action li>a', function() {
  574. var a = this,
  575. parent;
  576. //根据点击按钮,反推当前是哪个actionsheet
  577. for(parent = a.parentNode; parent != document.body; parent = parent.parentNode) {
  578. if(parent.classList.contains('mui-popover-action')) {
  579. break;
  580. }
  581. }
  582. //关闭actionsheet
  583. mui('#' + parent.id).popover('toggle');
  584. setMoney();
  585. });
  586. document.querySelector('.loading-bg').style.display = 'none';
  587. });
  588. // 校验订单状态
  589. function checkOrderStatus(orderId) {
  590. $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  591. data: {
  592. "orderId": orderId
  593. },
  594. dataType: 'json',
  595. xhrFields: {
  596. withCredentials: true
  597. },
  598. crossDomain: true,
  599. type: 'get',
  600. timeout: 15000,
  601. success: function(dataobj) {
  602. if(dataobj.isRedirect) {
  603. location.href = dataobj.redirectURL;
  604. } else {
  605. if(dataobj.status == true) { // 支付成功
  606. if(isSpell == 1 && orderId == null) {
  607. location.href = 'pay_add_group.html?productId=' + productId + '&colorId=' + colorId + '&orderid=' + dataobj.data + '&isSpell=1'
  608. } else {
  609. location.href = "pay_win.html?orderId=" + dataobj.data
  610. }
  611. } else {
  612. location.href = 'order_details.html?orderId=' + orderId ; // 前往订单详情
  613. // location.href = 'order_details.html?orderId=' + orderId + isSpellstr; // 前往订单详情
  614. }
  615. }
  616. },
  617. error: function(xhr, type, errorThrown) {
  618. console.log(xhr);
  619. }
  620. });
  621. };
  622. // 积分开关事件
  623. document.getElementById("mySwitch").addEventListener("toggle", function(e) {
  624. if(e.detail.isActive) {
  625. console.log("你启动了开关");
  626. userIntegralUsed = 1;
  627. } else {
  628. console.log("你关闭了开关");
  629. userIntegralUsed = 2;
  630. }
  631. setMoney();
  632. })
  633. /**
  634. * 滤芯弹窗及方法
  635. * @param {Object} dt
  636. */
  637. function setLvXin(dt){
  638. var yhq_str = "";
  639. var $productListUl = $("#products-list-ul");
  640. var c = 0,
  641. flag = false;
  642. var btnArray = ['否', '是'];
  643. mui(dt.data.couponItems).each(function(index) {
  644. if(this.couponId == 10000) {
  645. c++;
  646. }
  647. });
  648. mui(dt.data.cartItems).each(function(index) {
  649. var flag = true
  650. if(this.productName.indexOf('【赠品】') > -1){
  651. flag = false
  652. }
  653. if(this.cartColorId == 7 && flag) {
  654. t1 += this.cartNum;
  655. } else if(this.cartColorId == 8 && flag) {
  656. t2 += this.cartNum;
  657. } else {
  658. all_t++;
  659. }
  660. });
  661. if(c > 0) {
  662. if((t1 == 0 && t2 == 0) || all_t == 0) {
  663. $(".dhq-dalog").show();
  664. } else {
  665. flag = true;
  666. }
  667. $(document).on('tap', '.enter', function() {
  668. if($(".dhq-dalog input[type=radio]:checked").length > 0) {
  669. flag = true;
  670. exchangeColorId = $(".dhq-dalog input[type=radio]:checked").val();
  671. $.ajax(base_path + '/cart/get_exchange?dates=' + new Date().getTime(), {
  672. data: {
  673. "couponId": 10000
  674. },
  675. dataType: 'json',
  676. xhrFields: {
  677. withCredentials: true
  678. },
  679. crossDomain: true,
  680. type: 'post',
  681. async: false,
  682. timeout: 15000,
  683. success: function(dts) {
  684. console.log(dts);
  685. //if(dts.status==true){
  686. if(dt.isRedirect) {
  687. location.href = dt.redirectURL;
  688. } else {
  689. console.log("t1=" + t1 + ",t2=" + t2 + ",all_t=" + all_t);
  690. mui(dts.data).each(function(index) {
  691. if(exchangeColorId == this.colorId) {
  692. 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))) {
  693. $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>');
  694. } else {
  695. setMoney()
  696. }
  697. }
  698. });
  699. }
  700. //}
  701. },
  702. error: function(xhr, type, errorThrown) {
  703. console.log(xhr);
  704. }
  705. });
  706. $("#forward input[couponid=10000]").prop('checked', true);
  707. var yhq_check = $("input[name=radio1]:checked");
  708. yhq_val = yhq_check.val();
  709. yhq_type = yhq_check.attr("yhq_type");
  710. var yhq_id = yhq_check.attr("couponid");
  711. if(yhq_val == undefined) {
  712. yhq_val = 0
  713. } else {
  714. if(yhq_type == 3) {
  715. if(yhq_id == 10000) {
  716. var usednumber = usePayMoney;
  717. if(userIntegralUsed == 1){ //userIntegralUsed = 1; // 是否使用积分 1:使用 2:不使用
  718. usednumber = usePayMoney + userIntegralUsedNumber
  719. }
  720. if(yhq_val > (usednumber - ipt_balance)) {
  721. yhq_check.removeAttr("checked");
  722. yhq_val = 0;
  723. mui.alert(' ', '当前优惠券不可用', function() {});
  724. }
  725. $("#yhq_name").html(yhq_check.prev().html());
  726. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  727. $("#accSub,#accSub>div:first-child").show();
  728. if($(".dhq-last-add").length > 0) {
  729. yhq_val = 0;
  730. }
  731. setMoney()
  732. }
  733. }
  734. }
  735. $(".dhq-dalog").hide();
  736. } else {
  737. console.log("请选择要兑换的滤芯");
  738. }
  739. });
  740. //下次兑换
  741. $(document).on('tap', '.nexts', function() {
  742. $("#forward input[couponid=10000]").removeAttr('checked').prop("disabled", "disabled");
  743. $(".dhq-dalog").hide();
  744. flag = false;
  745. setMoney()
  746. });
  747. }
  748. if(dt.data.disable) {
  749. mui(dt.data.couponItems).each(function(index) {
  750. var checked = '';
  751. console.log(flag)
  752. if((this.couponId == 10000 && flag) || this.couponId == 10002) {
  753. checked = 'checked';
  754. }
  755. yhq_str += '<div class="mui-input-row mui-radio"><label>' + this.couponName + '</label><input name="radio1" value="' + accDiv(this.couponReduce, 100) + '" type="radio" couponid=' + this.couponId + ' id="' + this.couponItemId + '" yhq_type="' + this.couponType + '" enough="' + accDiv(this.couponConsumeEnough, 100) + '" ' + checked + '/></div>';
  756. });
  757. $(".my-popover").html(yhq_str + '<div class="mui-input-row mui-radio"><label>不使用优惠券</label><input name="radio1" value="1" type="radio"></div>');
  758. $("#yhq_count").html(dt.data.couponItems.length);
  759. if(t1 == 0 && t2 == 0) {
  760. $("#forward input[couponid=10001]").removeAttr('checked').prop("disabled", "disabled");
  761. }
  762. }
  763. }
  764. /**
  765. * 设置金额 - 任何需要变动总金额的地方,都只能调用此方法来计算
  766. */
  767. function setMoney() {
  768. usePayMoney = accDiv(mypayTotal, 100);
  769. $("#total").val(usePayMoney.toFixed(2) + " 元");
  770. //滤芯套装
  771. if(userIsVip == 2 && isSpell != 1) {
  772. $("#vip_price").text("- ¥" + (accVipSub).toFixed(2));
  773. $("#vipSub").show();
  774. usePayMoney -= accVipSub;
  775. }
  776. //优惠券
  777. var yhq_check = $("input[name=radio1]:checked");
  778. yhq_val = yhq_check.val();
  779. yhq_type = yhq_check.attr("yhq_type");
  780. enough = yhq_check.attr("enough");
  781. if(yhq_val == undefined) {
  782. yhq_val = 0
  783. } else {
  784. if(yhq_type == 1) {
  785. if(accDiv(payTotal, 100) >= enough) {
  786. if(yhq_val > usePayMoney) {
  787. yhq_check.removeAttr("checked");
  788. yhq_val = 0;
  789. mui.alert(' ', '当前优惠券不可用', function() {});
  790. }
  791. $("#yhq_name").html(yhq_check.prev().html());
  792. $("#yhq_price").html("- ¥" + parseInt(yhq_val).toFixed(2));
  793. $("#accSub,#accSub>div:first-child").show();
  794. console.log(usePayMoney)
  795. usePayMoney = (usePayMoney - yhq_val - ipt_balance).toFixed(2);
  796. $(".dhq-last-add").hide();
  797. exchangeColorId = '';
  798. } else {
  799. yhq_check.removeAttr("checked");
  800. yhq_val = 0;
  801. mui.alert(' ', '当前商品金额不满足使用条件', function() {});
  802. }
  803. } else if(yhq_type == 3) {
  804. if(yhq_val > (usePayMoney - ipt_balance)) {
  805. yhq_check.removeAttr("checked");
  806. yhq_val = 0;
  807. mui.alert(' ', '当前优惠券不可用', function() {});
  808. }
  809. $("#yhq_name").html(yhq_check.prev().html());
  810. $("#yhq_price").html("免费兑换1支T1或T2滤芯");
  811. $("#accSub,#accSub>div:first-child").show();
  812. $(".dhq-last-add").show();
  813. console.log(yhq_val)
  814. if($(".dhq-last-add").length > 0) {
  815. yhq_val = 0;
  816. }
  817. $("#user2000,#user3000").hide();
  818. usePayMoney = (usePayMoney - yhq_val - ipt_balance).toFixed(2)
  819. } else {
  820. yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_check.val(), usePayMoney) * 100) / 100);
  821. $("#yhq_name").html(yhq_check.prev().html());
  822. $("#yhq_price").html("- ¥" + yhq_val);
  823. $("#accSub,#accSub>div:first-child").show();
  824. $(".dhq-last-add").hide();
  825. usePayMoney = (usePayMoney - yhq_val - ipt_balance).toFixed(2)
  826. exchangeColorId = '';
  827. }
  828. }
  829. //最后使用积分
  830. if(userIntegralUsed == 1){
  831. var integral = $('.integral_money').text();
  832. if(parseInt(integral) > usePayMoney){
  833. $('.integral_money').text(usePayMoney)
  834. $('.integral_num').text(accMul(usePayMoney,10))
  835. integral = usePayMoney;
  836. }
  837. usePayMoney = usePayMoney - integral;
  838. }
  839. $("#user-pay-money-span").html(usePayMoney);
  840. $("#pro-count").text(pro_all_count); //总件数
  841. }
  842. </script>
  843. </body>
  844. </html>