| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904 | <!DOCTYPE html><html><head>	<meta charset="utf-8">	<title></title>	<meta name="Expires" content="0">	<meta name="Cache-Control" content="no-store, no-cache, must-revalidate">	<meta name="Cache-Control" content="post-check=0, pre-check=0">	<meta name="Pragma" content="no-cache">	<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">    <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/style.css" />	<link rel="stylesheet" type="text/css" href="css/clearing.css" />	<style type="text/css">		.buy-footer1:after{display: none;}	</style>	<script type="text/javascript">        // 屏蔽分享        window.hiddenAllWechatMenu = true;	</script></head><body style="background: #fff"><div class="loading-bg">	<div class="mui-loading">		<div class="mui-spinner">		</div>		  加载中...	</div></div><div class="mui-content" style="padding-bottom: 100px !important;background: #FFF;">	<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-->					<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 class="mui-table-cell mui-col-xs-1 mui-text-right table-middle btn-add-address">						<p><span class="mui-icon mui-icon-arrowright"></span></p>					</div>					<!--选择微信地址后显示的div-->					<div id="user-address-div" style="display: none;">						<!--<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>收货人:林笑笑 <span class="mui-pull-right">16899996678</span></div>                        <p>收货地址:广东省深圳市福田区莲花街道深圳特区 报业大厦12b</p>                    </div>-->					</div>				</div>			</li>		</ul>	</div>	<!--<ul class="mui-table-view more">-->		<!--<li class="mui-table-view-cell line-color" style="padding:20px 10px;">-->			<!--<div style="display: none;" id="user-address-div"></div>-->			<!--<a class="check_address" id="open-wechat-addres-a">-->				<!--<span>请选择收货地址!</span><span class="mui-icon mui-icon-forward icon-r-c"></span>-->			<!--</a>-->		<!--</li>-->	<!--</ul>-->	<ul class="mui-table-view mui-table-view-chevron my-grid-view-no" id="products-list-ul">		<li class="mui-table-view-cell mui-media" id="load-li">			  加载产品信息中...		</li>	</ul>	<ul class="mui-table-view my-yhq-tab">		<li class="mui-table-view-cell forward" style="margin: 0">			<a href="#forward" class="mui-navigate-right">				<div class="mui-media-body">					优惠券<span class="yhq-right"><span class="cl-red" id="yhq_count" style="display: none;">0</span></span>				</div>			</a>		</li>		<div style="padding: 10px 15px 0 15px;display: none;">可用余额:<span class="cl-red" id="used_balance">¥0.00</span></div>		<li class="mui-table-view-cell pay_ipt_box" style="padding: 0;display: none;">			<div class="mui-input-group">				<div class="mui-input-row">					<label>输入使用金额:</label>					<input id="pay_ipt" type="number" placeholder="(如699)">				</div>			</div>		</li>		<li class="mui-table-view-cell" style="padding: 0;margin: 0;">			<div class="mui-input-group">				<div class="mui-input-row">					<label>订单备注</label>					<input style="font-size: 12px" type="text" placeholder="(选填:特殊要求,可以在此备注)" id="textarea">				</div>  			</div>		</li>		<li class="mui-table-view-cell" style="padding: 0;margin: 0;display: none;">			<div class="mui-input-group">				<div class="mui-input-row">					<label>商品金额:</label>					<input style="font-size: 12px;text-align: right;" type="text" readonly="readonly" placeholder="(选填:订单要求,可以在此备注)" id="total">				</div>			</div>		</li>		<li class="mui-table-view-cell" id="vipSub" style="display: none;">			<div><span>VIP专享(1年滤芯套装)</span><span class="mui-pull-right"><span id="vip_price">- ¥0</span></span></div>		</li>		<li class="mui-table-view-cell" id="accSub">			<div><span id="yhq_name"></span><span class="mui-pull-right"><span id="yhq_price"></span></span></div>			<div>账户余额:<span class="mui-pull-right cl-red">- ¥<span id="used_buy">0</span></span></div>		</li>		<li class="mui-table-view-cell" id="user2000" style="display: none;">			<div><span>全场购满2000元</span><span class="mui-pull-right"><span id="user_2000">赠Aiberle电动牙刷1支</span></span></div>		</li>		<li class="mui-table-view-cell" id="user3000" style="display: none;">			<div><span>全场购满3000元</span><span class="mui-pull-right">- ¥<span id="user_3000">100</span></span></div>		</li>	</ul>	<!--<div class="clearing-count" style="text-align: right;">订单合计:<font class="cl-red">¥</font><span class="cl-red" id="user-pay-money-span">加载中...</span></div>-->	<div class="buy-footer1"><table class="tb-clearing"><tbody><tr><td>共<span><span id="pro-count">0</span>件</span></td><td class="mui-text-center">合计:<span class="count_price_box">¥<span class="cl-red" id="user-pay-money-span">0.0</span></span></td><td><a id="btn-weixin-pay" class="mui-btn mui-pull-right add_gwc btn-weixin-pay" style="min-width: 120px;">支付</a></td></tr></tbody></table></div>	<!--<div class="pay_weixin">		<button type="button" class="mui-btn mui-btn-success mui-btn-block btn-weixin-pay" id="btn-weixin-pay" style="border-radius: 0;background-color: #55c0dc;border-color: #55c0dc;">立即支付</button>	</div>--></div><div id="forward" class="mui-popover mui-popover-action mui-popover-bottom">	<div class="mui-input-group mui-table-view-radio my-popover ">	</div>	<ul class="mui-table-view">		<li class="mui-table-view-cell">			<a href="#forward"><b>确定</b></a>		</li>	</ul></div><div class="dhq-dalog">	<div>		<div class="titles">请选择免费兑换产品<p>(您有1张T1/T2滤芯兑换券)</p></div>		<div>			<form class="mui-input-group">				<div class="mui-input-row mui-radio mui-left">					<label>兑换T1滤芯</label>					<input name="radio2" type="radio" value="7"/>				</div>				<div class="mui-input-row mui-radio mui-left">					<label>兑换T2滤芯</label>					<input name="radio2" type="radio" value="8"/>				</div>			</form>		</div>		<div class="btn-boxs">			<button type="button" class="mui-btn nexts">下次兑换</button>			<button type="button" class="mui-btn enter">确认兑换</button>		</div>	</div></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/page/wechat-utils-1.0.js"></script><script src="js/page/layer.js"></script><script>    var userIntegral = 0; // 用户可用积分    var meonyProportion = 0; // 兑换比例:1个积分=?分钱    var payTotal = 0.0; // 支付总金额    var userInputIntegral = 0; // 抵扣积分    var isPay = true; // 是否在请求支付,false表示正在请求,true可以请求    var cartIdStr = ""; // 购物车ID    var pro_all_count=0;    var usePayMoney = 0;    var ipt_balance = 0;    var yhq_val = 0;    var used_balance = 0;    var yhq_type = 1;    var showIs = false;    var accVipSub=0;    var exchangeColorId='';    var t1=0,t2=0,all_t=0;    var user38Interests=2;    var isSpell=2;	//不能拼单    var orderId=getParam('orderId');    var isSpellstr='';    var productId='';    var colorId='';    								    mui.ready(function() {    	if(isSpell==1){			isSpellstr='&isSpell=1';										}        var name,value;        var str=location.href; //取得整个地址栏        var num=str.indexOf("?")        str=str.substr(num+1); //取得所有参数        var $productListUl = $("#products-list-ul");        $.ajax(base_path+'/order/payBefore?'+str, {            dataType: 'json',            type: 'POST',            timeout: 15000,            xhrFields: {				withCredentials: true			},			crossDomain: true,            success: function(dt) {                if(dt.status == true) {                    // 购物项遍历                    //console.log(dt)                    var liNote = "";                    var cNum = 0;                    user38Interests=dt.data.user38Interests;                    if(dt.data.balance == 0) {                        $(".pay_ipt_box").hide();                    } else {                        used_balance = accDiv(dt.data.balance, 100);                        $('#used_balance').html("¥ " + accDiv(dt.data.balance, 100));                    }                    var yhq_str = "";                    if(dt.data.couponItems.length == 0 || !dt.data.disable) {                        $(".forward").hide();$("#vipSub").hide();                    } else {                    	if(isSpell!=1){                        //如果购买商品只有饮水机滤芯,则不能使用优惠券						var c=0,flag=false;                        var btnArray = ['否', '是'];                        mui(dt.data.couponItems).each(function(index) {                            if(this.couponId==10000){                                c++;							}						});                        mui(dt.data.cartItems).each(function(index) {                            if(this.cartColorId==7){                                t1+=this.cartNum;                            }else if(this.cartColorId==8){                                t2+=this.cartNum;                            }else{                                all_t++;							}                        });                        if(c>0){                            if((t1==0 && t2==0) || all_t==0){                                $(".dhq-dalog").show();							}else{                                flag=true;							}                            $(document).on('tap', '.enter', function() {                                if($(".dhq-dalog input[type=radio]:checked").length>0){                                    flag=true;                                    exchangeColorId=$(".dhq-dalog input[type=radio]:checked").val();                                    $.ajax(base_path + '/cart/get_exchange?dates=' + new Date().getTime(), {                                        data: {                                            "couponId": 10000                                        },                                        dataType: 'json',                                        xhrFields: {                                            withCredentials: true                                        },                                        crossDomain: true,                                        type: 'post',                                        async:false,                                        timeout: 15000,                                        success: function(dts) {                                            console.log(dts);                                            //if(dts.status==true){                                            	if (dt.isRedirect) {                                            		location.href = dt.redirectURL;                                            	} else {											console.log("t1="+t1+",t2="+t2+",all_t="+all_t);                                            mui(dts.data).each(function(index) {                                                    if(exchangeColorId==this.colorId){                                                        if((((exchangeColorId==7 && t1==0) || (exchangeColorId==8 && t2==0)) && (all_t<=1) && ((t1+all_t)<=1 || (t2+all_t)<=1)) || (t1+t2==0) && all_t>0 || (((t1+all_t)==0 && t2<2) || ((t2+all_t)==0 && t1<2))){                                                            $productListUl.append('<li class="mui-table-view-cell mui-media dhq-last-add"><a><span class="mui-media-object mui-pull-left wh-100"> <img src="'+this.colorProductPic+'"></span><div class="mui-media-body" style="padding: 3% 0 3% 0;"><div class="wt-space gwc_tit">'+this.colorProductName+'</div><div><small class="mui-h6">'+this.colorName+'x1</small></div></div><div class="price_sp cl-gwc"  price="'+this.colorDiscount+'">¥'+accDiv(this.colorDiscount,100)+'</div></a></li>');														}else{                                                            yhq_val = $("#forward input[yhq_type=3]").val();                                                            if(yhq_val == undefined) {                                                                yhq_val = 0                                                            }else{                                                                $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));															}														}													}                                                });                                                }                                            //}                                        },                                        error: function(xhr, type, errorThrown) {                                            console.log(xhr);                                        }                                    });                                    $("#forward input[couponid=10000]").prop('checked',true);                                    var yhq_check=$("input[name=radio1]:checked");                                    yhq_val = yhq_check.val();                                    yhq_type = yhq_check.attr("yhq_type");                                    var yhq_id = yhq_check.attr("couponid");                                    if(yhq_val == undefined) {                                        yhq_val = 0                                    } else {                                        if(yhq_type == 3){                                        	if(yhq_id==10000){                                            if(yhq_val > (usePayMoney - ipt_balance)) {                                                yhq_check.removeAttr("checked");                                                yhq_val = 0;                                                mui.alert(' ', '当前优惠券不可用', function() {});                                            }                                            $("#yhq_name").html(yhq_check.prev().html());                                            $("#yhq_price").html("免费兑换1支T1或T2滤芯");                                            $("#accSub,#accSub>div:first-child").show();                                            if($(".dhq-last-add").length>0){                                                yhq_val = 0;                                            }                                            $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));                                           }                                        }                                    }                                    $(".dhq-dalog").hide();								}else{                                    console.log("请选择要兑换的滤芯");								}							});                            //下次兑换                            $(document).on('tap', '.nexts', function() {                                $("#forward input[couponid=10000]").removeAttr('checked').prop("disabled","disabled");                                $(".dhq-dalog").hide();                                flag=false;                                if(user38Interests==1){                                    console.log(usePayMoney>=2000 && usePayMoney<3000)                                    if(usePayMoney>=2000 && usePayMoney<3000){                                        $("#user2000").show();                                        $("#user-pay-money-span").html(usePayMoney);                                    }else if(usePayMoney>=3000){                                        $("#user-pay-money-span").html((usePayMoney-100));                                        $("#user2000,#user3000").show();                                    }else{                                        $("#user2000,#user3000").hide();                                        $("#user-pay-money-span").html(usePayMoney);                                    }                                }else{                                    $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));                                }                                console.log("899")							});                        }                        if (dt.data.disable) {                            mui(dt.data.couponItems).each(function(index) {                                var checked='';                                console.log(flag)                                if((this.couponId==10000 && flag) || this.couponId==10002){                                	                                    checked='checked';                                }                                yhq_str += '<div class="mui-input-row mui-radio"><label>' + this.couponName + '</label><input name="radio1" value="' + accDiv(this.couponReduce, 100) + '" type="radio" couponid='+this.couponId+' id="' + this.couponItemId + '" yhq_type="' + this.couponType + '" enough="'+accDiv(this.couponConsumeEnough, 100)+'" '+checked+'/></div>';                            });                            $(".my-popover").html(yhq_str + '<div class="mui-input-row mui-radio"><label>不使用优惠券</label><input name="radio1" value="1" type="radio"></div>');                            $("#yhq_count").html(dt.data.couponItems.length);                            if(t1==0 && t2==0){								$("#forward input[couponid=10001]").removeAttr('checked').prop("disabled","disabled");							}                        }                    }else{                    	$(".forward").hide();$("#vipSub").hide();                    	productId=dt.data.cartItems[0].cartProductId;                    	colorId=dt.data.cartItems[0].cartColorId;                    }                    }                                  for(let i = 0; i < dt.data.cartItems.length; i++) {                    	pro_all_count+=dt.data.cartItems[i].cartNum;                    	// 购物车小计,分--元                        let total = dt.data.cartItems[i].cartNum * dt.data.cartItems[i].productDiscount / 100;                         let pro_color = switchcolor(dt.data.cartItems[i].cartColorId);                        let colorImg = switchColorImg(dt.data.cartItems[i].cartColorId);                        let cartProductId = dt.data.cartItems[i].cartProductId;                        let colorId=dt.data.cartItems[i].cartColorId;                        let productDiscount = dt.data.cartItems[i].productDiscount;                            if(isSpell==1){                            	total = dt.data.cartItems[i].cartNum * dt.data.cartItems[i].colorSpellAmount / 100;                             	if(this.productIsSpell==2){                            		 productDiscount=dt.data.cartItems[i].colorSpellAmount;                            	}else{                            		 productDiscount=dt.data.cartItems[i].productDiscount;                            	}                            }                        total = total.toFixed(2); // 保留两位小数                            let num = dt.data.cartItems[i].cartNum;                        if (dt.data.cartItems[i].productDiscount / 100 == 3280) {                            liNote = liNote +                                "<li class='mui-table-view-cell mui-media'>" +                                "<a>" +                                "<span class='mui-media-object mui-pull-left wh-100'> <img src='" + dt.data.cartItems[i].colorImg + "'></span>" +                                "<div class='mui-media-body'  style='padding: 3% 0 3% 0;'>" +                                "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "</div>" +                                "<div><small class='mui-h6'>" + dt.data.cartItems[i].productColor + " x "+dt.data.cartItems[i].cartNum+"</small></div>"+                                "</div>" +                                "<div class='price_sp cl-gwc' id='product-" + cartProductId + "' price='" + productDiscount + "'>¥" + total + "</div>"+                                "</a>" +                                "</li>";                            cNum = cNum + num ;                            showIs = true;                        } else {                            liNote = liNote +                                "<li class='mui-table-view-cell mui-media'>" +                                "<a>" +                                "<span class='mui-media-object mui-pull-left wh-100'> <img src='" + dt.data.cartItems[i].colorImg + "'></span>" +                                "<div class='mui-media-body'  style='padding: 3% 0 3% 0;'>" +                                "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "</div>" +                                "<div><small class='mui-h6'>" + dt.data.cartItems[i].productColor + " x "+dt.data.cartItems[i].cartNum+"</small></div>"+                                "</div>" +                                "<div class='price_sp cl-gwc' id='product-" + cartProductId + "' price='" + productDiscount + "'>¥" + total + "</div>"+                                "</a>" +                                "</li>";                        }                        if(dt.data.cartItems[i].cartColorId==5 && dt.data.cartItems[i].cartProductId==38){                            accVipSub+=(100* dt.data.cartItems[i].cartNum);						}                    }                    if (showIs){                        liNote = liNote +                            "<li class='mui-table-view-cell mui-media'>" +                            "<a>" +                            "<span class='mui-media-object mui-pull-left wh-100'> <img src='//s.iamberry.com/watero/wechat/images/2C83538AC3039E693358_20161202182946_8118.jpg'></span>" +                            "<div class='mui-media-body'>" +                            "<div class='wt-space gwc_tit'>" +                            '赠送' + "<span id='giveNum'>" + cNum + '</span>' + '套三年滤芯' +                            "<span class='price_sp cl-gwc mui-pull-right' id='product-39' price='39'>¥" + 0 + "</span></div>" +                            "<small class='gwc_pp'>颜色:" + '无' + "</small>" +                            "</div>" +                            "</a>" +                            "</li>"                    }                    $productListUl.empty();                    $productListUl.append(liNote);                    dt.data.userIntegral = dt.data.userIntegral - 1;                    // 保存数据                    meonyProportion = dt.data.meonyProportion; // 兑换比例                    payTotal = dt.data.payTotal; // 支付金额,单位分                    userIntegral = dt.data.userIntegral; // 用户可用积分                    cartIdStr = dt.data.cartId; // 购物车ID                    // 替换数据                    usePayMoney = accDiv(dt.data.payTotal, 100);                    $("#total").val(usePayMoney.toFixed(2) + " 元");                    $("#user-integral-span").html(dt.data.userIntegral);                    if(dt.data.userIsVip==2 && isSpell!=1){                        $("#vip_price").text("- ¥"+(accVipSub).toFixed(2));                        $("#vipSub").show();                        usePayMoney-=accVipSub;					}                    if(user38Interests==1){                        if(usePayMoney>=2000 && usePayMoney<3000){                            $("#user2000").show();                            $("#user3000").hide();                            $("#user-pay-money-span").html(usePayMoney);                        }else if(usePayMoney>=3000){                            $("#user-pay-money-span").html((usePayMoney-100));                            $("#user2000,#user3000").show();                        }else{                            $("#user-pay-money-span").html(usePayMoney);                            $("#user2000,#user3000").hide();                        }                    }else{                        $("#user-pay-money-span").html(usePayMoney);                    }                    //默认自己拉出地址                    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;                    }                    var yhq_check=$("input[name=radio1]:checked");                    yhq_val = yhq_check.val();                    yhq_type = yhq_check.attr("yhq_type");                    enough=yhq_check.attr("enough");                    if(yhq_val == undefined) {                        yhq_val = 0                    } else {                        if(yhq_type == 1) {                								if(accDiv(payTotal, 100)>=enough){							if(yhq_val > usePayMoney) {								yhq_check.removeAttr("checked");								yhq_val = 0;								mui.alert(' ', '当前优惠券不可用', function() {});							}							$("#yhq_name").html(yhq_check.prev().html());							$("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));							$("#accSub,#accSub>div:first-child").show();							console.log(usePayMoney)							$("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));							$(".dhq-last-add").hide();							exchangeColorId='';						   }else{							   yhq_check.removeAttr("checked");								yhq_val = 0;								mui.alert(' ', '当前商品金额不满足使用条件', function() {});						   }						}else if(yhq_type == 3){                            if(yhq_val > (usePayMoney - ipt_balance)) {                                yhq_check.removeAttr("checked");                                yhq_val = 0;                                mui.alert(' ', '当前优惠券不可用', function() {});                            }                            $("#yhq_name").html(yhq_check.prev().html());                            $("#yhq_price").html("免费兑换1支T1或T2滤芯");                            $("#accSub,#accSub>div:first-child").show();                            console.log(yhq_val)                            if($(".dhq-last-add").length>0){                                yhq_val = 0;                            }                            console.log("998")                            if(user38Interests==1){                                if((usePayMoney - yhq_val - ipt_balance)>=2000 && (usePayMoney - yhq_val - ipt_balance)<3000){                                    $("#user2000").show();                                    $("#user3000").hide();                                    $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));                                }else if((usePayMoney - yhq_val - ipt_balance)>=3000){                                    $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance-100).toFixed(2));                                    $("#user2000,#user3000").show();                                }else{                                    $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));                                    $("#user2000,#user3000").hide();                                }                            }else{                                $("#user2000,#user3000").hide();                                $("#user-pay-money-span").html(usePayMoney);                            }                        }else {							yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_check.val(), usePayMoney) * 100) / 100);							$("#yhq_name").html(yhq_check.prev().html());							$("#yhq_price").html("- ¥"+yhq_val);							$("#accSub,#accSub>div:first-child").show();							$(".dhq-last-add").hide();							$("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));							exchangeColorId='';						}                    }                    $("#pro-count").text(pro_all_count);//总件数                } else {                    mui.alert(dt.message);                }            },            error: function(xhr, type, errorThrown) {                console.log(xhr);            }        });        // 获取微信共享地址        $(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("您没有选择收货地址!");                    }                }            );        });        // 积分数量改变时        mui('body').on('change', '#input-user-integral', function() {            var inputUserIntegral = $("#input-user-integral").val();            $.trim(inputUserIntegral);            var r = /^[1-9]+\d*$/;            if(!r.test(inputUserIntegral)) {                $("#input-user-integral").val(userInputIntegral);                return false;            }            inputUserIntegral = parseInt(inputUserIntegral);            if(inputUserIntegral > userIntegral) {                $("#input-user-integral").val(userInputIntegral);                return false;            }            if((inputUserIntegral * meonyProportion) > payTotal) {                $("#input-user-integral").val(userInputIntegral);                return false;            }            // 置换数据            userInputIntegral = inputUserIntegral;            var temp = (userInputIntegral * meonyProportion / 100).toFixed(2);            $("#integral-money-span").html(temp);            temp = ((payTotal - (userInputIntegral * meonyProportion)) / 100).toFixed(2);            $("#user-pay-money-span").html(temp);        });        //去支付        mui('body').on('tap', '.btn-weixin-pay', function() {            //if($("#forward input[yhq_type=3]").prop("checked") && (((t1+all_t)==0 && t2<=2) || ((t2+all_t)==0 && t1<=2) || ((t1<=1 && t2==0) || (t1==0 && t2<=1)))){             //   if($(".dhq-last-add").is(":visible")){            //        console.log(exchangeColorId)            //    }           // }            var yhq_id = $("input[name=radio1]:checked").attr('id');            if(yhq_id == undefined) {                yhq_id = "";            }            var remark = $("#textarea").val();            var pattern = new RegExp("[ `~!@#$^&*()=|{}':;'\\[\\]<>/?~!@#¥……&*()——|{}【】‘;:”“'、?]")            if(remark != "") {                $.trim(remark);                if(pattern.test(remark)) {                    mui.alert("请不要输入中文、字母、数字以外的特殊字符!");                    return;                }                if(!(remark.length >= 0 && remark.length <= 100)) {                    mui.alert("备注字数长度在0-100之间!");                    return;                }            }            if(wechatAddr.status) {                if(isPay) {                    isPay = false; // 锁定请求按钮                    layer.open({                        type: 2,                        shadeClose: false,                        content: "正在请求加载订单信息..."                    }); // 调用加载弹出层                    /* 组装数据 */                    var dataArgs = {                        "orderAddressInfo": wechatAddr.detailInfo,                        "orderAddressPostNum": wechatAddr.postalCode,                        "orderAddressMoblie": wechatAddr.userTel,                        "orderAddressName": wechatAddr.userName,                        "cartIdStr": cartIdStr,                        "orderIntegralNum": userInputIntegral,                        "orderUserRemark": remark,                        "couponId": yhq_id,                        "balancePayAmount": accMul(ipt_balance, 100)                    };//                  if($("#forward input[yhq_type=3]").prop("checked") && (((t1+all_t)==0 && t2<=2) || ((t2+all_t)==0 && t1<=2) || ((t1<=1 && t2==0) || (t1==0 && t2<=1)))){                        if($(".dhq-last-add").is(":visible")){                        	exchangeColorId=$(".dhq-dalog input[type=radio]:checked").val();                            dataArgs["exchangeColorId"] = exchangeColorId;                        }                        if(isSpell==1){                        	dataArgs['isSpell']=isSpell;                        }                        if(orderId!='' && orderId!=null){                        	dataArgs['spellOrderId']=orderId;                        }//                  }                    $.ajax(base_path+'/order/pay', { // 提交订单,准备支付                        data: dataArgs,                        dataType: 'json',                        type: 'POST',                        timeout: 15000,                        xhrFields: {                        	withCredentials: true                        },                        crossDomain: true,                        success: function(dt) {                        	if (dt.isRedirect) {                        		location.href = dt.redirectURL;                        	} else {                            layer.closeAll();                            //mui.alert(dt.resultCode=="500");                            if(dt.resultCode == "500") {                                mui.alert(dt.message);                                isPay = true;                                return;                            };                                                       if(dt.data.info == "isOK") {                            	location.href = 'pay_win.html?orderId=' + dt.data.orderId + isSpellstr;                                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') {                                        var orderIds = {                                            "orderId": dt.data.orderId                                        };                                        layer.open({                                            type: 2,                                            shadeClose: false,                                            content: "正在请求加载订单信息..."                                        }); // 调用加载弹出层                                        $.ajax(base_path + '/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) { // 支付成功															if(isSpell==1 && orderId==null){																location.href='pay_add_group.html?productId='+productId+'&colorId='+colorId+'&orderid='+orderIds.orderId+'&isSpell=1'															}else{																location.href = "pay_win.html?orderId=" + orderIds.orderId															}														} else {															setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000); // 前往订单详情														}													}												},												error: function(xhr, type, errorThrown) {													console.log(xhr);												}											});                                    } else {                                        isPay = true;                                        // mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!");                                        location.href = "order_details.html?orderId=" + dt.data.orderId + isSpellstr; // 前往订单详情                                    }                                });                            } else {                                isPay = true;                                mui.alert(dt.message);                                location.href = "order_details.html?orderId=" + dt.data.orderId + isSpellstr; // 前往订单详情                            }                            }                        },                        error: function(xhr, type, errorThrown) {                            isPay = true;                            layer.closeAll();                            mui.alert("您的网络异常,请刷新重试!");                            return;                        }                    });                } else {                    mui.alert("正在请求支付中~~请稍后!");                    return;                }            } else {                mui.alert("请选择收货地址!");                return;            }        });        //选择优惠券        mui('body').on('tap', '.mui-popover-action li>a', function() {            var a = this,parent;            //根据点击按钮,反推当前是哪个actionsheet            for(parent = a.parentNode; parent != document.body; parent = parent.parentNode) {                if(parent.classList.contains('mui-popover-action')) {                    break;                }            }            //关闭actionsheet            mui('#' + parent.id).popover('toggle');            var yhq_check=$("input[name=radio1]:checked");            yhq_val = yhq_check.val();            yhq_type = yhq_check.attr("yhq_type");            var yhq_id=yhq_check.attr("couponid"),enough=yhq_check.attr("enough");            if(yhq_val == undefined) {                yhq_val = 0            } else {                if(yhq_type == 1) {                	if(accDiv(payTotal, 100)>=enough){						if(yhq_val > usePayMoney) {							yhq_check.removeAttr("checked");							yhq_val = 0;							mui.alert(' ', '当前优惠券不可用', function() {});						}						$("#yhq_name").html(yhq_check.prev().html());						$("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));						$("#accSub,#accSub>div:first-child").show();						$("#user-pay-money-span").html((accDiv(payTotal, 100) -yhq_val- ipt_balance).toFixed(2));						$(".dhq-last-add").hide();						exchangeColorId='';                   }else{                   	   yhq_check.removeAttr("checked");                        yhq_val = 0;                        mui.alert(' ', '当前商品金额不满足使用条件', function() {});                   }                }else if(yhq_type == 3){                	if(yhq_id==10000){						if(yhq_val > (usePayMoney - ipt_balance)) {							$("input[couponid=10000]:checked").removeAttr("checked");							yhq_val = 0;							mui.alert(' ', '当前优惠券不可用', function() {});						}						$("#yhq_name").html($("input[couponid=10000]:checked").prev().html());						$("#yhq_price").html("免费兑换1支T1或T2滤芯");						$("#accSub,#accSub>div:first-child").show();						$(".dhq-last-add").show();						console.log(yhq_val)						if($(".dhq-last-add").length>0){							yhq_val = 0;						}					  }else if(yhq_id==10001){						  $("#yhq_name").html(yhq_check.prev().html());						  $("#yhq_price").html("- ¥"+parseInt(yhq_val).toFixed(2));						  $("#accSub,#accSub>div:first-child").show();						  $(".dhq-last-add").hide();						  exchangeColorId='';					   }                    //$("#user-pay-money-span").html((usePayMoney -yhq_val- ipt_balance).toFixed(2));				} else {                    yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_check.val(), usePayMoney) * 100) / 100);                    $("#yhq_name").html(yhq_check.prev().html());                    $("#yhq_price").html("- ¥"+yhq_val);                    $("#accSub,#accSub>div:first-child").show();                    //$("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));                    $(".dhq-last-add").hide();                    exchangeColorId='';                }                if(user38Interests==1){                    if((usePayMoney - yhq_val - ipt_balance)>=2000 && (usePayMoney - yhq_val - ipt_balance)<3000){                        $("#user2000").show();                        $("#user3000").hide();                        $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));                    }else if((usePayMoney - yhq_val - ipt_balance)>=3000){                        $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance-100).toFixed(2));                        $("#user2000,#user3000").show();                    }else{                        $("#user2000,#user3000").hide();                        $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));                    }                }else{                    $("#user2000,#user3000").hide();                    $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));                }            }        });        document.querySelector('.loading-bg').style.display = 'none';    });    // 校验订单状态    function checkOrderStatus(orderId) {        $.ajax(base_path + '/wechat/order/checkOrderPaySuccess?dates=' + new Date().getTime(), {			data: {				"orderId": 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) { // 支付成功						if(isSpell==1 && orderId==null){							location.href='pay_add_group.html?productId='+productId+'&colorId='+colorId+'&orderid='+dataobj.data+'&isSpell=1'						}else{							location.href = "pay_win.html?orderId=" + dataobj.data						}					} else {						location.href = 'order_details.html?orderId=' + orderId + isSpellstr; // 前往订单详情					}									}			},			error: function(xhr, type, errorThrown) {				console.log(xhr);			}		});   };</script></body></html>
 |