qihanjiao 6 лет назад
Родитель
Сommit
bb4b520452

+ 2 - 1
watero-wechat-web/src/main/resources/platform.properties

@@ -191,4 +191,5 @@ GOODS_SAVE_PATH=/common/images/uploadimages/
 REPLACE_SECURITY_IMAGE=http://192.168.1.129:8080/watero/common/images/security.jpg
 SUCCESSINFO=SUCCESS
 RESERVE_PAY_CALLBACK=http//test.iamberry.com/watero/callback/reserver_back
-reserve_pay_money=1
+reserve_pay_money=1
+DO_MAIN=test.iamberry.com

+ 620 - 9
watero-wechat-web/src/main/webapp/WEB-INF/views/wechat/clearing.html

@@ -15,6 +15,10 @@
 	<link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/iconfont.css?v=2016111701" />
 	<link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/style.css?v=2016111701" />
 	<link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/clearing.css?v=2016111701" />
+	<style>
+		.my-yhq-tab>li{margin: 0;}
+		.clearing-count{border-bottom: 30px solid #fff;}
+	</style>
 	<script type="text/javascript">
         // 屏蔽分享
         window.hiddenAllWechatMenu = true;
@@ -43,15 +47,15 @@
 		</li>
 	</ul>
 	<ul class="mui-table-view my-yhq-tab">
-		<li class="mui-table-view-cell forward">
+		<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">0</span>张可使用</span>
 				</div>
 			</a>
 		</li>
-		<div style="padding: 10px 15px 0 15px;">可用余额:<span class="cl-red" id="used_balance">¥0.00</span></div>
-		<li class="mui-table-view-cell pay_ipt_box" style="padding: 0;">
+		<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>
@@ -59,22 +63,30 @@
 				</div>
 			</div>
 		</li>
-		<li class="mui-table-view-cell" style="padding: 0;">
+		<li class="mui-table-view-cell" style="padding: 0;margin: 0;">
 			<div class="mui-input-group">
 				<div class="mui-input-row">
 					<label>订单备注:</label>
-					<input type="text" placeholder="(可选填)" id="textarea">
+					<input style="font-size: 12px" type="text" placeholder="(选填:订单要求,可以在此备注)" id="textarea">
+				</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;text-align: right;" type="text" readonly="readonly" placeholder="(选填:订单要求,可以在此备注)" id="total">
 				</div>
 			</div>
 		</li>
 		<li class="mui-table-view-cell" id="accSub">
-			<div>优惠券:<span class="mui-pull-right cl-red">- ¥<span id="yhq_price">0</span></span></div>
+			<div><span id="yhq_name"></span><span class="mui-pull-right cl-red"><span id="yhq_price"></span></span></div>
 			<div>账户余额:<span class="mui-pull-right cl-red">- ¥<span id="used_buy">0</span></span></div>
 		</li>
 	</ul>
-	<div class="clearing-count">还需支付:<font class="cl-red">¥</font><span class="cl-red" id="user-pay-money-span">加载中...</span></div>
+	<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="pay_weixin">
-		<button type="button" class="mui-btn mui-btn-success mui-btn-block btn-weixin-pay" id="btn-weixin-pay">微信支付</button>
+		<button type="button" class="mui-btn mui-btn-success mui-btn-block btn-weixin-pay" id="btn-weixin-pay" style="border-radius: 0;">微信支付</button>
 	</div>
 </div>
 <div id="forward" class="mui-popover mui-popover-action mui-popover-bottom">
@@ -92,6 +104,605 @@
 <script src="/watero/common/shop/js/page/main.js?v=20170622"></script>
 <script src="//s.iamberry.com/watero/js/shop/wechat-utils-1.0.js?v=201706001"></script>
 <script src="//s.iamberry.com/watero/js/shop/layer.js"></script>
-<script src="//s.iamberry.com/watero/js/shop/clearing.js?v=201706001"></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 usePayMoney = 0;
+    var ipt_balance = 0;
+    var yhq_val = 0;
+    var used_balance = 0;
+    var yhq_type = 1;
+    var showIs = false;
+
+    mui.ready(function() {
+        var name,value;
+        var str=location.href; //取得整个地址栏
+        var num=str.indexOf("?")
+        str=str.substr(num+1); //取得所有参数
+
+        mui.ajax(base_path+'/order/payBefore?'+str, {
+            dataType: 'json',
+            type: 'POST',
+            timeout: 15000,
+            success: function(dt) {
+                if(dt.status == true) {
+                    // 购物项遍历
+                    //console.log(dt)
+                    var liNote = "";
+
+                    var cNum = 0;
+                    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();
+                    } else {
+                        $("#yhq_count").html(dt.data.couponItems.length);
+                        //如果购买商品只有饮水机滤芯,则不能使用优惠券
+                        if (dt.data.disable) {
+                            mui(dt.data.couponItems).each(function(index) {
+                                yhq_str += '<div class="mui-input-row mui-radio"><label>' + this.couponName + '</label><input name="radio1" value="' + accDiv(this.couponReduce, 100) + '" type="radio" id="' + this.couponItemId + '" yhq_type="' + this.couponType + '"></div>';
+                            });
+                            $(".my-popover").html(yhq_str + '<div class="mui-input-row mui-radio"><label>不使用优惠券</label><input name="radio1" value="1" type="radio"></div>');
+                        }
+                    }
+                    for(var i = 0; i < dt.data.cartItems.length; i++) {
+                        var total = dt.data.cartItems[i].cartNum * dt.data.cartItems[i].productPrice / 100; // 购物车小计,分-->元
+                        var pro_color = switchcolor(dt.data.cartItems[i].cartColorId);
+                        var colorImg = switchColorImg(dt.data.cartItems[i].cartColorId);
+                        total = total.toFixed(2); // 保留两位小数
+                        var productId = dt.data.cartItems[i].cartProductId;
+                        var colorId=dt.data.cartItems[i].cartColorId;
+                        var price = dt.data.cartItems[i].productPrice;
+                        var num = dt.data.cartItems[i].cartNum;
+                        if (dt.data.cartItems[i].productPrice / 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='" + colorImg + "'></span>" +
+                                "<div class='mui-media-body' style='padding: 5% 0;'>" +
+                                "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "<div class='price_sp cl-gwc' id='product-" + productId + "' price='" + price + "'>¥" + total + "</div></div>" +
+                                "<small class='gwc_pp'>颜色:" + pro_color + "</small>" +
+                                "</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='" + colorImg + "'></span>" +
+                                "<div class='mui-media-body'  style='padding: 5% 0;'>" +
+                                "<div class='wt-space gwc_tit'>" + dt.data.cartItems[i].productName + "<div class='price_sp cl-gwc' id='product-" + productId + "' price='" + price + "'>¥" + total + "</div></div>" +
+                                "<small class='gwc_pp'>颜色:" + pro_color + "</small>" +
+                                "</div>" +
+                                "</a>" +
+                                "</li>";
+                        }
+
+                    }
+                    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='//w.iamberry.com/watero/common/images/uploadimages/image/20161202/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>"
+                    }
+                    var $productListUl = $("#products-list-ul");
+                    $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);
+                    $("#user-pay-money-span").html(usePayMoney.toFixed(2) + " 元");
+
+                    //默认自己拉出地址
+                    if(dt.data.addressInfo != undefined && dt.data.addressInfo != null) {
+                        $("#user-address-div").empty().append(
+                            "收货人:" + dt.data.addressInfo.salesAddressName + "<span class='ml-5'>" + dt.data.addressInfo.salesAddressTel + "</span>" +
+                            "<a>" +
+                            "<p class='shipping_address wt-space'>" + dt.data.addressInfo.salesAddressInfo + "<span class='mui-icon mui-icon-arrowright icon-r-c'></span></p>" +
+                            "</a>");
+                        $("#user-address-div").show();
+                        $("#open-wechat-addres-a").hide();
+                        //给微信参数赋值
+                        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 {
+                    mui.alert(dt.message);
+                }
+            },
+            error: function(xhr, type, errorThrown) {
+                errorfn(xhr);
+            }
+        });
+        // 获取微信共享地址
+        mui('body').on('tap', '#open-wechat-addres-a,#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;
+
+                    $("#user-address-div").empty().append(
+                        "收货人:" + wechatAddr.userName + "<span class='ml-5'>" + wechatAddr.userTel + "</span>" +
+                        "<a>" +
+                        "<p class='shipping_address wt-space'>" + wechatAddr.detailInfo + "<span class='mui-icon mui-icon-arrowright icon-r-c'></span></p>" +
+                        "</a>");
+                    $("#user-address-div").show();
+                    $("#open-wechat-addres-a").hide();
+                },
+                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() {
+            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)
+                    };
+
+                    mui.ajax('/watero/wechat/order/pay', { // 提交订单,准备支付
+                        data: dataArgs,
+                        dataType: 'json',
+                        type: 'POST',
+                        timeout: 15000,
+                        success: function(dt) {
+                            layer.closeAll();
+
+                            //mui.alert(dt.resultCode=="500");
+                            if(dt.resultCode == "500") {
+                                mui.alert(dt.message);
+                                isPay = true;
+                                return;
+                            };
+                            if(dt.data.info == "isOK") {
+                                mui.openWindow({
+
+                                    url: domanUrl + base_path+"/order/paySuccess?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') {
+                                        var orderIds = {
+                                            "orderId": dt.data.orderId
+                                        };
+                                        layer.open({
+                                            type: 2,
+                                            shadeClose: false,
+                                            content: "正在请求加载订单信息..."
+                                        }); // 调用加载弹出层
+                                        var url = base_path+"/order/checkOrderPaySuccess";
+                                        $.getJSON(url, {
+                                            "s": new Date().getTime(),
+                                            "orderId": dt.data.orderId
+                                        }, function(data) {
+                                            if(data.status == true) { // 支付成功
+                                                window.location.href = base_path + "/order/paySuccess?orderId=" + orderIds.orderId + "&dates=" + new Date().getTime();
+                                            } else {
+                                                setTimeout("checkOrderStatus('" + dt.data.orderId + "')", 1000);
+                                            }
+                                        });
+                                    } else {
+                                        isPay = true;
+                                        // mui.alert("对不起,支付失败!请稍后重试!" + dt.data.orderId + "支付失败!");
+                                        window.location.href = "/watero/pay/goOrderInfo?orderId=" + dt.data.orderId + "&dates=" + new Date().getTime(); // 前往订单详情
+                                    }
+                                });
+                            } else {
+                                isPay = true;
+                                mui.alert(dt.message);
+                                window.location.href = "/watero/pay/goOrderInfo?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;
+            }
+        });
+        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');
+            yhq_val = $("input[name=radio1]:checked").val();
+            yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
+            if(yhq_val == undefined) {
+                yhq_val = 0
+            } else {
+                if(yhq_type == 1) {
+                    if(yhq_val > (usePayMoney - ipt_balance)) {
+                        $("input[name=radio1]:checked").removeAttr("checked");
+                        yhq_val = 0;
+                        mui.alert(' ', '当前优惠券不可用', function() {});
+                    }
+                    console.log($("input[name=radio1]:checked").prev().html());
+                    $("#yhq_name").html($("input[name=radio1]:checked").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));
+                }else if(yhq_type == 3){
+                    if(yhq_val > (usePayMoney - ipt_balance)) {
+                        $("input[name=radio1]:checked").removeAttr("checked");
+                        yhq_val = 0;
+                        mui.alert(' ', '当前优惠券不可用', function() {});
+                    }
+                    $("#yhq_name").html($("input[name=radio1]:checked").prev().html());
+                    $("#yhq_price").html("免费兑换1支T1或T2滤芯");
+                    $("#accSub,#accSub>div:first-child").show();
+                    $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2));
+				} else {
+                    yhq_val = accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100);
+                    $("#yhq_name").html($("input[name=radio1]:checked").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));
+                }
+            }
+        });
+        mui.os.ios ? listener_ipt() : keyup_fn();
+        var reg = /^(([1-9]\d*))$/;
+
+        function keyup_fn() {
+            $('body').on('blur', '#pay_ipt', function(e) {
+                ipt_balance = $(this).val();
+                if(reg.test(ipt_balance)) {
+                    if(ipt_balance > (usePayMoney - yhq_val)) {
+                        ipt_balance = (usePayMoney - yhq_val).toFixed(2);
+                        if(ipt_balance < 0) {
+                            ipt_balance = 0;
+                            $(this).val("");
+                        } else {
+                            $(this).val((usePayMoney - yhq_val).toFixed(2));
+                        }
+                    }
+                    if(ipt_balance > used_balance) {
+                        ipt_balance = used_balance;
+                        $(this).val(used_balance);
+                    }
+                    $('#used_buy').html(ipt_balance);
+                    var money = (usePayMoney - yhq_val).toFixed(2);
+                    money <= 0 ? money = 0 : money;
+                    $("#accSub,#accSub>div:last-child").show();
+                    $("#user-pay-money-span").html((money - ipt_balance).toFixed(2) + " 元");
+                } else {
+                    mui.alert(' ', '您输入的数字有误,请重新输入', function() {
+                        $(this).val("");
+                        ipt_balance = 0;
+                        $('#used_buy').html(ipt_balance);
+                        $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
+                    });
+                }
+            });
+        }
+
+        function listener_ipt() {
+            document.getElementById('pay_ipt').onblur = function() {
+                var th = this;
+                ipt_balance = th.value;
+                if(reg.test(ipt_balance)) {
+                    if(ipt_balance > (usePayMoney - yhq_val)) {
+                        ipt_balance = (usePayMoney - yhq_val).toFixed(2);
+                        if(ipt_balance < 0) {
+                            ipt_balance = 0;
+                            th.value = "";
+                        } else {
+                            th.value = (usePayMoney - yhq_val).toFixed(2);
+                        }
+                    }
+                    if(ipt_balance > used_balance) {
+                        th.value = used_balance;
+                        ipt_balance = used_balance;
+                    }
+                    $('#used_buy').html(ipt_balance);
+                    var money = (usePayMoney - yhq_val).toFixed(2);
+                    money <= 0 ? money = 0 : money;
+                    $("#accSub,#accSub>div:last-child").show();
+                    $("#user-pay-money-span").html((money - ipt_balance).toFixed(2) + " 元");
+                } else {
+                    mui.alert(' ', '您输入的数字有误<br>请重新输入', function() {
+                        th.value = "";
+                        ipt_balance = 0;
+                        $('#used_buy').html(ipt_balance);
+                        $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
+                    });
+                }
+            }
+        }
+        document.querySelector('.loading-bg').style.display = 'none';
+    });
+    // 校验订单状态
+    function checkOrderStatus(orderId) {
+        var url = base_path + "/order/checkOrderPaySuccess";
+        var order = {
+            "s": new Date().getTime(),
+            "orderId": orderId
+        };
+        $.getJSON(url, order, function(data) {
+            if(data.status == true) { // 支付成功
+                window.location.href = base_path + "/order/paySuccess?orderId=" + orderId + "&dates=" + new Date().getTime();
+            } else {
+                window.location.href = '/watero/pay/goOrderInfo?orderId=' + orderId + "&dates=" + new Date().getTime();;
+            }
+        });
+    }
+
+    // 点击加号的事件
+    function shoppAddEvent(productId,colorId) {
+        mui.ajax(base_path + '/cart/addCart', {
+            data: {
+                "productId": productId,
+                "carNum": 1,
+                "colorId":colorId
+            },
+            dataType: 'json',
+            type: 'GET',
+            timeout: 15000,
+            success: function(dt) {
+                if(dt.status == true) {
+                    // 销售价
+                    var productObj = $("#product-" + productId);
+                    var price = parseInt(productObj.attr("price"));
+                    // total
+                    var total = payTotal + price;
+                    payTotal = total;
+                    // 修改数量
+                    var shoppNumObj = $("#shoppNum-" + productId);
+                    var num = parseInt(shoppNumObj.val());
+                    shoppNumObj.val(num + 1);
+                    /* $("#user-pay-money-span").html((payTotal / 100).toFixed(2)); */
+                    yhq_val = $("input[name=radio1]:checked").val();
+                    yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
+                    usePayMoney = accDiv(payTotal, 100);
+                    if(yhq_val == undefined) {
+                        yhq_val = 0
+                    }
+                    if(yhq_type == 2) {
+                        yhq_val = accSub(usePayMoney, (Math.floor(accMul(yhq_val, usePayMoney) * 100) / 100));
+                        $("#yhq_price").html(accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100));
+                    }
+                    $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
+                    // 修改小计
+                    productObj.html("¥" + ((num + 1) * price / 100).toFixed(2));
+                    var temp = new Number($("#shoppNum-all").val());
+                    temp = temp + 3;
+                    $("#shoppNum-all").val(temp);
+                    if(showIs){
+                        var gNum = $("#giveNum").html();
+                        var rNum = parseInt(gNum) + 1;
+                        $("#giveNum").html(rNum);
+                    }
+
+                } else {
+                    // 失败之后的事件
+                    mui.alert(dt.message);
+                }
+            },
+            error: function(xhr, type, errorThrown) {}
+        });
+    }
+
+    // 购物车减
+    function shoppSubEvent(productId,colorId) {
+        var shoppNumObj = $("#shoppNum-" + productId);
+        var num = parseInt(shoppNumObj.val());
+
+        if(num <= 1) {
+            mui.alert("不能继续减少了哦!");
+            return;
+        }
+        mui.ajax(base_path + '/cart/deleteCart', {
+            data: {
+                "productId": productId,
+                "cartNum": 1,
+                "colorId":colorId
+            },
+            dataType: 'json',
+            type: 'GET',
+            timeout: 15000,
+            success: function(dt) {
+                if(dt.status == true) {
+                    // 销售价
+                    var productObj = $("#product-" + productId);
+                    var price = parseInt(productObj.attr("price"));
+                    // total
+                    var total = payTotal - price;
+                    payTotal = total;
+                    // 修改数量
+                    var shoppNumObj = $("#shoppNum-" + productId);
+                    var num = parseInt(shoppNumObj.val());
+                    shoppNumObj.val(num - 1);
+                    /*$("#user-pay-money-span").html((payTotal / 100).toFixed(2));*/
+                    yhq_val = $("input[name=radio1]:checked").val();
+                    yhq_type = $("input[name=radio1]:checked").attr("yhq_type");
+                    usePayMoney = accDiv(payTotal, 100);
+                    if(yhq_val == undefined) {
+                        yhq_val = 0
+                    }
+                    if(yhq_type == 2) {
+                        yhq_val = accSub(usePayMoney, Math.floor(accMul(yhq_val, usePayMoney) * 100) / 100);
+                        $("#yhq_price").html(accSub(usePayMoney, Math.floor(accMul($("input[name=radio1]:checked").val(), usePayMoney) * 100) / 100));
+                        if(ipt_balance > (usePayMoney - yhq_val)) {
+                            if((usePayMoney - yhq_val) <= 0) {
+                                ipt_balance = 0;
+                                $('#used_buy').html(ipt_balance);
+                                $('#pay_ipt').val("");
+                            } else {
+                                ipt_balance = (usePayMoney - yhq_val).toFixed(2);
+                                $('#used_buy').html(ipt_balance);
+                                $('#pay_ipt').val(ipt_balance);
+                            }
+                        }
+                        $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
+                    } else {
+                        if((usePayMoney - yhq_val) < ipt_balance) {
+                            if((usePayMoney - yhq_val) <= 0) {
+                                ipt_balance = 0;
+                                $('#used_buy').html(ipt_balance);
+                                $('#pay_ipt').val("");
+                            } else {
+                                ipt_balance = (usePayMoney - yhq_val).toFixed(2);
+                                $('#used_buy').html(ipt_balance);
+                                $('#pay_ipt').val(ipt_balance);
+                            }
+                        }
+                        if(yhq_val > (usePayMoney - ipt_balance)) {
+                            mui.alert(' ', '当前优惠券不可用', function() {
+                                $("input[name=radio1]:checked").removeAttr("checked");
+                                yhq_val = 0;
+                                $("#yhq_price").html(yhq_val);
+                                $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
+                            });
+                        }
+                        $("#user-pay-money-span").html((usePayMoney - yhq_val - ipt_balance).toFixed(2) + " 元");
+                    }
+                    var temp = new Number($("#shoppNum-all").val());
+                    temp = temp - 3;
+                    $("#shoppNum-all").val(temp+"")
+                    productObj.html("¥" + ((num - 1) * price / 100).toFixed(2));
+                    if(showIs){
+                        var gNum = $("#giveNum").html();
+                        var rNum = parseInt(gNum) - 1;
+                        $("#giveNum").html(rNum);
+                    }
+                } else {
+                    mui.alert(dt.message);
+                }
+            },
+            error: function(xhr, type, errorThrown) {
+                errorfn(xhr);
+            }
+        });
+    }
+</script>
 </body>
 </html>

