clearing.html 28 KB

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