channel-clearing.html 27 KB

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