clearing.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">
  6. <meta name="apple-mobile-web-app-capable" content="yes">
  7. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  8. <title>结算</title>
  9. <link rel="stylesheet" type="text/css" href="css/mui.min.css" />
  10. <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
  11. <link rel="stylesheet" type="text/css" href="css/main.css" />
  12. <script type="text/javascript">
  13. // 屏蔽分享
  14. window.hiddenAllWechatMenu = true;
  15. </script>
  16. <style>
  17. .mui-table-view-cell>a:not(.mui-btn) {margin-left: -12px;}
  18. .no-after:after,.no-line:after{display: none;}
  19. .mui-table-view-cell.no-line{padding: 7px;}
  20. .add_gwc{display: block;width: 100%;}
  21. .mui-h6{margin-right: 6px;}
  22. .center{float: right;margin-right: 7px;}
  23. </style>
  24. </head>
  25. <body>
  26. <div class="mui-content" style="padding-bottom: 56px;">
  27. <div class="address-cantainner">
  28. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed">
  29. <li class="mui-table-view-cell">
  30. <div class="mui-table">
  31. <div class="mui-table-cell mui-col-xs-12 table-middle btn-add-address">
  32. <div class="add-address"><span class="iconfont icon-jia"></span>添加收货地址</div>
  33. </div>
  34. <div id="user-address-div" style="display: none;">
  35. </div>
  36. </div>
  37. </li>
  38. </ul>
  39. </div>
  40. <div class="clearing-box">
  41. <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed shopping-cart-list">
  42. </ul>
  43. <!--<div class="mui-content-padded mui-text-right">合计:<span class="pro-price">¥<span class="count_price">0.0</span></span>
  44. </div>-->
  45. <ul class="mui-table-view no-after">
  46. <li class="mui-table-view-cell" id="ul-youhuiquan" style="padding-left:7px;display: none;">
  47. <a class="mui-navigate-right btn-youhuiquan">
  48. 优惠券<span class="mui-pull-right cl-red">未选择优惠券</span>
  49. </a>
  50. </li>
  51. <!--<li class="mui-table-view-cell " id="" style="padding-left:7px;">
  52. <a class=" ">
  53. 总价<span class="mui-pull-right cl-red ">¥<span class="all_price"></span></span>
  54. </a>
  55. </li>
  56. <li class="mui-table-view-cell" id="" style="padding-left:7px;">
  57. <a class=" ">
  58. 邮费 <span style=" font-size: 12px;color: #8f8f94;">(总价满30元包邮)</span><span class="mui-pull-right cl-red">
  59. ¥<span class="sales_postage"></span>
  60. </span>
  61. </a>
  62. </li>-->
  63. <li class="mui-table-view-cell" style="padding-left:3px;">
  64. <div class="mui-input-row">
  65. <label class="lbl-remarks">订单备注</label>
  66. <input class="ipt-remarks" id="textarea" type="text" placeholder="选填:您对订单有特殊要求,可以在此备注">
  67. </div>
  68. </li>
  69. <li class="mui-table-view-cell no-line" style="padding-left:7px;">
  70. <a>
  71. <span class="mui-h6">商品金额</span><span class="mui-pull-right">
  72. <span class="mui-h6">¥<span class="count_price">0.0</span></span>
  73. </span>
  74. </a>
  75. </li>
  76. <li class="mui-table-view-cell no-line" style="padding-left:7px;display: none;">
  77. <a>
  78. <span class="mui-h6" id="coupon-name"></span><span class="mui-pull-right">
  79. <span class="mui-h6" id="coupon-val"></span>
  80. </span>
  81. </a>
  82. </li>
  83. <li class="mui-table-view-cell no-line" style="padding-left:7px;display: none;">
  84. <a>
  85. <span class="mui-h6" id="full-sub-name"></span><span class="mui-pull-right">
  86. <span class="mui-h6">- ¥<span id="full-sub-count">0</span></span>
  87. </span>
  88. </a>
  89. </li>
  90. <li class="mui-table-view-cell no-line" style="padding-left:7px;">
  91. <a>
  92. <span class="mui-h6">邮费(满30包邮)</span><span class="mui-pull-right">
  93. <span class="mui-h6">¥ <span class="sales_postage">0.0</span></span>
  94. </span>
  95. </a>
  96. </li>
  97. <li class="mui-table-view-cell no-line" style="padding-left:7px;">
  98. <span class="mui-pull-right">订单合计:<span class="count_price_box">¥<span class="pay_price">0.0</span></span></span>
  99. </li>
  100. </ul>
  101. </div>
  102. <div class="buy-footer1">
  103. <table class="tb-clearing">
  104. <tr>
  105. <!--<td class="quanxuan">
  106. 共<span id="pro-count" class="cl-red">0</span>件商品
  107. </td>
  108. <td class="mui-text-center">需支付:<span class="count_price_box">¥<span class="pay_price">0.0</span></span>
  109. </td>-->
  110. <td>
  111. <a id="go-pay" class="mui-btn mui-pull-right add_gwc go-clearing">立即支付</a>
  112. </td>
  113. </tr>
  114. </table>
  115. </div>
  116. </div>
  117. <div class="loading covers">
  118. <div class="loading-bj"></div>
  119. <p>正在加载...</p>
  120. </div>
  121. <script src="js/mui.min.js"></script>
  122. <script src="js/jquery-2.1.1.min.js"></script>
  123. <script src="js/main.js"></script>
  124. <script src="js/wechat-utils-1.0.js"></script>
  125. <script>
  126. window.addEventListener('pageshow', function(e) {
  127. // 通过persisted属性判断是否存在 BF Cache
  128. if(e.persisted) {
  129. location.reload();
  130. }
  131. });
  132. var userIntegral = 0; // 用户可用积分
  133. var meonyProportion = 0; // 兑换比例:1个积分=?分钱
  134. var payTotal = 0.0; // 支付总金额
  135. var userInputIntegral = 0; // 抵扣积分
  136. var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求
  137. var cartIdStr = ""; // 购物车ID
  138. var usePayMoney = 0;
  139. var ipt_balance = 0;
  140. var yhq_val = 0;
  141. var used_balance = 0;
  142. var yhq_type = 1;
  143. var yhq_id = '';
  144. var full_sb='';
  145. var orderItem; //获取订单项信息
  146. var couponMoney = 0; //新人卷 - 优惠金额
  147. var channelType = getParam("channelType"); //渠道类型
  148. var channelId = getParam("channelId"); //渠道id
  149. if(channelType == null || channelId == null ){
  150. channelType = 0;
  151. channelId=0;
  152. }
  153. if(channelType > 0 || channelId>0){
  154. location.href = 'channel-clearing.html?channelType='+channelType+'&channelId='+channelId; //跳转结算页面
  155. }
  156. var wechatAddr = new Object();
  157. mui.ready(function() {
  158. var parameter = {}; //ajax参数json集合
  159. var cartidList = '';
  160. if(!window.sessionStorage) {
  161. mui.alert("您的浏览器不支持sessionStorage");
  162. } else {
  163. //读取上一个页面带过来的sessionStorage
  164. pay_data = JSON.parse(sessionStorage.getItem('pay_data'));
  165. if(pay_data != null) {
  166. cartidList = pay_data.text[0]; //购物项id集合
  167. parameter["cartIds"] = cartidList;
  168. parameter["isCustomize"] = 1;
  169. parameter["channelType"] = channelType;
  170. parameter["channelId"] = channelId;
  171. $.ajax(base_path + '/wechat/order/payBefore', {
  172. data: parameter,
  173. dataType: 'json',
  174. type: 'get',
  175. xhrFields: {
  176. withCredentials: true
  177. },
  178. crossDomain: true,
  179. timeout: 15000,
  180. success: function(dt) {
  181. if(dt.isRedirect) {
  182. location.href = dt.redirectURL;
  183. } else {
  184. if(dt.status == true) {
  185. // 购物项遍历
  186. full_sb=dt.data.activityDate;
  187. orderItem = dt.data.cartItems; //订单项信息
  188. mui.each(dt.data.cartItems, function(index) {
  189. if(this.productType == 101){ //刷头类
  190. var brPrice = this.productPrice; //优惠券金额
  191. if(couponMoney == 0 || couponMoney < brPrice){
  192. couponMoney = brPrice;
  193. }
  194. }
  195. })
  196. var liNote = "";
  197. var yhq_str = "";
  198. if(dt.data.couponItems!=null && typeof(dt.data.couponItems)!=undefined &&
  199. dt.data.couponItems.length > 0 && channelType==0 && channelId ==0) {
  200. $("#ul-youhuiquan").show();
  201. var str = '';
  202. mui.each(dt.data.couponItems, function() {
  203. var couponReduce = this.couponReduce,val='';
  204. //if(this.couponIsNewPeople == 1){ //新人卷
  205. // couponReduce = couponMoney;
  206. //}
  207. if(this.couponType==2){
  208. val=(couponReduce/10).toFixed(1)+"折";
  209. }else{
  210. val='¥' + ((couponReduce) / 100).toFixed(2);
  211. }
  212. str += '<li class="my-table-view-cell" style="opacity:.5;margin:20px 0;"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">'+ this.couponName +':'+val+'<h6>有效期至:' + this.couponUseEndDate + '</h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="radio" type="radio" class="mui-pull-left" val="' + (this.couponReduce / 100).toFixed(2) + '" couponname="'+this.couponName+'" couponid="' + this.couponItemId + '" couponType="' + this.couponId + '" zhekou="'+this.couponType+'" couponIsNewPeople="'+ this.couponIsNewPeople +'"/></div></div></li>';
  213. });
  214. str += '<li class="my-table-view-cell" style="opacity:.5;margin:20px 0;"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">不使用优惠券<h6></h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="radio" type="radio" class="mui-pull-left" val="0"/></div></div></li>';
  215. $("body").append('<div class="my-picker"><ul class="mui-table-view mui-table-view-striped mui-table-view-condensed my-grid-view-no" style="padding: 25px 15px; overflow: scroll;max-height: 420px;">' + str + '</ul><button class="mui-btn my-btn-block my-btn-user-know" disabled="disabled">确认</button><span class="iconfont icon-guanbi"></span></div>');
  216. }
  217. var proCount = 0;
  218. mui.each(dt.data.cartItems, function(index) {
  219. if(this.productType == 101){ //刷头类
  220. var brPrice = this.productPrice; //优惠券金额
  221. if(couponMoney == 0 || couponMoney < brPrice){
  222. couponMoney = brPrice;
  223. }
  224. }
  225. var num = this.cartNum;
  226. proCount += num;
  227. var total = (num * this.productPrice / 100).toFixed(2); //购物车小计,单位分,保留两位小数
  228. var productId = this.cartProductId;
  229. liNote += '<div class="mui-table"><div class="mui-table-cell mui-col-xs-5"><img class="mui-media-object wh-100" src="' + this.productIntroduceImg + '"></div><div class="mui-table-cell table-middle mui-col-xs-7" style="line-height:2.5">' + this.productName + '<h6>颜色:' + this.productColor + '<span class="center">数量:' + num + '</span></h6><div>单价¥' + (this.productPrice / 100).toFixed(2) + '</div></div></div>';
  230. });
  231. var $productListUl = $(".shopping-cart-list");
  232. $productListUl.empty();
  233. $productListUl.append(liNote);
  234. // 保存数据
  235. payTotal = dt.data.payTotal; // 支付金额,单位分
  236. cartIdStr = dt.data.cartId; // 购物车ID
  237. //默认自己拉出地址
  238. if(dt.data.addressInfo != undefined && dt.data.addressInfo != null) {
  239. $(".btn-add-address").hide();
  240. $("#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();
  241. //给微信参数赋值
  242. wechatAddr.status = true;
  243. wechatAddr.detailInfo = dt.data.addressInfo.salesAddressInfo;
  244. wechatAddr.userName = dt.data.addressInfo.salesAddressName;
  245. wechatAddr.userTel = dt.data.addressInfo.salesAddressTel;
  246. wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum;
  247. }else{
  248. wechatAddr.status = false;
  249. }
  250. $(".count_price").text(accDiv(dt.data.payTotal,100));
  251. //var oldTotal = fullSub(dt.data.payTotal);
  252. $(".pay_price,.all_price").text(accDiv(fullSub(dt.data.payTotal),100));
  253. if(accDiv(fullSub(dt.data.payTotal),100) < 30){
  254. $(".sales_postage").text(10);
  255. }else{
  256. $(".sales_postage").text(0);
  257. }
  258. //$("#pro-count").text(proCount);
  259. $(".loading").hide().css("opacity", "0"); //隐藏(正在加载...)
  260. } else {
  261. mui.alert("获取数据失败!", function() {
  262. location.href = "shopping-cart.html";
  263. });
  264. }
  265. }
  266. },
  267. error: function(xhr, type, errorThrown) {
  268. console.log(xhr);
  269. mui.alert("获取数据失败,网络错误!")
  270. }
  271. });
  272. } else {
  273. mui.alert("sessionStorage异常!", function() {
  274. location.href = "index.html";
  275. })
  276. }
  277. }
  278. // var str = "";
  279. // for(i = 0; i < 3; i++) {
  280. // str += '<div class="mui-table"><div class="mui-table-cell mui-col-xs-5"><img class="mui-media-object wh-100" src="images/pro-bai.png"></div><div class="mui-table-cell table-middle mui-col-xs-7" style="line-height:2.5">柔性声波牙刷<h6>颜色:极光白<span class="center">数量:2</span></h6><div>¥2999.00</div></div></div>';
  281. // }
  282. // document.querySelector('.shopping-cart-list').innerHTML = str;
  283. });
  284. //callback为用户点击蒙版时自动执行的回调;
  285. var mask = mui.createMask(function() {
  286. $(".my-picker").removeClass("active"); //隐藏弹窗
  287. });
  288. //现金券弹窗
  289. $(document).on('tap', '.btn-youhuiquan', function() {
  290. mask.show();
  291. // if($(".my-picker").length==0){
  292. // var li = '<li class="my-table-view-cell" style="opacity:.5;margin:20px 0;"><div class="mui-table"><div class="mui-table-cell table-middle mui-col-xs-11">现金券:¥99.9<h6>有效期至:2017-12-12</h6></div><div class="mui-table-cell table-middle mui-col-xs-1"><input name="radio" type="radio" class="mui-pull-left" /></div></div></li>';
  293. // var str = '';
  294. // for(i = 0; i < 17; i++) {
  295. // str += li;
  296. // }
  297. // $("body").append('<div class="my-picker"><ul class="mui-table-view mui-table-view-striped mui-table-view-condensed my-grid-view-no" style="padding: 25px 15px; overflow: scroll;max-height: 420px;">' + str + '</ul><button class="mui-btn my-btn-block my-btn-user-know" disabled="disabled">确认使用</button><span class="iconfont icon-guanbi"></span></div>');
  298. // }
  299. // setTimeout(function() {
  300. if($(".my-picker").length > 0) {
  301. $(".my-picker").addClass("active");
  302. }
  303. // }, 500);
  304. });
  305. //确认使用
  306. $(document).on('tap', '.my-btn-user-know', function() {
  307. //console.log("确认使用");
  308. if(typeof($(".my-picker input[name=radio]:checked").attr("couponid")) != "undefined") {
  309. $(".btn-youhuiquan").attr("couponid", $(".my-picker input[name=radio]:checked").attr("couponid"));
  310. yhq_id = $(".my-picker input[name=radio]:checked").attr("couponid");
  311. $(".btn-youhuiquan span,#coupon-val").text("-¥" + $(".my-picker input[name=radio]:checked").attr("val"));
  312. var couponIsNewPeople = $(".my-picker input[name=radio]:checked").attr("couponIsNewPeople");
  313. var couponType = $(".my-picker input[name=radio]:checked").attr("couponType");
  314. var price = 0;
  315. /*只减去刷头的钱*/
  316. if(couponIsNewPeople == 1){ //标识为新人卷
  317. if(couponType == 20000){ //刷头抵扣卷
  318. var brushCouponPrice = 0; //刷头优惠总金额
  319. var otherPrice = 0;//其他商品总金额
  320. var couponPrice = $(".my-picker input[name=radio]:checked").attr("val"); //优惠券金额
  321. mui.each(orderItem,function(index){
  322. if(this.productType == 101 && this.cartProductId != 310 ){ //刷头类
  323. var brPrice = this.productPrice; //优惠券金额
  324. if(brushCouponPrice == 0 || brushCouponPrice < brPrice){
  325. brushCouponPrice = brPrice;
  326. }
  327. }
  328. });
  329. brushCouponPrice = accDiv(brushCouponPrice,100);
  330. price = accSub($(".count_price").text(),brushCouponPrice); //刷头减去优惠券
  331. $(".btn-youhuiquan span,#coupon-val").text("-¥" + brushCouponPrice); //减去优惠金额赋值
  332. }else if(couponType == 40000){ //新人卷 60元优惠券
  333. var brushPrice = 0; //刷头总金额
  334. var otherPrice = 0;//其他商品总金额
  335. var couponPrice = $(".my-picker input[name=radio]:checked").attr("val"); //优惠券金额
  336. mui.each(orderItem,function(index){
  337. if(this.productType == 101 && this.cartProductId != 310 ){
  338. brushPrice = accAdd(brushPrice,this.productPrice*this.cartNum);
  339. }else{
  340. otherPrice = accAdd(otherPrice,this.productPrice*this.cartNum);
  341. }
  342. });
  343. brushPrice = accDiv(brushPrice,100);
  344. otherPrice = accDiv(otherPrice,100);
  345. brushPrice = accSub(brushPrice,couponPrice); //刷头减去优惠券
  346. if(brushPrice <= 0){
  347. brushPrice = 0;
  348. }
  349. price = accAdd(brushPrice,otherPrice);
  350. }
  351. }else{
  352. if($(".my-picker input[name=radio]:checked").attr("zhekou")==2){
  353. price = accMul($(".count_price").text(),$(".my-picker input[name=radio]:checked").attr("val"));
  354. // price =parseInt($(".count_price").text()*$(".my-picker input[name=radio]:checked").attr("val"));
  355. $(".btn-youhuiquan span,#coupon-val").text("-¥"+accSub($(".count_price").text(),price)); //减去折扣优惠金额赋值
  356. }else{
  357. price = accSub($(".count_price").text(),$(".my-picker input[name=radio]:checked").attr("val"));
  358. }
  359. }
  360. if(price <= 0) {
  361. price = 0.0; //判断商品价格减去现金券价格若<0 则显示0
  362. }
  363. $(".all_price").text(price);
  364. var postage = 0;
  365. if(price<30){
  366. $(".sales_postage").text(10);
  367. postage = 10;
  368. }else{
  369. $(".sales_postage").text(0);
  370. }
  371. price = accAdd(price,postage);
  372. price=accDiv(fullSub(accMul(price,100)),100);
  373. $(".pay_price").text(price);
  374. $("#coupon-name").parent().parent().show();
  375. } else {
  376. yhq_id = '';
  377. $(".btn-youhuiquan").removeAttr("couponid");
  378. $(".btn-youhuiquan span").text("不使用现金券");
  379. $(".all_price").text(payTotal);
  380. var salesPostage = $(".count_price").text();
  381. if(salesPostage < 30 ){
  382. $(".sales_postage").text(10);
  383. salesPostage += 10;
  384. }else{
  385. $(".sales_postage").text(0);
  386. }
  387. price=accDiv(fullSub(payTotal),100);
  388. $(".pay_price").text(parseFloat(price));
  389. $("#coupon-name").parent().parent().hide();
  390. }
  391. $("#coupon-name").text($(".my-picker input[name=radio]:checked").attr("couponname"));
  392. $(".my-picker").removeClass("active"); //隐藏弹窗
  393. $(".mui-backdrop").remove(); //移除遮罩层
  394. });
  395. //单选事件
  396. $(document).on('tap', '.my-picker .my-table-view-cell', function() {
  397. $(this).find("input[name=radio]").prop("checked", true);
  398. $(this).css("opacity", "1");
  399. $(this).siblings().css("opacity", ".5");
  400. $(".my-btn-user-know").removeAttr("disabled").addClass("active");
  401. });
  402. //关闭弹窗
  403. $(document).on('tap', '.icon-guanbi', function() {
  404. $(".mui-backdrop").remove(); //移除遮罩层
  405. $(".my-picker").removeClass("active"); //隐藏弹窗
  406. });
  407. // 获取微信共享地址
  408. $(document).on('tap', '.btn-add-address,#user-address-div', function() {
  409. editAddrV1(
  410. function(res) {
  411. // 用户成功拉出地址
  412. var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo;
  413. wechatAddr.status = true;
  414. wechatAddr.detailInfo = address;
  415. wechatAddr.postalCode = res.postalCode;
  416. wechatAddr.userName = res.userName;
  417. wechatAddr.userTel = res.telNumber;
  418. wechatAddr.nationalCode = res.nationalCode;
  419. $(".btn-add-address").hide();
  420. $("#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();
  421. },
  422. function() {
  423. if($('#user-address-div').html() != null && $('#user-address-div').html() != '') {
  424. wechatAddr.status = true;
  425. } else {
  426. wechatAddr.status = false;
  427. // 用户取消拉出地址
  428. mui.alert("您没有选择收货地址!");
  429. }
  430. }
  431. );
  432. });
  433. //满减活动
  434. function fullSub(a) {
  435. var time=new Date(),sum=0;
  436. if(full_sb!=''){
  437. var beginDate = parseDate(full_sb.beginDate,"yyyy-MM-dd hh:mm:ss");
  438. var endDate = parseDate(full_sb.endDate,"yyyy-MM-dd hh:mm:ss");
  439. var ispreferential = false;
  440. if(time>beginDate && time<endDate){
  441. $.each(full_sb.salesActivitiesList, function() {
  442. if(a>=this.salesActivitiesFull && sum==0){
  443. sum=a-this.salesActivitiesReduction;
  444. $("#full-sub-name").text(this.salesActivitiesName);
  445. $("#full-sub-count").text(accDiv(this.salesActivitiesReduction,100));
  446. $("#full-sub-name").parent().parent().show();
  447. ispreferential = true;
  448. return false;
  449. }
  450. });
  451. if(ispreferential){
  452. $("#ul-youhuiquan").hide();
  453. }
  454. if(sum == 0){
  455. return a;
  456. }else{
  457. return sum;
  458. }
  459. }else{
  460. return a;
  461. }
  462. }
  463. }
  464. // 去支付
  465. $(document).on('tap', '#go-pay', function() {
  466. var remark = $("#textarea").val();
  467. var ch_en_num = /^[A-Za-z0-9 _\[\]\【\】\{\}\{\}\(\)\(\)\《\》\<\>\,\,\.\。\、\!\!\~\·\@\#\¥\$\%\^\…\&\—\:\:\;\;\‘\’\'\'\"\"\“\”\?\?\-\=\|\*\+\-\u4e00-\u9fa5]{0,100}$/;
  468. if(ch_en_num.test(remark)) {
  469. //console.log("备注验证通过")
  470. } else {
  471. mui.alert("备注格式错误!仅支持中/英文,数字,普通符号");
  472. return false;
  473. }
  474. if(wechatAddr.status) {
  475. if($('#user-address-div').html() == null || $('#user-address-div').html() == '') {
  476. wechatAddr.status = false;
  477. mui.toast("请选择收货信息!");
  478. return ;
  479. }
  480. if(isPay) {
  481. isPay = false; // 锁定请求按钮
  482. /* 组装数据 */
  483. var dataArgs = {
  484. "orderAddressInfo": wechatAddr.detailInfo,
  485. "orderAddressPostNum": wechatAddr.postalCode,
  486. "orderAddressMoblie": wechatAddr.userTel,
  487. "orderAddressName": wechatAddr.userName,
  488. "cartIdStr": cartIdStr
  489. };
  490. if(yhq_id != '') {
  491. dataArgs["couponId"] = yhq_id;
  492. }
  493. if(remark != '') {
  494. dataArgs["orderUserRemark"] = remark;
  495. }
  496. dataArgs["isCustomize"] = 1;
  497. dataArgs["channelType"] = channelType;
  498. dataArgs["channelId"] = channelId;
  499. $.ajax(base_path + '/wechat/order/pay', { // 提交订单,准备支付
  500. data: dataArgs,
  501. dataType: 'json',
  502. type: 'post',
  503. xhrFields: {
  504. withCredentials: true
  505. },
  506. crossDomain: true,
  507. timeout: 15000,
  508. success: function(dt) {
  509. // layer.closeAll();
  510. //mui.alert(dt.resultCode=="500");
  511. if(dt.resultCode == "500") {
  512. mui.alert(dt.message);
  513. isPay = true;
  514. return;
  515. };
  516. if(dt.data.info == "isOK") {
  517. location.href = 'pay-win.html?orderId=' + dt.data.orderId + "&dates=" + new Date().getTime()
  518. return;
  519. };
  520. if(dt.status) {
  521. var str = dt.data.info;
  522. var obj = JSON.parse("{" + str + "}");
  523. WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) {
  524. if(res.err_msg == 'get_brand_wcpay_request:ok') {
  525. $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {
  526. data: {
  527. "orderId": dt.data.orderId
  528. },
  529. dataType: 'json',
  530. xhrFields: {
  531. withCredentials: true
  532. },
  533. crossDomain: true,
  534. type: 'get',
  535. timeout: 15000,
  536. success: function(dataobj) {
  537. if(dataobj.isRedirect) {
  538. location.href = dataobj.redirectURL;
  539. } else {
  540. if(dataobj.status == true) { // 支付成功
  541. location.href = "pay-win.html?orderId=" + dataobj.data + "&dates=" + new Date().getTime();
  542. } else {
  543. location.href = "order-details.html?orderId=" + dataobj.data + "&dates=" + new Date().getTime(); // 前往订单详情
  544. }
  545. }
  546. },
  547. error: function(xhr, type, errorThrown) {
  548. console.log(xhr);
  549. }
  550. });
  551. } else {
  552. isPay = true;
  553. mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!", function() {
  554. location.href = "order-details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  555. });
  556. }
  557. });
  558. } else {
  559. isPay = true;
  560. mui.alert(dt.message);
  561. location.href = "order-details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
  562. }
  563. },
  564. error: function(xhr, type, errorThrown) {
  565. isPay = true;
  566. // layer.closeAll();
  567. mui.alert("您的网络异常,请刷新重试!");
  568. return;
  569. }
  570. });
  571. } else {
  572. mui.alert("正在请求支付中~~请稍后!");
  573. return;
  574. }
  575. } else {
  576. mui.alert("请选择收货地址!");
  577. return;
  578. }
  579. });
  580. </script>
  581. </body>
  582. </html>