<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=8"> <meta http-equiv="Cache" content="no-cache"> <title>结算</title> <link rel="stylesheet" type="text/css" href="css/mui.min.css" /> <link rel="stylesheet" type="text/css" href="css/iconfont.css" /> <link rel="stylesheet" type="text/css" href="css/main.css" /> <script type="text/javascript"> // 屏蔽分享 window.hiddenAllWechatMenu = true; </script> <style> .mui-table-view-cell>a:not(.mui-btn) {margin-left: -12px;} .no-after:after,.no-line:after{display: none;} .mui-table-view-cell.no-line{padding: 7px;} .add_gwc{display: block;width: 100%;} .mui-h6{margin-right: 6px;} .center{float: right;margin-right: 7px;} </style> </head> <body> <div class="mui-content" style="padding-bottom: 56px;"> <div class="address-cantainner"> <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed"> <li class="mui-table-view-cell"> <div class="mui-table"> <div class="mui-table-cell mui-col-xs-12 table-middle btn-add-address"> <div class="add-address"><span class="iconfont icon-jia"></span>添加收货地址</div> </div> <div id="user-address-div" style="display: none;"> </div> </div> </li> </ul> </div> <div class="clearing-box"> <ul class="mui-table-view mui-table-view-striped my-grid-view-no mui-table-view-condensed shopping-cart-list"> </ul> <!--<div class="mui-content-padded mui-text-right">合计:<span class="pro-price">¥<span class="count_price">0.0</span></span> </div>--> <ul class="mui-table-view no-after"> <li class="mui-table-view-cell" id="ul-youhuiquan" style="padding-left:7px;display: none;"> <a class="mui-navigate-right btn-youhuiquan"> 优惠券<span class="mui-pull-right cl-red">未选择优惠券</span> </a> </li> <!--<li class="mui-table-view-cell " id="" style="padding-left:7px;"> <a class=" "> 总价<span class="mui-pull-right cl-red ">¥<span class="all_price"></span></span> </a> </li> <li class="mui-table-view-cell" id="" style="padding-left:7px;"> <a class=" "> 邮费 <span style=" font-size: 12px;color: #8f8f94;">(总价满30元包邮)</span><span class="mui-pull-right cl-red"> ¥<span class="sales_postage"></span> </span> </a> </li>--> <li class="mui-table-view-cell" style="padding-left:3px;"> <div class="mui-input-row"> <label class="lbl-remarks">订单备注</label> <input class="ipt-remarks" id="textarea" type="text" placeholder="选填:您对订单有特殊要求,可以在此备注"> </div> </li> <li class="mui-table-view-cell no-line" style="padding-left:7px;"> <a> <span class="mui-h6">商品金额</span><span class="mui-pull-right"> <span class="mui-h6">¥<span class="count_price">0.0</span></span> </span> </a> </li> <li class="mui-table-view-cell no-line" style="padding-left:7px;display: none;"> <a> <span class="mui-h6" id="coupon-name"></span><span class="mui-pull-right"> <span class="mui-h6" id="coupon-val"></span> </span> </a> </li> <li class="mui-table-view-cell no-line" style="padding-left:7px;display: none;"> <a> <span class="mui-h6" id="full-sub-name"></span><span class="mui-pull-right"> <span class="mui-h6">- ¥<span id="full-sub-count">0</span></span> </span> </a> </li> <li class="mui-table-view-cell no-line" style="padding-left:7px;"> <a> <span class="mui-h6">邮费(满30包邮)</span><span class="mui-pull-right"> <span class="mui-h6">¥ <span class="sales_postage">0.0</span></span> </span> </a> </li> <li class="mui-table-view-cell no-line" style="padding-left:7px;"> <span class="mui-pull-right">订单合计:<span class="count_price_box">¥<span class="pay_price">0.0</span></span></span> </li> </ul> </div> <div class="buy-footer1"> <table class="tb-clearing"> <tr> <!--<td class="quanxuan"> 共<span id="pro-count" class="cl-red">0</span>件商品 </td> <td class="mui-text-center">需支付:<span class="count_price_box">¥<span class="pay_price">0.0</span></span> </td>--> <td> <a id="go-pay" class="mui-btn mui-pull-right add_gwc go-clearing">立即支付</a> </td> </tr> </table> </div> </div> <div class="loading covers"> <div class="loading-bj"></div> <p>正在加载...</p> </div> <script src="js/mui.min.js"></script> <script src="js/jquery-2.1.1.min.js"></script> <script src="js/main.js"></script> <script src="js/wechat-utils-1.0.js"></script> <script> window.addEventListener('pageshow', function(e) { // 通过persisted属性判断是否存在 BF Cache if(e.persisted) { location.reload(); } }); var userIntegral = 0; // 用户可用积分 var meonyProportion = 0; // 兑换比例:1个积分=?分钱 var payTotal = 0.0; // 支付总金额 任何地方不允许更改 payTotal var userInputIntegral = 0; // 抵扣积分 var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求 var cartIdStr = ""; // 购物车ID var usePayMoney = 0; var ipt_balance = 0; var yhq_val = 0; var used_balance = 0; var yhq_type = 1; var yhq_id = ''; var full_sb=''; var orderItem; //获取订单项信息 var channelType = getParam("channelType"); //渠道类型 var channelId = getParam("channelId"); //渠道id if(channelType == null || channelId == null ){ channelType = 0; channelId=0; } if(channelType > 0 || channelId>0){ location.href = 'channel-clearing.html?channelType='+channelType+'&channelId='+channelId; //跳转结算页面 } var wechatAddr = new Object(); mui.ready(function() { var parameter = {}; //ajax参数json集合 var cartidList = ''; if(!window.sessionStorage) { mui.alert("您的浏览器不支持sessionStorage"); } else { //读取上一个页面带过来的sessionStorage pay_data = JSON.parse(sessionStorage.getItem('pay_data')); if(pay_data != null) { cartidList = pay_data.text[0]; //购物项id集合 parameter["cartIds"] = cartidList; parameter["isCustomize"] = 1; parameter["channelType"] = channelType; parameter["channelId"] = channelId; $.ajax(base_path + '/wechat/order/payBefore', { data: parameter, dataType: 'json', type: 'get', xhrFields: { withCredentials: true }, crossDomain: true, timeout: 15000, success: function(dt) { if(dt.isRedirect) { location.href = dt.redirectURL; } else { if(dt.status == true) { // 购物项遍历 full_sb=dt.data.activityDate; orderItem = dt.data.cartItems; //订单项信息 var liNote = ""; var yhq_str = ""; if(dt.data.couponItems!=null && typeof(dt.data.couponItems)!=undefined && dt.data.couponItems.length > 0 && channelType==0 && channelId ==0) { $("#ul-youhuiquan").show(); var str = ''; mui.each(dt.data.couponItems, function() { var couponReduce = this.couponReduce,val=''; if(this.couponType==2){ val=(couponReduce/10).toFixed(1)+"折"; }else{ val='¥' + ((couponReduce) / 100).toFixed(2); } 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 + '" couponname="'+this.couponName+'" couponid="' + this.couponItemId + '" couponType="' + this.couponId + '" zhekou="'+this.couponType+'" couponIsNewPeople="'+ this.couponIsNewPeople +'"/></div></div></li>'; }); 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>'; $("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>'); } //展示订单项 mui.each(orderItem, function(index) { var num = this.cartNum; var total = (num * this.productPrice / 100).toFixed(2); //购物车小计,单位分,保留两位小数 var productId = this.cartProductId; 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>'; }); var $productListUl = $(".shopping-cart-list"); $productListUl.empty(); $productListUl.append(liNote); // 保存数据 payTotal = dt.data.payTotal; // 支付金额,单位分 cartIdStr = dt.data.cartId; // 购物车ID $(".count_price").text(accDiv(payTotal,100)); //计算价格 paymoney(cartIdStr); //默认自己拉出地址 if(dt.data.addressInfo != undefined && dt.data.addressInfo != null) { $(".btn-add-address").hide(); $("#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(); //给微信参数赋值 wechatAddr.status = true; wechatAddr.detailInfo = dt.data.addressInfo.salesAddressInfo; wechatAddr.userName = dt.data.addressInfo.salesAddressName; wechatAddr.userTel = dt.data.addressInfo.salesAddressTel; wechatAddr.postalCode = dt.data.addressInfo.salesAddressPostnum; }else{ wechatAddr.status = false; } $(".loading").hide().css("opacity", "0"); //隐藏(正在加载...) } else { mui.alert("获取数据失败!", function() { location.href = "shopping-cart.html"; }); } } }, error: function(xhr, type, errorThrown) { console.log(xhr); mui.alert("获取数据失败,网络错误!") } }); } else { mui.alert("sessionStorage异常!", function() { location.href = "index.html"; }) } } }); //callback为用户点击蒙版时自动执行的回调; var mask = mui.createMask(function() { $(".my-picker").removeClass("active"); //隐藏弹窗 }); //优惠券弹窗 $(document).on('tap', '.btn-youhuiquan', function() { mask.show(); if($(".my-picker").length > 0) { $(".my-picker").addClass("active"); } }); //确认使用 $(document).on('tap', '.my-btn-user-know', function() { paymoney(); if(typeof($(".my-picker input[name=radio]:checked").attr("couponid")) != "undefined") { $(".btn-youhuiquan").attr("couponid", $(".my-picker input[name=radio]:checked").attr("couponid")); yhq_id = $(".my-picker input[name=radio]:checked").attr("couponid"); }else{ yhq_id = ''; $(".btn-youhuiquan").removeAttr("couponid"); $(".btn-youhuiquan span").text("不使用现金券"); $("#coupon-name").parent().parent().hide(); } $(".my-picker").removeClass("active"); //隐藏弹窗 $(".mui-backdrop").remove(); //移除遮罩层 }); //单选事件 $(document).on('tap', '.my-picker .my-table-view-cell', function() { $(this).find("input[name=radio]").prop("checked", true); $(this).css("opacity", "1"); $(this).siblings().css("opacity", ".5"); $(".my-btn-user-know").removeAttr("disabled").addClass("active"); }); //关闭弹窗 $(document).on('tap', '.icon-guanbi', function() { $(".mui-backdrop").remove(); //移除遮罩层 $(".my-picker").removeClass("active"); //隐藏弹窗 }); // 获取微信共享地址 $(document).on('tap', '.btn-add-address,#user-address-div', function() { editAddrV1( function(res) { // 用户成功拉出地址 var address = res.provinceName + "-" + res.cityName + "-" + res.countryName + "-" + res.detailInfo; wechatAddr.status = true; wechatAddr.detailInfo = address; wechatAddr.postalCode = res.postalCode; wechatAddr.userName = res.userName; wechatAddr.userTel = res.telNumber; wechatAddr.nationalCode = res.nationalCode; $(".btn-add-address").hide(); $("#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(); }, function() { if($('#user-address-div').html() != null && $('#user-address-div').html() != '') { wechatAddr.status = true; } else { wechatAddr.status = false; // 用户取消拉出地址 mui.alert("您没有选择收货地址!"); } } ); }); //满减活动 function fullSub(a) { var time=new Date(),sum=0; if(full_sb!=''){ var beginDate = parseDate(full_sb.beginDate,"yyyy-MM-dd hh:mm:ss"); var endDate = parseDate(full_sb.endDate,"yyyy-MM-dd hh:mm:ss"); var ispreferential = false; if(time>beginDate && time<endDate){ $.each(full_sb.salesActivitiesList, function() { if(a>=this.salesActivitiesFull && sum==0){ if(this.salesActivitiesId == 10){ var rNum = 0; var price = 0; var couponPrice = 0; $('.shopping-cart-list').find('.mui-table').each(function(){ var colorId = $(this).attr('colorid'); var onceNum = parseInt($(this).attr('num')); var productprice = $(this).attr('productprice'); if(colorId == 60 || colorId == 61 || colorId == 62 || colorId == 63){ //60,61,62,63 rNum += onceNum; price += accMul(onceNum,productprice) } }) if(parseInt(rNum) == 1){ couponPrice = 9000; }else if(parseInt(rNum) >= 2){ couponPrice = price couponPrice -= 29900 couponPrice = accMul(couponPrice,0.35); couponPrice += 9000 } sum=a-couponPrice; $("#full-sub-name").text(this.salesActivitiesName); $("#full-sub-count").text(accDiv(couponPrice,100)); $("#full-sub-name").parent().parent().show(); ispreferential = false; return false; }else{ sum=a-this.salesActivitiesReduction; $("#full-sub-name").text(this.salesActivitiesName); $("#full-sub-count").text(accDiv(this.salesActivitiesReduction,100)); $("#full-sub-name").parent().parent().show(); ispreferential = true; return false; } } }); if(ispreferential){ $("#ul-youhuiquan").hide(); } if(sum == 0){ return a; }else{ return sum; } }else{ return a; } } } // 去支付 $(document).on('tap', '#go-pay', function() { var remark = $("#textarea").val(); var ch_en_num = /^[A-Za-z0-9 _\[\]\【\】\{\}\{\}\(\)\(\)\《\》\<\>\,\,\.\。\、\!\!\~\·\@\#\¥\$\%\^\…\&\—\:\:\;\;\‘\’\'\'\"\"\“\”\?\?\-\=\|\*\+\-\u4e00-\u9fa5]{0,100}$/; if(ch_en_num.test(remark)) { //console.log("备注验证通过") } else { mui.alert("备注格式错误!仅支持中/英文,数字,普通符号"); return false; } if(wechatAddr.status) { if($('#user-address-div').html() == null || $('#user-address-div').html() == '') { wechatAddr.status = false; mui.toast("请选择收货信息!"); return ; } if(isPay) { isPay = false; // 锁定请求按钮 /* 组装数据 */ var dataArgs = { "orderAddressInfo": wechatAddr.detailInfo, "orderAddressPostNum": wechatAddr.postalCode, "orderAddressMoblie": wechatAddr.userTel, "orderAddressName": wechatAddr.userName, "cartIdStr": cartIdStr }; if(yhq_id != '') { dataArgs["couponId"] = yhq_id; } if(remark != '') { dataArgs["orderUserRemark"] = remark; } dataArgs["isCustomize"] = 1; dataArgs["channelType"] = channelType; dataArgs["channelId"] = channelId; $.ajax(base_path + '/wechat/order/pay', { // 提交订单,准备支付 data: dataArgs, dataType: 'json', type: 'post', xhrFields: { withCredentials: true }, crossDomain: true, timeout: 15000, success: function(dt) { // layer.closeAll(); //mui.alert(dt.resultCode=="500"); if(dt.resultCode == "500") { isPay = true; var newOrderId = dt.data.orderId; if(newOrderId != null && newOrderId != "" && typeof(newOrderId) != "undefined"){ mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!", function() { location.href = "order-details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情 }); return; } mui.alert("支付失败,"+ dt.message, function() { location.href = "shopping-cart.html"; // 前往订单详情 }); return; }; if(dt.data.info == "isOK") { location.href = 'pay-win.html?orderId=' + dt.data.orderId + "&dates=" + new Date().getTime() return; }; if(dt.status) { var str = dt.data.info; var obj = JSON.parse("{" + str + "}"); WeixinJSBridge.invoke('getBrandWCPayRequest', obj, function(res) { if(res.err_msg == 'get_brand_wcpay_request:ok') { $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), { data: { "orderId": dt.data.orderId }, dataType: 'json', xhrFields: { withCredentials: true }, crossDomain: true, type: 'get', timeout: 15000, success: function(dataobj) { if(dataobj.isRedirect) { location.href = dataobj.redirectURL; } else { if(dataobj.status == true) { // 支付成功 location.href = "pay-win.html?orderId=" + dataobj.data + "&dates=" + new Date().getTime(); } else { location.href = "order-details.html?orderId=" + dataobj.data + "&dates=" + new Date().getTime(); // 前往订单详情 } } }, error: function(xhr, type, errorThrown) { console.log(xhr); } }); } else { isPay = true; mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!", function() { location.href = "order-details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情 }); } }); } else { isPay = true; mui.alert(dt.message); location.href = "order-details.html?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情 } }, error: function(xhr, type, errorThrown) { isPay = true; // layer.closeAll(); mui.alert("您的网络异常,请刷新重试!"); return; } }); } else { mui.alert("正在请求支付中~~请稍后!"); return; } } else { mui.alert("请选择收货地址!"); return; } }); /** * 所有优惠活动都经过此方法计算 */ function paymoney(){ var allAmount = payTotal; //总金额(单位为分) ,任何地方不允许更改 payTotal //遍历订单项,获取所需要的金额 var toothbrush = 0, toothbrush_head = 0; mui.each(orderItem, function(index) { var brPrice = this.productPrice; //优惠券金额 var num = this.cartNum; var total = accMul(num,brPrice); switch (this.productType){ case 100: //牙刷 toothbrush = accAdd(toothbrush,total); break; case 101: //刷头类 toothbrush_head = accAdd(toothbrush_head,total); break; default: break; } }); //计算优惠券 - 开始 var coupon_reduce = 0; //优惠金额 if(typeof($(".my-picker input[name=radio]:checked").attr("couponid")) != "undefined") { var item_amount = allAmount; // 临时总金额 var couponIsNewPeople = $(".my-picker input[name=radio]:checked").attr("couponIsNewPeople"); var couponType = $(".my-picker input[name=radio]:checked").attr("couponType"); couponType = parseInt(couponType); /*只减去刷头的钱*/ switch (couponType){ case 20000: //刷头抵扣卷 var brushCouponPrice = 0; //刷头优惠总金额 var couponPrice = $(".my-picker input[name=radio]:checked").attr("val"); //优惠券金额 mui.each(orderItem,function(index){ if(this.productType == 101 && (this.colorToothType == 6 || this.colorToothType == 7)){ //刷头类 牙刷分类 5:刷头(lips) 6:刷头(儿童) 7:刷头(北欧+轻奢) 8:(套装) if(brushCouponPrice == 0 || brushCouponPrice < this.productPrice){ brushCouponPrice = this.productPrice; } } }); allAmount = accSub(allAmount,brushCouponPrice); //刷头减去优惠券 coupon_reduce = brushCouponPrice; break; case 20004: //lips刷头抵扣卷 var brushCouponPrice = 0; //刷头优惠总金额 var couponPrice = $(".my-picker input[name=radio]:checked").attr("val"); //优惠券金额 mui.each(orderItem,function(index){ if(this.productType == 101 && (this.colorToothType == 5)){ //刷头类 牙刷分类 5:刷头(lips) 6:刷头(儿童) 7:刷头(北欧+轻奢) 8:(套装) if(brushCouponPrice == 0 || brushCouponPrice < this.productPrice){ brushCouponPrice = this.productPrice; } } }); allAmount = accSub(allAmount,brushCouponPrice); //刷头减去优惠券 coupon_reduce = brushCouponPrice; break; case 40000: var brushPrice = 0; //刷头总金额 var otherPrice = 0;//其他商品总金额 var couponPrice = $(".my-picker input[name=radio]:checked").attr("val"); //优惠券金额 mui.each(orderItem,function(index){ if(this.productType == 101 && (this.colorToothType == 6 || this.colorToothType == 7)){ brushPrice = accAdd(brushPrice,this.productPrice*this.cartNum); }else{ otherPrice = accAdd(otherPrice,this.productPrice*this.cartNum); } }); brushPrice = accSub(brushPrice,couponPrice); //刷头减去优惠券 if(brushPrice <= 0){ brushPrice = 0; } allAmount = accAdd(brushPrice,otherPrice); coupon_reduce = 6000; break; case 110000: //上朵年货节-电动牙刷8折券 var once_disc = $(".my-picker input[name=radio]:checked").attr("val"); once_disc = accDiv(once_disc,100); var reduce_disc = accSub(1,once_disc); coupon_reduce = accMul(toothbrush,reduce_disc); //减去的金额 allAmount = accSub(allAmount,coupon_reduce); break; case 110001: //上朵年货节-刷头9折券 case 110002: //上朵年货节-刷头8.5折券 case 110003: //上朵年货节-刷头8折券 case 110004: //上朵年货节-刷头7.5折券 var once_disc = $(".my-picker input[name=radio]:checked").attr("val"); once_disc = accDiv(once_disc,100); var reduce_disc = accSub(1,once_disc); coupon_reduce = accMul(toothbrush_head,reduce_disc); //减去的金额 allAmount = accSub(allAmount,coupon_reduce); break; default: if($(".my-picker input[name=radio]:checked").attr("zhekou")==2){ //折扣 var once_disc = $(".my-picker input[name=radio]:checked").attr("val"); once_disc = accDiv(once_disc,100); allAmount = accMul(allAmount,once_disc); coupon_reduce = accAdd(item_amount,-allAmount); }else{ //满减 coupon_reduce = $(".my-picker input[name=radio]:checked").attr("val") //减少金额 allAmount = accSub(allAmount,coupon_reduce); } break } if(allAmount <= 0) { allAmount = 0.0; //判断商品价格减去现金券价格若<0 则显示0 } coupon_reduce = accDiv(coupon_reduce,100); $(".btn-youhuiquan span,#coupon-val").text("-¥" + coupon_reduce); $("#coupon-name").text($(".my-picker input[name=radio]:checked").attr("couponname")); $("#coupon-name").parent().parent().show(); } //计算优惠券 - 结束 //满减 allAmount = fullSub(allAmount); //计算邮费 var oldTotal = accDiv(fullSub(allAmount),100); if(accDiv(fullSub(allAmount),100) < 30){ $(".sales_postage").text(10); oldTotal = accAdd(oldTotal,10); }else{ $(".sales_postage").text(0); } $(".pay_price,.all_price").text(oldTotal); } </script> </body> </html>