clearing.html 32 KB

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