+ 38 - 35
watero-wechat-web/src/main/webapp/WEB-INF/views/wechat/free_collection.html

@@ -14,15 +14,28 @@
 		<link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/mui.min.css?v=2016111701" />
 		<link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/iconfont.css?v=2016111701" />
 		<link rel="stylesheet" type="text/css" href="//css.iamberry.com/watero/css/style.css?v=2016111701" />
+		<style>
+			.register-group{margin: 0 auto;width: 300px;}
+			.register-group:before,.register-group:after,.register-group .mui-input-row:before,.register-group .mui-input-row:after{display: none}
+			.register-group .mui-input-row label{padding: 11px 5px;width: 20%;}
+			.register-group .mui-input-row label~input{width: 80%;border-bottom:1px solid #ccc;font-size: 16px;}
+			.register-group .mui-input-row label~input::-webkit-input-placeholder{font-size: 15px;color: #ccc;}
+			.pull-code {border: 0;color: #666;padding:8px 0;position: absolute;right:0;}
+			.pull-code.active{color: #6dd4e5;}
+			.pull-code:active{background-color: #fff !important;color: #666 !important;}
+			.my-btn-confirm{background-color: #fff;border:1px solid #59c0d9;border-radius: 0;width: 200px;margin: 0 auto;color: #666;padding: 7px 0;color: #59c0d9;}
+			.my-btn-confirm:active{background-color: #59c0d9 !important;border:1px solid #59c0d9;color: #fff;}
+			.my-btn-confirm.active{background-color: #59c0d9 !important;border:1px solid #59c0d9;color: #fff;}
+		</style>
 	</head>
 
-	<body>
+	<body style="background: #fff;">
 		<!--内容开始-->
-		<div class="mui-content">
+		<div class="mui-content" style="background: #fff;">
 			<div>
 				<img width="100%" src="//s.iamberry.com/watero/images/banner-11.jpg" />
 			</div>
-			<div class="mui-text-center">
+			<div class="mui-text-center" style="color:#59c0d9;font-size: 16px;padding: 15px 0;">
 				验证手机信息
 			</div>
 			<form class="mui-input-group register-group">
@@ -32,7 +45,7 @@
 				</div>
 				<div class="mui-input-row">
 					<label>验证码</label>
-					<input type="tel" placeholder="输入短信验证码" maxlength="4" id="code"><button type="button" class="pull-code" id="pull-code">获取验证码</button>
+					<input type="tel" placeholder="输入验证码" maxlength="4" id="code"><button type="button" class="pull-code" id="pull-code">获取验证码</button>
 				</div>
 			</form>
 			<br />
@@ -40,15 +53,16 @@
 				<button type="button" data-loading-icon="mui-spinner mui-spinner-custom" data-loading-text="提交中" class="mui-btn mui-btn-block my-btn-confirm" id="btn-confirm" disabled="disabled">领取滤芯</button>
 			</div>
 			<div class="mui-content-padded">
+				<div style="border-top: 1px solid rgba(0,0,0,.1);margin: 20px 0;"></div>
 				<ul>
-					<li>活动说明:</li>
-					<li>1、此活动福利仅针对watero老客户</li>
-					<li>2、每个手机号限领一次,会员中心可查看</li>
-					<li>3、如您为老客户,已更换手机号,请联系客服处理</li>
-					<li>活动福利:</li>
-					<li>1、免费赠送WateroT1或T2滤芯一支</li>
-					<li>2、此后凡购买滤芯套装,均享立减100元优惠</li>
-					<li>3、尊享watero一对一客服售后服务</li>
+					<li style="color:#59c0d9;padding-bottom: 10px;">活动说明:</li>
+					<li class="mui-h6">1、此活动福利仅针对watero老客户</li>
+					<li class="mui-h6">2、每个手机号限领一次,会员中心可查看</li>
+					<li class="mui-h6">3、如您为老客户,已更换手机号,请联系客服处理</li>
+					<li style="color:#59c0d9;padding:10px 0;">活动福利:</li>
+					<li class="mui-h6">1、免费赠送WateroT1或T2滤芯一支</li>
+					<li class="mui-h6">2、此后凡购买滤芯套装,均享立减100元优惠</li>
+					<li class="mui-h6">3、尊享watero一对一客服售后服务</li>
 				</ul>
 			</div>
 		</div>
@@ -119,7 +133,7 @@
 								return;
 							} else {
 								if($(this).hasClass("active")) {
-									$.ajax(base_path + '/send_message?dates=' + new Date().getTime(), {
+									$.ajax(base_path + '/tanksgiv/send_veri?dates=' + new Date().getTime(), {
 										data: {
 											"phone": $("#ipt-phone").val().trim()
 										},
@@ -134,7 +148,7 @@
 											if(dt.isRedirect) {
 												location.href = dt.redirectURL;
 											} else {
-												if(dt.returnCode == "200") {
+												if(dt.status) {
 													settime("pull-code");
 													$("#code").select();
 													if(!window.localStorage) {
@@ -208,9 +222,9 @@
 					th = this;
 				if(code.test(val)) {
 					mui(th).button('loading');
-					$.ajax(base_path + '/userRegister_TEL?dates=' + new Date().getTime(), {
+					$.ajax(base_path + '/tanksgiv/receive_coupon?dates=' + new Date().getTime(), {
 						data: {
-							"tel": $("#ipt-phone").val().trim(),
+							"phone": $("#ipt-phone").val().trim(),
 							"code": $("#code").val().trim()
 						},
 						dataType: 'json',
@@ -224,31 +238,20 @@
 							if(dt.isRedirect) {
 								location.href = dt.redirectURL;
 							} else {
-								if(dt.returnCode == "200") {
-									//									mui.alert("手机验证成功!",function(){
-									location.href = "register-perfect.html";
-									//									});
+								if(dt.status) {
+									mui.alert(dt.message,function(){
+									    location.href = "/watero/view/coupon_bag.html";
+									});
 								} else {
-									if(typeof(dt.returnMsg.registerTel) != "undefined") {
-										if(dt.returnMsg.registerTel) {
-											mui.alert('该号码已注册会员,换一个手机号试试!', function() {
-												mui(th).button('reset');
-											});
-										}
-									}
-									if(typeof(dt.returnMsg.registerInfo) != "undefined") {
-										if(dt.returnMsg.registerInfo) {
-											mui.alert('您已完善注册信息!', function() {
-												location.href = 'vip-center.html';
-											});
-										}
-									}
+									mui.alert(dt.message, function() {
+										mui(th).button('reset');
+									});
 								}
 							}
 						},
 						error: function(xhr, type, errorThrown) {
 							console.log(xhr);
-							mui.alert("注册验证失败!网络出小差了", function() {
+							mui.alert("领取失败!网络出小差了", function() {
 								mui(th).button('reset');
 							});
 						}

Разница между файлами не показана из-за своего большого размера
+ 35 - 46
watero-wechat-web/src/main/webapp/view/coupon_bag.html