Browse Source

Merge branch 'dev4.4' of ssh://192.168.3.207:10022/qmx/jy into dev4.4

yangfeng 4 years ago
parent
commit
49efd3c8ec

+ 2 - 1
src/config.json

@@ -43,7 +43,8 @@
 		"msgremind": "/front/vipsubscribe/msgremind?%s",
 		"treasurebox":"/jyTreasureBox/treasureBox",
 		"vipreport":"/subscribepay/report/wxtplmsg?start=%s&end=%s&pushcount=%s",
-		"viphomepage":"/front/vipsubscribe/vipsubscribe_new",
+		"viphomepage":"/front/vipsubscribe/introducePage",
+		"viphomepage_new":"/front/vipsubscribe/vipsubscribe_new",
 		"liveAcitve":"/active/livePage/index",
 		"bigMember":"/big/wx/page/landingPage",
 		"structed":"/front/structed/index?p=wx",

+ 28 - 0
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/css/vip_renew.css

@@ -705,4 +705,32 @@
   width: unset;
   flex: 1;
   justify-content: flex-start;
+}
+
+.tips {
+  padding: 0 .32rem;
+}
+.tip-title {
+  margin: .3rem .22rem;
+  text-align: left;
+  color: #171826;
+  line-height: .4rem;
+}
+.tip-content {
+  color: #5F5E64;
+  line-height: .36rem;
+}
+.l-line {
+  position: relative;
+}
+.l-line:before {
+  content: '';
+  position: absolute;
+  left: -0.22rem;
+  top: 50%;
+  width: .06rem;
+  height: .32rem;
+  background-color: #2ABED1;
+  transform: translateY(-50%);
+  border-radius: .06rem;
 }

+ 404 - 465
src/jfw/modules/app/src/web/staticres/jyapp/vipsubscribe/js/vip_renew.js

@@ -1,250 +1,259 @@
-var purchase = {
-    areaSelect: {
-        "一个省": ["一个市"]
-    }, //已选择地区 {"一个省":["一个市"]}计算价格临时变量
-    industrySelect: ["一个行业"], // 已选择行业 一个行业(计算价格临时变量)
-    timeSelect: [1, 2], //已选择时间 timeSelect[0]时长  timeSelect[1] 1:年 2:月
-    timeValue: "一个月",
-    endTime: "",
-    price: {}, //价格
-    nowBuyset: {},
-    timeCheckOk: false,
-    payWay: "wx_app",
-    initData: function () {
-        //已选择
-        try {
-            //即将到期 回显已购买
-            if (!sessionStorage.getItem("pay_read_cache")) {
-                $DoPost("/subscribepay/vipsubscribe/getSubBuyMsg", {}, function (r) {
-                    if (r.success) {
-                        if (!$.isEmptyObject(r.data.area)) {
-                            purchase.areaSelect = r.data.area
-                        } else {
-                            purchase.areaSelect = {
-                                "全国": []
-                            }
-                        }
-                        if (r.data.industry.length != 0) {
-                            purchase.industrySelect = r.data.industry
-                        } else {
-                            purchase.industrySelect = ["全部行业"]
-                        }
-                        if (r.data.endTime) {
-                            purchase.endTime = r.data.endTime;
-                        }
-                        sessionStorage.setItem("vipSubSelectArea", JSON.stringify(purchase.areaSelect));
-                        sessionStorage.setItem("vipSubSelectIndustry", JSON.stringify(purchase.industrySelect));
-                        sessionStorage.setItem("endTime", JSON.stringify(purchase.endTime))
-                        sessionStorage.setItem("vipSub_read", true);
-                    }
-                }, false)
-            } else {
-                sessionStorage.removeItem("pay_read_cache");
-                if (sessionStorage.getItem("vipSubSelectArea")) {
-                    this.areaSelect = JSON.parse(sessionStorage.getItem("vipSubSelectArea"));
-                }
-                if (sessionStorage.getItem("vipSubSelectIndustry")) {
-                    this.industrySelect = JSON.parse(sessionStorage.getItem("vipSubSelectIndustry"));
-                }
-                if (sessionStorage.getItem("endTime")) {
-                    this.endTime = parseInt(sessionStorage.getItem("endTime"))
-                }
-            }
-            if (sessionStorage.getItem("vipSubSelectTime")) {
-                this.timeSelect = JSON.parse(sessionStorage.getItem("vipSubSelectTime"));
+var renew = {
+    oldRules: Calculation.PriceRule.old,
+    newRules: Calculation.PriceRule.new,
+    requestRules: {},
+    price: '', // 单位分
+    timeSelect: [1, 2], // 续费周期(默认选中1个月)
+    timeCheckOk: true,
+    buyInfo: { // 购买的信息
+        startTime: 0,
+        endTime: 0,
+        area: {},
+        industry: [],
+        buyset: {
+            areacount: 0,
+            newcitys: [],
+            buyerclasscount: 3
+        },
+        isTrial: false,
+        renewList: []
+    },
+    init: function () {
+        this.recoverState()
+        this.getPrice()
+        this.getBuySetInfo()
+        this.initEvents()
+    },
+    setAreaAndIndustry: function () {
+        var buySet = this.buyInfo.buyset
+        var result = {
+            area: '',
+            industry: ''
+        }
+        // 区域
+        if (buySet.areacount === -1) {
+            result.area = '全国'
+        } else {
+            var strArr = []
+            if (buySet.areacount) {
+                strArr.push(buySet.areacount + '个省')
             }
-            if (sessionStorage.liveActiveCode_renew === "jianyu360") {
-                $('.coupon-code-tx .keywords-text').text("支付成功赠送30天订阅周期");
-                $('.coupon-picker .weui-input').val("jianyu360");
-                $('.coupon-code-tx').off('click');
+            if (buySet.newcitys && buySet.newcitys.length !== 0) {
+                var count = 0
+                buySet.newcitys.forEach(function (item) {
+                    count += item
+                })
+                strArr.push(count + '个市(分布在' + buySet.newcitys.length + '个省内')
             }
-            //加载价格
-            $DoPost("/subscribepay/vipsubscribe/getPrice", {}, function (r) {
-                if (r) {
-                    purchase.price = r;
-                    purchase.can1111 = r.isActiving && r.isWritten === 0
-                    if (purchase.can1111) {
-                        if (!sessionStorage.getItem("vipSubSelectTime")) {
-                            purchase.timeValue = "1年";
-                            purchase.timeSelect_tmp = [1,1]
-                            purchase.timeSelect = purchase.timeSelect_tmp;
-                            purchase.showTime();
-                            purchase.flushPrice(purchase.timeSelect, 1);
-                            sessionStorage.setItem("vipSubSelectTime", JSON.stringify(purchase.timeSelect));
-                        }
-                        showGiveStatus(true)
-                    } else {
-                        //showGiveStatus(false)
-                    }
-                }
-            }, false)
+            result.area = strArr.join('、')
+        }
 
-        } catch (e) {
-            console.log(e)
+        // 行业(3个行业价格和全部行业价格相同,当购买3个以上行业页面显示全部行业)
+        if (buySet.buyerclasscount === -1 || buySet.buyerclasscount >= 3) {
+            result.industry = '全部行业'
+        } else {
+            result.industry = buySet.buyerclasscount + '个行业'
         }
-        this.nowBuyset = getBuySet(purchase.areaSelect, purchase.industrySelect, this.price);
 
-        if (sessionStorage.getItem("payWay")) {
-            if (sessionStorage.getItem("payWay").indexOf("ali") > -1) {
-                this.payWay = "ali_app";
-                $("#zfb").prop("checked", true);
-                $(".pay-mode-text").text("支付宝支付");
+        $('.area .item-r').text(result.area)
+        $('.industry .item-r').text(result.industry)
+
+        return result
+    },
+    initEvents: function () {
+        this.initClickEvents()
+        this.initPickerEvents()
+    },
+    getBuySetInfo: function () {
+        var _this = this
+        $.ajax({
+            url: '/subscribepay/vipsubscribe/getSubBuyMsg',
+            type: 'POST',
+            success: function (r) {
+                if (r.success && r.data) {
+                    Object.assign(_this.buyInfo, r.data)
+                    _this.setAreaAndIndustry()
+                    _this.checkShowDueTip()
+                    // 初始化默认续费周期
+                    _this.calcDuration(true)
+                    // 初始化价格计算类
+                    Calculation.Init(
+                        false,
+                        new Buyset(_this.buyInfo.buyset.areacount, _this.buyInfo.buyset.newcitys, _this.buyInfo.buyset.buyerclasscount)
+                    )
+                    // 初始化默认金额
+                    _this.setPrice(_this.calcPrice())
+                }
             }
-        }
+        })
     },
-    showArea: function () {
-        if (!$.isEmptyObject(this.areaSelect) && !this.areaSelect["一个省"]) { //有选择
-            if (this.nowBuyset.areacount === -1) {
-                $(".area .item-r").text("全国");
-            } else {
-                var tipTxt = "";
-                if (this.nowBuyset.areacount > 0) tipTxt += this.nowBuyset.areacount + " 个省";
-                var count = 0;
-                this.nowBuyset.citys.forEach(function (item, index) {
-                    count += item;
-                });
-                if (count > 0) {
-                    if (this.nowBuyset.areacount > 0) tipTxt += "、";
-                    tipTxt += count + " 个市";
-                    if (this.nowBuyset.citys.length > 1) tipTxt += "(分布在" + this.nowBuyset.citys.length + "个省内)"
+    getPrice: function () {
+        var _this = this
+        $.ajax({
+            url: '/subscribepay/vipsubscribe/getPrice',
+            type: 'POST',
+            success: function (r) {
+                if (r) {
+                    _this.requestRules = r
                 }
-                $(".area .item-r").text(tipTxt);
             }
-        } else {
-            $(".area .item-r").text("");
-        }
+        })
     },
-    showPrice: function () {
-        $('.monthly span:eq(0)').text(purchase.price.month.oneCity_oneBuyerClass / 100);
-        $('.monthly span:eq(1)').text(purchase.price.month.oneCity_allBuyerClass / 100);
-        $('.monthly span:eq(2)').text(purchase.price.month.oneProvince_oneBuyerClass / 100);
-        $('.monthly span:eq(3)').text(purchase.price.month.oneProvince_allBuyerClass / 100);
-        $('.monthly span:eq(4)').text(purchase.price.month.allProvince_oneBuyerClass / 100);
-        $('.monthly span:eq(5)').text(purchase.price.month.allProvince_allBuyerClass / 100);
-
-        $('.yearly span:eq(0)').text(purchase.price.year.oneCity_oneBuyerClass / 100);
-        $('.yearly span:eq(1)').text(purchase.price.year.oneCity_allBuyerClass / 100);
-        $('.yearly span:eq(2)').text(purchase.price.year.oneProvince_oneBuyerClass / 100);
-        $('.yearly span:eq(3)').text(purchase.price.year.oneProvince_allBuyerClass / 100);
-        $('.yearly span:eq(4)').text(purchase.price.year.allProvince_oneBuyerClass / 100);
-        $('.yearly span:eq(5)').text(purchase.price.year.allProvince_allBuyerClass / 100);
+    calcPrice: function () {
+        return Calculation.GetTotal(undefined, this.timeSelect)
     },
-    showIndustry: function () {
-        if (this.industrySelect.length > 0 && this.industrySelect[0] !== "一个行业") { //选择有行业信息
-            if (this.nowBuyset.buyerclasscount === -1) {
-                $(".industry .item-r").text("全部行业");
-            } else {
-                var tipTxt = "";
-                $(".industry .item-r").text(tipTxt + this.nowBuyset.buyerclasscount + " 个行业");
-            }
-        } else {
-            $(".industry .item-r").text("");
+    setPrice: function (price) {
+        this.price = price
+        coupon.updatePrice(formatMoney(this.price / 100))
+    },
+    // 根据选中结果得到一个时间段的时间戳
+    getDuration: function (timeSelect) {
+        var dStamp = 0
+        var s = ''
+        var perMonthStamp = 1000 * 60 * 60 * 24 * 30
+        if (timeSelect[1] === 1) {
+            // 年
+            dStamp = timeSelect[0] * 12 * perMonthStamp
+            s = timeSelect[0] + '年'
+        } else if (timeSelect[1] === 2) {
+            // 月
+            dStamp = timeSelect[0] * perMonthStamp
+            s = timeSelect[0] + '个月'
+        }
+        return {
+            stamp: dStamp,
+            s: s
         }
     },
-    showTime: function () {
-        var tmp = this.timeSelect[0];
-        if (this.timeSelect[1] === 1) {
-            tmp += "年";
-            $("#yearly").prop('checked', true);
-            //$('.year_number:eq(' + (this.timeSelect[0] - 1) + ')').trigger("click");
-            $('.year_number:eq(' + (this.timeSelect[0] - 1) + ')').addClass("active")
-            //$(".number_box:eq(1)").addClass("active");
+    // 计算续费后的日期区间
+    calcDuration: function (needSet) {
+        // 根据
+        var endTime = this.buyInfo.endTime
+        if (!endTime) {
+            $('.select_cycle .duration').hide()
+            return
+        }
+        var durationInfo = this.getDuration(this.timeSelect)
+        var durationStamp = durationInfo.stamp // 续费时间段时间戳
+        var durationStr = durationInfo.s // 续费时间段字符串
+        var buyEndTimeString = new Date(endTime * 1000).pattern('yyyy年MM月dd日') // svip到期时间
+        var renewEndTimeString = new Date(endTime * 1000 + durationStamp).pattern('yyyy年MM月dd日') //续费后到期时间
+
+        if (needSet) {
+            $('.select_cycle .month').text(durationStr)
+            $('.select_cycle .duration').text(buyEndTimeString + ' - ' + renewEndTimeString)
         } else {
-            tmp += "个月";
-            $("#monthly").prop('checked', true);
-            $(".number_box:eq(0)").addClass("active");
-            $("#number_box_month .month_number").text(this.timeSelect[0]);
-            //if (this.timeSelect[0] >= 10) {
-            //    $('.profit_tips').text("已选择" + this.timeSelect[0] + "个月,建议“按年订阅”").show();
-            //}
-            if (this.timeSelect[0] === 1) {
-                $('#number_box_month button:eq(0)').attr("disabled", "disabled");
-            } else {
-                $('#number_box_month button:eq(0)').removeAttr("disabled");
+            return {
+                duration: durationStr, // 续费时间段字符串
+                buyEndTimeString: buyEndTimeString, // svip到期时间
+                renewEndTimeString: renewEndTimeString, //续费后到期时间
             }
         }
-        this.timeValue = tmp;
     },
-    flushPrice: function (time, flag) {
-        //var price = getsubVipOrderPrice(this.areaSelect, this.industrySelect, time, this.price);
-        var times = [time[0], time[1]];
-        var price = getsubVipOrderPriceBybuyset(this.nowBuyset, time);
-        var givePrice = getsubVipOrderPriceBybuyset(this.nowBuyset, [time[1] === 1 ? 1 :time[0], time[1]]);
-
-        var showPrice = formatMoney(price);
-        if (flag === 1) {
-            $('.billing-price').text(showPrice);
-            $('.origin-price .price-num').text(formatMoney(price + givePrice));
-            // 优惠明细
-            $('.discount-price .dis-price').text(formatMoney(givePrice))
-            $('.now-price .dis-price').text(formatMoney(price));
-
-        } else if (flag === 2) {
-            $('.computed_price').html(showPrice);
-        } else {
-            $('.billing-price').text(showPrice);
-            $('.origin-price .price-num').text(formatMoney(price + givePrice));
-            // 优惠明细
-            $('.discount-price .dis-price').text(formatMoney(givePrice))
-            $('.now-price .dis-price').text(formatMoney(price));
-            $('.computed_price').html(showPrice);
+    // 月份转年份(超过1年才会转)
+    monthToYear: function (num) {
+        var year = Math.floor(num / 12)
+        var month = num % 12
+        var str = ''
+        if (year) {
+            str += (year + '年')
+        }
+        if (month) {
+            str += (month + '个月')
+        }
+        return {
+            str: str,
+            year: year,
+            month: month
         }
-        this.flushSelectTime(times, flag === undefined ? 1 : flag);
-        coupon.updatePrice(price)
     },
-    flushSelectTime(thisValue, flag) {
-        if (this.endTime) {
-            var time1 = new Date(this.endTime * 1000).pattern('yyyy年MM月dd日');
-            var end = getVipEndDate(thisValue[1], thisValue[0], this.endTime);
-            var time2 = new Date(end * 1000).pattern('yyyy年MM月dd日');
+    checkOver3Years: function () {
+        // 根据
+        var endTime = this.buyInfo.endTime
+        if (!endTime) {
+            return
+        }
+        var maxEndMonth = 36 // 最大续费36个月
+        var durationInfo = this.getDuration(this.timeSelect)
+        var durationStamp = durationInfo.stamp // 续费时间段时间戳
 
-            if (flag === 1) {
-                $(".select_cycle .month").text(this.timeValue);
-                var giveTime = this.timeValue
-                if (this.timeValue.indexOf('年') !== -1) {
-                    giveTime = '1年'
-                }
-                $(".select_cycle #giveTime").text(giveTime);
-                $(".select_cycle .duration").text(time1 + "-" + time2);
-                $(".select_cycle .duration").show();
-                // @NewYearMarketing 2021/1/25
-                checkMonth(giveTime)
-            }
+        // 最长订阅周期不可超过3年 ------------
+        var nowStamp = Math.floor(Date.now() / 1000)
+        // 已购买的套餐剩余月数
+        var lastMonthStamp = endTime - nowStamp
+        var lastMonth = Math.ceil(lastMonthStamp / (60 * 60 * 24 * 30))
+        // 续费后套餐剩余月数(需要加上原剩余月数lastMonth)
+        var renewMonthTotalStamp = lastMonthStamp + (durationStamp / 1000)
+        var renewMonthTotal = Math.ceil(renewMonthTotalStamp / (60 * 60 * 24 * 30))
 
-            //是否超过三年
-            var now = Math.floor(new Date().getTime() / 1000);
-            var MaxEnd = getVipEndDate(1, 3, now);
-            if (!purchase.can1111 && end > MaxEnd) {
-                var timeShow = getDateSub(now, this.endTime);
-                var showTipText = "<div style='white-space: nowrap;'>最长订阅周期不可超过3年</div>剩余周期:";
-                if (timeShow[0] !== 0) {
-                    showTipText += timeShow[0] + "年"
-                }
-                if (timeShow[1] !== 0) {
-                    showTipText += timeShow[1] + "个月"
-                }
-                weui.toast(showTipText, {
-                    duration: 3000,
-                    className: 'jy-toast',
-                });
-                if (flag === 1) this.timeCheckOk = false;
-                if (flag === 2) $("#enter_period").prop("disabled", true);
-            } else {
-                if (flag === 1) this.timeCheckOk = true;
-                if (flag === 2) $("#enter_period").prop("disabled", false);
-            }
-            this.flushSubmit();
+        if (renewMonthTotal > maxEndMonth) {
+            var showTipText = '<div style="white-space: nowrap;">最长订阅周期不可超过3年</div>剩余周期:' + this.monthToYear(lastMonth).str
+            weui.toast(showTipText, {
+                duration: 3000,
+                className: 'jy-toast',
+            })
+            // 确认按钮置灰
+            $('#enter_period').prop('disabled', true)
         } else {
-            $(".select_cycle .duration").hide();
+            $('#enter_period').prop('disabled', false)
         }
     },
-    showTip() { //是否展示即将到期
-        var timeSub = this.endTime * 1000 - new Date().getTime();
+    // 是否展示即将到期
+    checkShowDueTip () {
+        var endTime = this.buyInfo.endTime * 1000
+        var timeSub = endTime - Date.now()
         if (timeSub > 0 && timeSub < 60 * 60 * 24 * 1000 * 3) {
-            $(".vip-header").show();
+            $('.vip-header').show()
+        }
+    },
+    setTimePickerSelected: function (timeSelect) {
+        timeSelect = [1 ,2]
+        if (timeSelect[1] === 1) {
+            // 年
+            dStamp = timeSelect[0] * 12 * perMonthStamp
+            s = timeSelect[0] + '年'
+        } else if (timeSelect[1] === 2) {
+            // 月
+            dStamp = timeSelect[0] * perMonthStamp
+            s = timeSelect[0] + '个月'
         }
     },
-    flushSubmit() { //是否可提交
+    getTimePickerSelected: function () {
+        var timeSelectPicker = $('#time_cycle')
+        var $checkInput = timeSelectPicker.find('input[name=time]:checked')
+        if (!$checkInput) return
+        // year/month(按年或者按月购买)
+        var checkedType = $checkInput.val()
+        // timeSelectedArr[0] 代表选择的内容
+        // timeSelectedArr[1] 代表选择的类型 1年份 2月份
+        var timeSelectedArr = []
+        if (checkedType === 'month') {
+            timeSelectedArr = [$('#number_box_month .month_number').text() - 0, 2]
+        } else if (checkedType === 'year') {
+            timeSelectedArr = [$('#number_box_year .year_number.active').attr('data-id') - 0, 1]
+        }
+        return timeSelectedArr
+    },
+    onTimePickerChange: function () {
+        this.timeSelect = this.getTimePickerSelected()
+        var price = this.calcPrice()
+        $('.computed_price').text(formatMoney(price / 100))
+        this.checkOver3Years()
+    },
+    // 恢复数据
+    recoverState: function () {
+        var vipSubSelectTime = sessionStorage.getItem('vipSubSelectTime')
+        if (vipSubSelectTime) {
+            this.timeSelect = JSON.parse(vipSubSelectTime)
+        }
+        this.flushSubmit()
+    },
+    // 保存数据
+    saveState: function () {
+        sessionStorage.setItem('vipSubSelectTime', JSON.stringify(this.timeSelect))
+    },
+    // 是否可提交
+    flushSubmit: function () {
         if (this.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true") {
             $('.vip-footer.renew .confirm').prop('disabled', false)
             coupon.checkboxStatus = true
@@ -253,261 +262,187 @@ var purchase = {
             $('.vip-footer.renew .confirm').prop('disabled', true)
             coupon.$refs.couponRef.submitStatus = true
         }
-    }
-};
+    },
+    initClickEvents: function () {
+        var _this = this
+        /*------ 关闭弹窗事件  点击取消或遮罩层 -----*/
+        $('.weui-mask').click(hideDialog);
+        $('.cancel').click(hideDialog);
 
+        // 确认订阅周期
+        $('#enter_period').on('click', function () {
+            $('.weui-mask').trigger('click')
+            _this.calcDuration(true)
+            _this.setPrice(_this.calcPrice())
+        })
 
-$(function () {
-    purchase.initData();
-    purchase.showArea();
-    purchase.showIndustry();
-    purchase.showPrice();
-    purchase.showTime();
-    purchase.showTip();
-    purchase.flushPrice(purchase.timeSelect);
-    purchase.flushSubmit();
-    var time_limit; //定义一个周期变量
-    /*------ 关闭弹窗事件  点击取消或遮罩层 -----*/
-    $('.weui-mask').click(hideDialog);
-    $('.cancel').click(hideDialog);
+        $('.vip-footer.renew .confirm').on('click', function () {
+            $('.vip-footer.renew .confirm').prop('disabled', true)
+            //支付请求
+            var data = {
+                userLotteryId :coupon.$refs.couponRef.coupon.userLotteryId,
+                lotteryId : coupon.$refs.couponRef.coupon.lotteryId,
+                time : _this.getDuration(_this.timeSelect).s.trim(),
+                orderType: 5,
+                disWord :GetQueryString('disWord'),
+                price: _this.price
+            }
+            $.ajax({
+                // url: '/subscribepay/vipsubscribe/createOrder',
+                url: '/subscribepay/vipsubscribe/renew',
+                type: 'POST',
+                data: data,
+                success: function (r) {
+                    $('.vip-footer.renew .confirm').prop('disabled', false)
+                    clearSessionStorage()
+                    if (r.success) {
+                        try {
+                            history.replaceState({}, '', '/jyapp/vipsubscribe/toOrderDetailPage?orderCode=' + r.data.code);
+                            window.location.href = "/jyapp/pay/checkout_subvip?orderCode=" + r.data.code + "&t=1&from=buy"
+                        } catch (e) {
+                            showToast(e)
+                        }
+                    } else {
+                        showToast(r.errMsg || '请求失败')
+                    }
+                    
+                }
+            })
+        })
+    },
+    initPickerEvents: function () {
+        var _this = this
+        /* -----  订阅周期弹窗弹出事件 -------*/
+        // 选择订阅周期
+        $('.select_cycle a').click(function (e) {
+            _this.onTimePickerChange()
+            $('#time_cycle').show(200);
+        });
 
-    /* -----  订阅周期、支付方式弹窗弹出事件 -------*/
-    // 选择订阅周期
-    $('.select_cycle a').click(function (e) {
-        $('#time_cycle').show(200);
-    });
+        // 对订阅时间选择的input绑定点击事件
+        $('#time_cycle input:radio[name="time"]').on('click', function (e) {
+            // 解除确认按钮的锁定
+            if ($(e.target).hasClass('monthly') !== $('#number_box_month').hasClass('active')) {
+                $('#time_cycle .form-btn button').removeAttr('disabled');
+            }
+            if ($(e.target).hasClass('monthly')) {
+                // 按月订阅
+                $('#number_box_month').addClass('active');
+                $('#number_box_year span').removeClass('active');
+            } else {
+                // 按年订阅
+                $('#number_box_month').removeClass('active');
+            }
+        });
 
+        /* --------控制月份number_box的事件  点击加减号触发的事件------- */
+        $('#number_box_month').on('click', 'button', function (e) {
+            // 点击加减号让input radio选中
+            $('#monthly').prop('checked', true);
+            $('#yearly').prop('checked', false);
+            $('.number_box span').removeClass('active');
+            $('#number_box_month').addClass('active');
 
-    /* -----  选择完支付方式、订阅周期 回显到页面 -------*/
-    $('.vip-body .pay-mode').on('click', function () {
-        pickerShow('#pay_way', true)
-    });
+            var $number = $('#number_box_month span.month_number');
+            var $monthlyInput = $('#monthly');
+            // 未整理的data数组,里面的值都是字符串
+            var preData = e.delegateTarget.dataset;
+            var currentNum = parseInt($number.text());
+            var data = {};
+            // 把字符串转换成数字
+            for (var i in preData) {
+                data[i] = preData[i] - 0
+            }
 
-    $('#pay_way input:radio[name="way"]').click(function () {
-        var checkValue = $('input:radio[name="way"]:checked').val();
-        pickerShow('#pay_way', false)
-        $('.vip-body .pay-mode .pay-mode-text').text(checkValue);
-        if (checkValue === "微信支付") {
-            purchase.payWay = "wx_app"
-        } else {
-            purchase.payWay = "ali_app"
-        }
-        sessionStorage.setItem("payWay", purchase.payWay);
-    });
+            if (!$monthlyInput.prop('checked')) {
+                return
+            }
+            // 判断是点击的是+ 还是-
+            if ($(e.target).hasClass('add') || $(e.currentTarget).hasClass('add')) {
+                if (currentNum == 11) { //12个月自动跳转1年
+                    $("#number_box_year .year_number:eq(0)").trigger("click");
+                    return
+                }
+                // 点的+
+                currentNum = currentNum >= data.numboxMax ? data.numboxMax : (currentNum + data.numboxStep);
+            } else {
+                // 点的-
+                currentNum = currentNum <= data.numboxMin ? data.numboxMin : (currentNum - data.numboxStep);
+            }
+            $number.text(currentNum);
 
+            _this.onTimePickerChange()
 
-    // 对订阅时间选择的input绑定点击事件
-    $('#time_cycle input:radio[name="time"]').on('click', function (e) {
-        // 解除确认按钮的锁定
-        if ($(e.target).hasClass('monthly') !== $('#number_box_month').hasClass('active')) {
-          $('#time_cycle .form-btn button').removeAttr('disabled');
-        }
-        if ($(e.target).hasClass('monthly')) {
-            // 按月订阅
-            $('#number_box_month').addClass('active');
-            $('#number_box_year span').removeClass('active');
-        } else {
-            // 按年订阅
+            var firstButton = $('#number_box_month button:first');
+            var lastButton = $('#number_box_month button:last');
+            // 如果为操作后的结果为1,则锁定减号按钮
+            if (currentNum === data.numboxMin) {
+                firstButton.attr('disabled', true)
+            } else {
+                firstButton.removeAttr('disabled')
+            }
+            // 如果为操作后的结果为12,则锁定加号按钮
+            if (currentNum === data.numboxMax) {
+                lastButton.attr('disabled', true)
+            } else {
+                lastButton.removeAttr('disabled')
+            }
+        });
+
+        /* -------- 控制年份number_box的事件  点击1年 2年 3年触发的事件------- */
+        $('#number_box_year').on('click', 'span', function (e) {
             $('#number_box_month').removeClass('active');
-            // $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active');
-        }
-    });
+            var id = e.target.dataset.id;
+            $(this).addClass('active').siblings().removeClass('active');
+            $('#yearly').prop('checked', true);
+            $("#monthly").prop('checked', false);
 
-    /* --------控制月份number_box的事件  点击加减号触发的事件------- */
-    $('#number_box_month').on('click', 'button', function (e) {
-        // 点击加减号让input radio选中
-        $('#monthly').prop('checked', true);
-        $('#yearly').prop('checked', false);
-        $('.number_box span').removeClass('active');
-        $('#number_box_month').addClass('active');
+            _this.onTimePickerChange()
+        });
 
-        var $number = $('#number_box_month span.month_number');
-        var $monthlyInput = $('#monthly');
-        // 未整理的data数组,里面的值都是字符串
-        var preData = e.delegateTarget.dataset;
-        var currentNum = parseInt($number.text());
-        var data = {};
-        // 把字符串转换成数字
-        for (var i in preData) {
-            data[i] = preData[i] - 0
-        }
-
-        if (!$monthlyInput.prop('checked')) {
-            return
-        }
-        // 判断是点击的是+ 还是-
-        if ($(e.target).hasClass('add') || $(e.currentTarget).hasClass('add')) {
-            if (currentNum == 11) { //12个月自动跳转1年
-                $("#number_box_year .year_number:eq(0)").trigger("click");
-                return
+        /* -------- 选择按月订阅  radio触发的事件------- */
+        $('#monthly').on('change', function (e) {
+            var isChecked = $(this).is(':checked');
+            var val = $('.month_number').text();
+            if (!isChecked) {
+                $('#number_box_month button').attr('disabled', true)
             }
-            // 点的+
-            currentNum = currentNum >= data.numboxMax ? data.numboxMax : (currentNum + data
-                .numboxStep);
-        } else {
-            // 点的-
-            currentNum = currentNum <= data.numboxMin ? data.numboxMin : (currentNum - data
-                .numboxStep);
-        }
-        $number.text(currentNum);
-        purchase.timeSelect_tmp = [Number(currentNum), 2];
-        purchase.flushPrice(purchase.timeSelect_tmp, 2);
-        //var price = (5.8 * currentNum).toFixed(1);
-        //$('.computed_price').html('¥' + price)
-        var firstButton = $('#number_box_month button:first');
-        var lastButton = $('#number_box_month button:last');
-        /*if (currentNum >= 10) {
-            $('.profit_tips').text("已选择" + currentNum + "个月,建议“按年订阅”").show();
-        } else {
-            $('.profit_tips').hide();
-        }*/
-        // 如果为操作后的结果为1,则锁定减号按钮
-        if (currentNum === data.numboxMin) {
-            firstButton.attr('disabled', true)
-        } else {
-            firstButton.removeAttr('disabled')
-        }
-        // 如果为操作后的结果为12,则锁定加号按钮
-        if (currentNum === data.numboxMax) {
-            lastButton.attr('disabled', true)
-        } else {
-            lastButton.removeAttr('disabled')
-        }
-    });
+            _this.onTimePickerChange()
+        });
 
-    /* -------- 控制年份number_box的事件  点击1年 2年 3年触发的事件------- */
-    $('#number_box_year').on('click', 'span', function (e) {
-        // console.log(e.target.dataset.id);
-        $('#number_box_month').removeClass('active');
-        var id = e.target.dataset.id;
-        //$('.profit_tips').hide();
-        $(this).addClass('active').siblings().removeClass('active');
-        $('#yearly').prop('checked', true);
-        $("#monthly").prop('checked', false);
+        /* -------- 选择按年订阅  radio触发的事件------- */
+        $('#yearly').on('change', function (e) {
+            var isChecked = $(this).is(':checked');
+            // 按年订阅默认选择1年
+            var val = 1;
+            if (isChecked) {
+                $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
+            }
 
-        // 渲染结果 保留一位小数
-        //var result = (Number(id) * 58).toFixed(1);
-        //$('.computed_price').html('¥' + result)
-        purchase.timeSelect_tmp = [Number(id), 1];
-        purchase.flushPrice(purchase.timeSelect_tmp, 2);
-    });
+            _this.onTimePickerChange()
+        });
 
-    /* -------- 选择按月订阅  radio触发的事件------- */
-    $('#monthly').on('change', function (e) {
-        var isChecked = $(this).is(':checked');
-        var val = $('.month_number').text();
-        /*if (val >= 10) {
-            $('.profit_tips').show()
-        }*/
-        if (!isChecked) {
-            $('#number_box_month button').attr('disabled', true)
-        }
-        //var result = (Number(val) * 5.8).toFixed(1);
-        //$('.computed_price').html('¥' + result);
-        purchase.timeSelect_tmp = [Number(val), 2];
-        purchase.flushPrice(purchase.timeSelect_tmp, 2);
-    });
-    //计价清单
-    $('.billing-list-btn').on('click', function () {
-        pickerShow('.billing-list-container', true)
-    })
-    // 计算标准隐藏
-    $('.billing-list-container .dialog_hd__close').on('click', function () {
-        pickerShow('.billing-list-container', false)
-    })
+        // 计价标准
+        $('.billing-list-btn').on('click', function () {
+            pickerShow('.billing-list-container', true)
+        })
+        // 计算标准隐藏
+        $('.billing-list-container .dialog_hd__close').on('click', function () {
+            pickerShow('.billing-list-container', false)
+        })
 
-    $('.checkbox').on('click', function () {
-        $(this).toggleClass('checked')
-        var state = $(this).hasClass('checked');
-        sessionStorage.setItem("vipSub_read", state);
-        purchase.flushSubmit();
-        //$('.vip-footer.renew .confirm').prop('disabled', !state)
-    });
-    //是否点击已读
-    if (sessionStorage.getItem("vipSub_read") === "true") {
-      $('.checkbox').addClass("checked");
+        $('.checkbox').on('click', function () {
+            $(this).toggleClass('checked')
+            var state = $(this).hasClass('checked')
+            sessionStorage.setItem("vipSub_read", state)
+            renew.flushSubmit()
+        });
     }
+}
+$(function () {
+    renew.init()
+})
 
-    /* -------- 选择按年订阅  radio触发的事件------- */
-    $('#yearly').on('change', function (e) {
-        //$('.profit_tips').hide();
-        // console.log($(this).is(':checked'))
-        var isChecked = $(this).is(':checked');
-        // 按年订阅默认选择1年
-        var val = 1;
-        //$('.computed_price').html('¥' + Number(val) * 58)
-        if (isChecked) {
-            $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
-        }
-        purchase.timeSelect_tmp = [Number(val), 1];
-        purchase.flushPrice(purchase.timeSelect_tmp, 2);
-        purchase.flushSelectTime(purchase.timeSelect_tmp, 2);
-    });
-
-    // 确认订阅周期
-    $('#enter_period').on('click', function () {
-        var val;
-        var selectedDOM = $('#time_cycle input[name=time]:checked');
-        if (selectedDOM.val() === 'year') {
-            val = $('#number_box_year .year_number.active').attr('data-id');
-            purchase.timeSelect_tmp = [parseInt(val), 1];
-            $('#time_cycle').hide(function () {
-                purchase.timeValue = val + "年";
-            });
-        } else if (selectedDOM.val() === 'month') {
-            val = $('#number_box_month .month_number').text();
-            purchase.timeSelect_tmp = [parseInt(val), 2];
-            $('#time_cycle').hide(function () {
-                purchase.timeValue = val + "个月";
-            });
-        }
-        purchase.timeSelect = purchase.timeSelect_tmp;
-        purchase.showTime();
-        purchase.flushPrice(purchase.timeSelect, 1);
-        sessionStorage.setItem("vipSubSelectTime", JSON.stringify(purchase.timeSelect));
-    });
-    $('.vip-footer.renew .confirm').click(function () {
-        $('.vip-footer.renew .confirm').attr("disabled", "disabled");
-        //支付请求
-        var area = purchase.areaSelect;
-        var industry = purchase.industrySelect;
-        if (area["全国"]) {
-            area = {};
-        }
-        if (industry.length === 1 && industry[0] === "全部行业") {
-            industry = [];
-        }
-        //优惠码
-        /*var activeCode = $('.coupon-picker .weui-input').val();
-        var activeCodes = "";
-        if (activeCode.toLowerCase() === couponInfo.code && $('.coupon-code-tx .keywords-text').text() === couponInfo.successTip){
-            activeCodes = couponInfo.code;
-        }*/
-        //付费用户
-        var param = {
-            "userLotteryId":coupon.$refs.couponRef.coupon.userLotteryId,
-            "lotteryId": coupon.$refs.couponRef.coupon.lotteryId,
-            "area": JSON.stringify(area),
-            "industry": industry.join(","),
-            "time": purchase.timeValue.trim(),
-            "orderType": 5,
-            "disWord":GetQueryString("disWord"),
-        };
-        $DoPost("/subscribepay/vipsubscribe/createOrder", param, function (r) {
-            if (r.success) {
-                try {
-                    clearSessionStorage()
-                    history.replaceState({}, '', '/jyapp/vipsubscribe/toOrderDetailPage?orderCode=' + r.data.code);
-                    window.location.href = "/jyapp/pay/checkout_subvip?orderCode=" + r.data.code + "&t=1&from=buy"
-                } catch (e) {
-                    showToast(e)
-                }
-            }
-        }, false);
-        $('.vip-footer.renew .confirm').removeAttr("disabled");
-    })
-
-});
 
 //获取url中"?"符后的字符串并正则匹配
 function GetQueryString(name) {
@@ -529,13 +464,10 @@ function hideDialog() {
 }
 
 function clearSessionStorage() {
-    sessionStorage.removeItem("vipSubSelectArea");
-    sessionStorage.removeItem("vipSubSelectIndustry");
     sessionStorage.removeItem("vipSubSelectTime");
     sessionStorage.removeItem("vipSub_read");
     sessionStorage.removeItem("historypushDataCache");
     sessionStorage.removeItem("endTime");
-    sessionStorage.removeItem("payWay");
     sessionStorage.To_introducePage = 2;
     //订阅首页
     sessionStorage.removeItem("sub_vip_state");
@@ -546,7 +478,12 @@ function clearSessionStorage() {
     sessionStorage.removeItem("liveActiveCode_renew");
     sessionStorage.removeItem("liveActiveCode_new");
 }
-
+function showToast(text) {
+    weui.toast(text, {
+        duration: 3000,
+        className: 'jy-toast',
+    })
+}
 function pickerShow(selector, f) {
     if (f) {
         // 添加进场动画,并显示
@@ -601,16 +538,18 @@ var coupon = new Vue({
     },
     // 校验checkbox
     checkSubmitStatus: function (checkStatus) {
-      sessionStorage.setItem("vipSub_read", checkStatus);
-      purchase.flushSubmit();
-      return purchase.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true"
+      sessionStorage.setItem("vipSub_read", checkStatus)
+      renew.flushSubmit()
+      return renew.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true"
     },
     saveEvent: function () {
+      renew.saveState()
       sessionStorage.setItem("pay_read_cache", "0");
     },
     // 阅读协议点击事件
     readEvent: function () {
-      toRead()
+        renew.saveState()
+        toRead()
     },
     // 订单提交事件
     submitOrder: function () {

+ 41 - 73
src/jfw/modules/app/src/web/templates/vipsubscribe/vip_renew.html

@@ -3,8 +3,7 @@
 
 <head>
     <meta charset="UTF-8">
-    <meta name="viewport"
-          content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>超级订阅续费</title>
     <meta name="apple-mobile-web-app-capable" content="yes">
@@ -82,7 +81,7 @@
                             <span class="sub-l" style="white-space:nowrap;">有效日期:</span>
                             <span class="sub-r ellipsis">
                             <span class="ellipsis">
-                                (<span class="month">3个月</span>)<span class="duration"></span>
+                                (<span class="month">0个月</span>)<span class="duration"></span>
                             </span>
                         </span>
                         </div>
@@ -103,6 +102,13 @@
                     </div>
                 </li>
             </ul>
+            <div class="tips">
+                <div class="tip-title l-line">续费说明</div>
+                <div class="tip-content">
+                    <div>1、仅支持原套餐延长周期续费,不支持套餐变更(含增加、减少、更改)原订阅的省份、城市、行业。 <br />续费费用=续费周期(按月/年)/原地区/原行业</div>
+                    <div>2、套餐周期内,用户也可以选择升级超级订阅2.0版享受更多权益。</div>
+                </div>
+            </div>
         </div>
         <!-- vue组件 -->
         <div class="vip-footer" id="coupon-vue">
@@ -137,52 +143,50 @@
                 </div>
             </div>
             <div class="footer-button-group j-button-group">
-                <!--<button class="button-l reset">取消</button>-->
                 <button data-need-bind-phone style="height: 0.92rem!important;line-height: 0.92rem;" class="button-r confirm j-button-confirm" disabled>提交订单</button>
             </div>
         </div>
     </div>
 
-        <!-- 优惠明细 -->
-        <div class="j-picker adaption discount-details" style="display:none;">
-            <div class="weui-mask"></div>
-            <div class="weui-half-screen-dialog weui-picker">
-                <div class="weui-half-screen-dialog__hd">
-                    <div class="weui-half-screen-dialog__hd__main">
-                        <strong class="weui-half-screen-dialog__title">优惠明细</strong>
-                    </div>
-                    <span class="j-icon icon-del-grey cancel"></span>
+    <!-- 优惠明细 -->
+    <div class="j-picker adaption discount-details" style="display:none;">
+        <div class="weui-mask"></div>
+        <div class="weui-half-screen-dialog weui-picker">
+            <div class="weui-half-screen-dialog__hd">
+                <div class="weui-half-screen-dialog__hd__main">
+                    <strong class="weui-half-screen-dialog__title">优惠明细</strong>
                 </div>
-                <div class="weui-half-screen-dialog__bd">
-                    <div class="weui-picker__bd">
-                        <div class="details-bd-item origin-price">
-                            <div class="d-b-left">原价</div>
-                            <div class="d-b-right">
-                                <span class="dis-mon">&yen;</span>
-                                <span class="dis-price price-num">0</span>
-                            </div>
+                <span class="j-icon icon-del-grey cancel"></span>
+            </div>
+            <div class="weui-half-screen-dialog__bd">
+                <div class="weui-picker__bd">
+                    <div class="details-bd-item origin-price">
+                        <div class="d-b-left">原价</div>
+                        <div class="d-b-right">
+                            <span class="dis-mon">&yen;</span>
+                            <span class="dis-price price-num">0</span>
                         </div>
-                        <div class="details-bd-item discount-price">
-                            <div class="d-b-left">限时优惠</div>
-                            <div class="d-b-right text-red">
-                                <span class="dis-mon">-&yen;</span>
-                                <span class="dis-price">0</span>
-                            </div>
+                    </div>
+                    <div class="details-bd-item discount-price">
+                        <div class="d-b-left">限时优惠</div>
+                        <div class="d-b-right text-red">
+                            <span class="dis-mon">-&yen;</span>
+                            <span class="dis-price">0</span>
                         </div>
-                        <div class="details-bd-item now-price">
-                            <div class="d-b-left">实付</div>
-                            <div class="d-b-right text-red">
-                                <span class="dis-mon">&yen;</span>
-                                <span class="dis-price">0</span>
-                            </div>
+                    </div>
+                    <div class="details-bd-item now-price">
+                        <div class="d-b-left">实付</div>
+                        <div class="d-b-right text-red">
+                            <span class="dis-mon">&yen;</span>
+                            <span class="dis-price">0</span>
                         </div>
                     </div>
                 </div>
             </div>
         </div>
+    </div>
 
-
-        <!-- 计费清单picker -->
+    <!-- 计费清单picker -->
     <div class="billing-list-container p13" style="display: none;">
         <div class="weui-mask weui-animate-fade-in"></div>
         <div class="weui-half-screen-dialog weui-picker weui-animate-slide-up">
@@ -307,42 +311,7 @@
             </div>
         </div>
     </div>
-    <!-- 选择支付方式 -->
-    <div class="js_dialog pay_way" id="pay_way" style="display: none;">
-        <div class="weui-mask"></div>
-        <div class="box">
-            <div class="box_hd">
-                <span></span>
-                <h3>支付方式</h3>
-                <span class="cancel">取消</span>
-            </div>
-            <div class="box_bd">
-                <div class="weui-cells weui-cells_checkbox choose-form">
-                    <label class="weui-cell weui-check__label wx_label" for="wx">
-                        <div class="weui-cell__bd read">
-                            <i class="icon-wx"></i>
-                            <p>微信支付</p>
-                        </div>
-                        <div class="weui-cell__hd">
-                            <input type="radio" class="weui-check" name="way" value="微信支付" id="wx" checked/>
-                            <i class="weui-icon-checked"></i>
-                        </div>
-                    </label>
-                    <label class="weui-cell weui-check__label zfb_label" for="zfb">
-                        <div class="weui-cell__bd read">
-                            <i class="icon-zfb"></i>
-                            <p>支付宝支付</p>
-                        </div>
-                        <div class="weui-cell__hd">
-                            <input type="radio" class="weui-check" name="way" value="支付宝支付" id="zfb"/>
-                            <i class="weui-icon-checked"></i>
-                        </div>
-                    </label>
-                </div>
-            </div>
-        </div>
-    </div>
-	<!-- 优惠码弹窗 -->
+    <!-- 优惠码弹窗 -->
 	<div class="j-picker adaption coupon-picker" style="display:none;">
 	    <div class="weui-mask weui-animate-fade-in"></div>
 	    <div class="weui-half-screen-dialog weui-picker weui-animate-slide-up">
@@ -366,10 +335,8 @@
 	    </div>
 	</div>
     <script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/jquery.min.js"></script>
-    <!--<script src='{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/js/check-bind-phone.js?v={{Msg "seo" "version"}}'></script>-->
     <script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/local/weui.min.js"></script>
     <script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}"></script>
-    <script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/js/UpgradePrice.js?v={{Msg "seo" "version"}}"></script>
     <script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/js/common.js?v={{Msg "seo" "mod_version"}}"></script>
   {{include "/common/iosJS.html"}}
     <script src=//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js></script>
@@ -434,6 +401,7 @@
         }
       }
 	</script>
+	<script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/js/price.js?v={{Msg "seo" "version"}}"></script>
 	<script src="{{Cdns .Host "seo" "cdn"|SafeUrl}}/jyapp/vipsubscribe/js/vip_renew.js?v={{Msg "seo" "version"}}"></script>
 </div>
 {{include "/common/baiducc.html"}}

+ 0 - 16
src/jfw/modules/subscribepay/src/entity/subscribeVip.go

@@ -436,22 +436,6 @@ func (this *vipSubscribeStruct) SubChange(userId string, oldVip, areaNew *map[st
 	return true
 }
 
-//校验订单是否可以创建是否合法,返回user表查询信息
-func (this *vipSubscribeStruct) OrderCheck(userId string, orderType int) (bool, *map[string]interface{}) {
-	res, ok := util.MQFW.FindById("user", userId, `{"l_vip_endtime":1,"i_vip_status":1,"o_vipjy":1}`)
-	if !ok || len(*res) == 0 {
-		return false, nil
-	}
-	vipStatus := qutil.IntAll((*res)["i_vip_status"])
-	switch orderType { //1:订单 2:续费 3:立即升级 4:下月升级 5:即将到期(升降级)
-	case 1: //新订单 用户不能处于vip状态
-		return vipStatus != 2, res
-	case 5: //续费 用户需要处于vip状态
-		return vipStatus == 2, res
-	}
-	return false, nil
-}
-
 //获取省份,城市,行业购买内容
 //[省份,城市,行业]
 func (this *vipSubscribeStruct) GetVipDetail(userId string) (*map[string]interface{}, *SubvipBuySet, bool) {

+ 10 - 10
src/jfw/modules/subscribepay/src/service/vipSubscribeChange.go

@@ -24,6 +24,7 @@ type SubscribeChange struct {
 	getSubBuyMsg  xweb.Mapper `xweb:"/vipsubscribe/getSubBuyMsg"`  //获取vip订阅详情
 	saveChange    xweb.Mapper `xweb:"/vipsubscribe/saveChange"`    //订阅修改
 	mergeIndustry xweb.Mapper `xweb:"/vipsubscribe/mergeIndustry"` //行业合并
+	upgrade       xweb.Mapper `xweb:"/vipsubscribe/upgrade"`       //升级超级订阅
 }
 
 func init() {
@@ -235,7 +236,7 @@ func (this *SubscribeChange) Upgrade() {
 			"dis_word":       disWord,
 			"discount_price": discount_price,
 			"d_relation_id":  userLotteryId,
-			"vip_type":       2, //1:续费 2:升级
+			"vip_type":       3, //立即升级
 			"user_phone":     order_phone,
 		}
 		if order_phone != "" {
@@ -284,7 +285,6 @@ func getNewUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySe
 			if this_price < 0 {
 				return -1, nil
 			}
-			log.Println("---------------this_price:", this_price)
 			totalPrice += this_price
 			subtotals = append(subtotals, map[string]interface{}{
 				"type":      1,
@@ -299,7 +299,6 @@ func getNewUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySe
 	//当前升级
 	now := time.Now()
 	price_now := getSubtotalPrice(oldBuySet, newBuySet, now.Unix(), nowEndTime)
-	log.Println("~~~~~~~~2", price_now)
 	if price_now < 0 {
 		return -1, nil
 	}
@@ -315,7 +314,6 @@ func getNewUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySe
 	if count > 0 {
 		renew_price := entity.JyVipSubStruct.GetSubVipPriceByBuySet(newBuySet, count, unit, false)
 		if renew_price < 0 {
-			log.Println("~~~~~~~~3", renew_price)
 			return -1, nil
 		}
 		totalPrice += renew_price
@@ -326,6 +324,7 @@ func getNewUpgradeDetail(userId string, newBuySet, oldBuySet *entity.SubvipBuySe
 			"price":     renew_price,
 		})
 	}
+	log.Printf("%s升级所需费用%d 计价清单%v\n", userId, totalPrice, subtotals)
 	return totalPrice, subtotals
 }
 
@@ -491,12 +490,13 @@ func needUpgrade(newBuySet, oldBuySet *entity.SubvipBuySet) bool {
 
 //获取升级小计价格
 func getSubtotalPrice(oldBuyset, newBuyset *entity.SubvipBuySet, startTime, endtime int64) int {
-	//不能降级
-	pCount := oldBuyset.AreaCount
-	if oldBuyset.Upgrade != 1 {
-		pCount = oldBuyset.AreaCount + len(oldBuyset.NewCitys)
-	}
-	if newBuyset.AreaCount < pCount {
+
+	if !func() bool { //不能降级
+		if oldBuyset.Upgrade == 1 {
+			return (newBuyset.AreaCount == -1 && oldBuyset.AreaCount != -1) || newBuyset.AreaCount > oldBuyset.AreaCount
+		}
+		return newBuyset.AreaCount == -1 || newBuyset.AreaCount >= oldBuyset.AreaCount+len(oldBuyset.NewCitys)
+	}() {
 		return -1
 	}
 

+ 24 - 16
src/jfw/modules/subscribepay/src/service/vipSubscribePay.go

@@ -24,7 +24,6 @@ type SubVipPayOrder struct {
 	*xweb.Action
 	getPrice    xweb.Mapper `xweb:"/vipsubscribe/getPrice"`    //获取价格
 	createOrder xweb.Mapper `xweb:"/vipsubscribe/createOrder"` //创建订单并支付
-	upgrade     xweb.Mapper `xweb:"/vipsubscribe/upgrade"`     //升级超级订阅
 	renew       xweb.Mapper `xweb:"/vipsubscribe/renew"`       //续费超级订阅
 }
 
@@ -79,13 +78,29 @@ func (this *SubVipPayOrder) CreateOrder() {
 			}
 		}
 		now := time.Now()
-		if !(orderType == 1 || orderType == 5) {
-			return &entity.FuncResult{false, errors.New("参数异常"), nil}
-		}
-		createOk, userData := entity.JyVipSubStruct.OrderCheck(userId, orderType)
-		if !createOk { //校验订单
-			return &entity.FuncResult{false, errors.New("非法请求"), nil}
+
+		userData, oldBuyset, _ := entity.JyVipSubStruct.GetVipDetail(userId)
+
+		pass := func() bool { //校验订单是否合法
+			if orderType == 1 {
+				vipStatus := qutil.IntAll((*userData)["i_vip_status"])
+				if vipStatus > 1 { //仅非VIP用户购买
+					return false
+				}
+			} else if orderType == 5 { //仅即将到期用户购买
+				endTime := qutil.Int64All((*userData)["l_vip_endtime"])
+				if endTime > now.Unix()+60*60*24*7 {
+					return false
+				}
+			} else {
+				return false
+			}
+			return true
+		}()
+		if !pass {
+			return &entity.FuncResult{false, fmt.Errorf("非法请求"), nil}
 		}
+
 		date_count, date_unit, err := checkReqDate(date)
 		if err != nil {
 			return &entity.FuncResult{false, err, nil}
@@ -100,21 +115,14 @@ func (this *SubVipPayOrder) CreateOrder() {
 			OrderType:  orderType,
 			DisWord:    disWord,
 		}
-		//续费单子
+		//即将到期
 		if orderType == 5 {
-			log.Println(userData)
 			o_vipjy := qutil.ObjToMap((*userData)["o_vipjy"])
 			thisBuySet := qutil.ObjToMap((*o_vipjy)["o_buyset"])
-			log.Println(thisBuySet)
 			if len(*thisBuySet) == 0 {
 				return &entity.FuncResult{false, errors.New("创建续费订单出错"), nil}
 			}
-			filter.OldBuyset = &entity.SubvipBuySet{
-				qutil.IntAll((*thisBuySet)["upgrade"]),
-				qutil.IntAll((*thisBuySet)["areacount"]),
-				util.ConfirmIntArr((*thisBuySet)["newcitys"].([]interface{})),
-				qutil.IntAll((*thisBuySet)["buyerclasscount"]),
-			}
+			filter.OldBuyset = oldBuyset
 		}
 		//插入订单表
 		mog_id := entity.JyVipSubStruct.SaveSelectLog(userId, openId, &filter)

+ 1 - 1
src/jfw/modules/weixin/src/config.json

@@ -114,7 +114,7 @@
 	"reply":[
         {
         		"text":"Hi~欢迎关注剑鱼标讯!\n\n每日更新10万+招标采购信息,\n定制项目监控,实时跟踪全部销售线索,\n已帮助数百万用户获取全网商机!\n\n点击这里<a href='%s'>免费订阅</a>,帮你抓住每个业务机会!\n\n【超级订阅】\n<a href='%s'>点击订阅</a>,立享380-100。\n●直接对接项目联系人!\n● 招标动态第一时间推送!\n● 大容量300组关键词。\n● 每日可查看2000条招标采购信息。\n● 提供企业画像,透视中标项目、重点客户。\n● 搜索全国七千万企业信息,获取商业情报。",
-			"href":["keysetIndex","viphomepage"]
+			"href":["keysetIndex","viphomepage_new"]
         }
 	],
 	"newYearReply":{

+ 24 - 0
src/web/staticres/vipsubscribe/css/vip_renew.css

@@ -716,3 +716,27 @@
   flex: 1;
   justify-content: flex-start;
 }
+.tip-title {
+  margin: .3rem .22rem;
+  text-align: left;
+  color: #171826;
+  line-height: .4rem;
+}
+.tip-content {
+  color: #5F5E64;
+  line-height: .36rem;
+}
+.l-line {
+  position: relative;
+}
+.l-line:before {
+  content: '';
+  position: absolute;
+  left: -0.22rem;
+  top: 50%;
+  width: .06rem;
+  height: .32rem;
+  background-color: #2ABED1;
+  transform: translateY(-50%);
+  border-radius: .06rem;
+}

+ 561 - 0
src/web/staticres/vipsubscribe/js/vip_renew.js

@@ -0,0 +1,561 @@
+var renew = {
+    oldRules: Calculation.PriceRule.old,
+    newRules: Calculation.PriceRule.new,
+    requestRules: {},
+    price: '', // 单位分
+    timeSelect: [1, 2], // 续费周期(默认选中1个月)
+    timeCheckOk: true,
+    buyInfo: { // 购买的信息
+        startTime: 0,
+        endTime: 0,
+        area: {},
+        industry: [],
+        buyset: {
+            areacount: 0,
+            newcitys: [],
+            buyerclasscount: 3
+        },
+        isTrial: false,
+        renewList: []
+    },
+    init: function () {
+        this.recoverState()
+        this.getPrice()
+        this.getBuySetInfo()
+        this.initEvents()
+    },
+    setAreaAndIndustry: function () {
+        var buySet = this.buyInfo.buyset
+        var result = {
+            area: '',
+            industry: ''
+        }
+        // 区域
+        if (buySet.areacount === -1) {
+            result.area = '全国'
+        } else {
+            var strArr = []
+            if (buySet.areacount) {
+                strArr.push(buySet.areacount + '个省')
+            }
+            if (buySet.newcitys && buySet.newcitys.length !== 0) {
+                var count = 0
+                buySet.newcitys.forEach(function (item) {
+                    count += item
+                })
+                strArr.push(count + '个市(分布在' + buySet.newcitys.length + '个省内')
+            }
+            result.area = strArr.join('、')
+        }
+
+        // 行业(3个行业价格和全部行业价格相同,当购买3个以上行业页面显示全部行业)
+        if (buySet.buyerclasscount === -1 || buySet.buyerclasscount >= 3) {
+            result.industry = '全部行业'
+        } else {
+            result.industry = buySet.buyerclasscount + '个行业'
+        }
+
+        $('.area .item-r').text(result.area)
+        $('.industry .item-r').text(result.industry)
+
+        return result
+    },
+    initEvents: function () {
+        this.initClickEvents()
+        this.initPickerEvents()
+    },
+    getBuySetInfo: function () {
+        var _this = this
+        $.ajax({
+            url: '/subscribepay/vipsubscribe/getSubBuyMsg',
+            type: 'POST',
+            success: function (r) {
+                if (r.success && r.data) {
+                    Object.assign(_this.buyInfo, r.data)
+                    _this.setAreaAndIndustry()
+                    _this.checkShowDueTip()
+                    // 初始化默认续费周期
+                    _this.calcDuration(true)
+                    // 初始化价格计算类
+                    Calculation.Init(
+                        false,
+                        new Buyset(_this.buyInfo.buyset.areacount, _this.buyInfo.buyset.newcitys, _this.buyInfo.buyset.buyerclasscount)
+                    )
+                    // 初始化默认金额
+                    _this.setPrice(_this.calcPrice())
+                }
+            }
+        })
+    },
+    getPrice: function () {
+        var _this = this
+        $.ajax({
+            url: '/subscribepay/vipsubscribe/getPrice',
+            type: 'POST',
+            success: function (r) {
+                if (r) {
+                    _this.requestRules = r
+                }
+            }
+        })
+    },
+    calcPrice: function () {
+        return Calculation.GetTotal(undefined, this.timeSelect)
+    },
+    setPrice: function (price) {
+        this.price = price
+        coupon.updatePrice(formatMoney(this.price / 100))
+    },
+    // 根据选中结果得到一个时间段的时间戳
+    getDuration: function (timeSelect) {
+        var dStamp = 0
+        var s = ''
+        var perMonthStamp = 1000 * 60 * 60 * 24 * 30
+        if (timeSelect[1] === 1) {
+            // 年
+            dStamp = timeSelect[0] * 12 * perMonthStamp
+            s = timeSelect[0] + '年'
+        } else if (timeSelect[1] === 2) {
+            // 月
+            dStamp = timeSelect[0] * perMonthStamp
+            s = timeSelect[0] + '个月'
+        }
+        return {
+            stamp: dStamp,
+            s: s
+        }
+    },
+    // 计算续费后的日期区间
+    calcDuration: function (needSet) {
+        // 根据
+        var endTime = this.buyInfo.endTime
+        if (!endTime) {
+            $('.select_cycle .duration').hide()
+            return
+        }
+        var durationInfo = this.getDuration(this.timeSelect)
+        var durationStamp = durationInfo.stamp // 续费时间段时间戳
+        var durationStr = durationInfo.s // 续费时间段字符串
+        var buyEndTimeString = new Date(endTime * 1000).pattern('yyyy年MM月dd日') // svip到期时间
+        var renewEndTimeString = new Date(endTime * 1000 + durationStamp).pattern('yyyy年MM月dd日') //续费后到期时间
+
+        if (needSet) {
+            $('.select_cycle .month').text(durationStr)
+            $('.select_cycle .duration').text(buyEndTimeString + ' - ' + renewEndTimeString)
+        } else {
+            return {
+                duration: durationStr, // 续费时间段字符串
+                buyEndTimeString: buyEndTimeString, // svip到期时间
+                renewEndTimeString: renewEndTimeString, //续费后到期时间
+            }
+        }
+    },
+    // 月份转年份(超过1年才会转)
+    monthToYear: function (num) {
+        var year = Math.floor(num / 12)
+        var month = num % 12
+        var str = ''
+        if (year) {
+            str += (year + '年')
+        }
+        if (month) {
+            str += (month + '个月')
+        }
+        return {
+            str: str,
+            year: year,
+            month: month
+        }
+    },
+    checkOver3Years: function () {
+        // 根据
+        var endTime = this.buyInfo.endTime
+        if (!endTime) {
+            return
+        }
+        var maxEndMonth = 36 // 最大续费36个月
+        var durationInfo = this.getDuration(this.timeSelect)
+        var durationStamp = durationInfo.stamp // 续费时间段时间戳
+
+        // 最长订阅周期不可超过3年 ------------
+        var nowStamp = Math.floor(Date.now() / 1000)
+        // 已购买的套餐剩余月数
+        var lastMonthStamp = endTime - nowStamp
+        var lastMonth = Math.ceil(lastMonthStamp / (60 * 60 * 24 * 30))
+        // 续费后套餐剩余月数(需要加上原剩余月数lastMonth)
+        var renewMonthTotalStamp = lastMonthStamp + (durationStamp / 1000)
+        var renewMonthTotal = Math.ceil(renewMonthTotalStamp / (60 * 60 * 24 * 30))
+
+        if (renewMonthTotal > maxEndMonth) {
+            var showTipText = '<div style="white-space: nowrap;">最长订阅周期不可超过3年</div>剩余周期:' + this.monthToYear(lastMonth).str
+            weui.toast(showTipText, {
+                duration: 3000,
+                className: 'jy-toast',
+            })
+            // 确认按钮置灰
+            $('#enter_period').prop('disabled', true)
+        } else {
+            $('#enter_period').prop('disabled', false)
+        }
+    },
+    // 是否展示即将到期
+    checkShowDueTip () {
+        var endTime = this.buyInfo.endTime * 1000
+        var timeSub = endTime - Date.now()
+        if (timeSub > 0 && timeSub < 60 * 60 * 24 * 1000 * 3) {
+            $('.vip-header').show()
+        }
+    },
+    setTimePickerSelected: function (timeSelect) {
+        timeSelect = [1 ,2]
+        if (timeSelect[1] === 1) {
+            // 年
+            dStamp = timeSelect[0] * 12 * perMonthStamp
+            s = timeSelect[0] + '年'
+        } else if (timeSelect[1] === 2) {
+            // 月
+            dStamp = timeSelect[0] * perMonthStamp
+            s = timeSelect[0] + '个月'
+        }
+    },
+    getTimePickerSelected: function () {
+        var timeSelectPicker = $('#time_cycle')
+        var $checkInput = timeSelectPicker.find('input[name=time]:checked')
+        if (!$checkInput) return
+        // year/month(按年或者按月购买)
+        var checkedType = $checkInput.val()
+        // timeSelectedArr[0] 代表选择的内容
+        // timeSelectedArr[1] 代表选择的类型 1年份 2月份
+        var timeSelectedArr = []
+        if (checkedType === 'month') {
+            timeSelectedArr = [$('#number_box_month .month_number').text() - 0, 2]
+        } else if (checkedType === 'year') {
+            timeSelectedArr = [$('#number_box_year .year_number.active').attr('data-id') - 0, 1]
+        }
+        return timeSelectedArr
+    },
+    onTimePickerChange: function () {
+        this.timeSelect = this.getTimePickerSelected()
+        var price = this.calcPrice()
+        $('.computed_price').text(formatMoney(price / 100))
+        this.checkOver3Years()
+    },
+    // 恢复数据
+    recoverState: function () {
+        var vipSubSelectTime = sessionStorage.getItem('vipSubSelectTime')
+        if (vipSubSelectTime) {
+            this.timeSelect = JSON.parse(vipSubSelectTime)
+        }
+        this.flushSubmit()
+    },
+    // 保存数据
+    saveState: function () {
+        sessionStorage.setItem('vipSubSelectTime', JSON.stringify(this.timeSelect))
+    },
+    // 是否可提交
+    flushSubmit: function () {
+        if (this.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true") {
+            $('.vip-footer.renew .confirm').prop('disabled', false)
+            coupon.checkboxStatus = true
+            coupon.$refs.couponRef.submitStatus = false
+        } else {
+            $('.vip-footer.renew .confirm').prop('disabled', true)
+            coupon.$refs.couponRef.submitStatus = true
+        }
+    },
+    initClickEvents: function () {
+        var _this = this
+        /*------ 关闭弹窗事件  点击取消或遮罩层 -----*/
+        $('.weui-mask').click(hideDialog);
+        $('.cancel').click(hideDialog);
+
+        // 确认订阅周期
+        $('#enter_period').on('click', function () {
+            $('.weui-mask').trigger('click')
+            _this.calcDuration(true)
+            _this.setPrice(_this.calcPrice())
+        })
+
+        $('.vip-footer.renew .confirm').on('click', function () {
+            $('.vip-footer.renew .confirm').prop('disabled', true)
+            //支付请求
+            var data = {
+                userLotteryId :coupon.$refs.couponRef.coupon.userLotteryId,
+                lotteryId : coupon.$refs.couponRef.coupon.lotteryId,
+                time : _this.getDuration(_this.timeSelect).s.trim(),
+                orderType: 5,
+                disWord :GetQueryString('disWord'),
+                price: _this.price
+            }
+            $.ajax({
+                // url: '/subscribepay/vipsubscribe/createOrder',
+                url: '/subscribepay/vipsubscribe/renew',
+                type: 'POST',
+                data: data,
+                success: function (r) {
+                    $('.vip-footer.renew .confirm').prop('disabled', false)
+                    clearSessionStorage()
+                    if (r.success) {
+                        try {
+                            history.replaceState({}, '', '/front/vipsubscribe/toOrderDetailPage?orderCode=' + r.data.code);
+                            window.location.href = "/weixin/pay/checkout_subvip?t=1&orderCode=" + r.data.code;
+                        } catch (e) {
+                            showToast(e)
+                        }
+                    } else {
+                        showToast(r.errMsg || '请求失败')
+                    }
+                    
+                }
+            })
+        })
+    },
+    initPickerEvents: function () {
+        var _this = this
+        /* -----  订阅周期弹窗弹出事件 -------*/
+        // 选择订阅周期
+        $('.select_cycle a').click(function (e) {
+            _this.onTimePickerChange()
+            $('#time_cycle').show(200);
+        });
+
+        // 对订阅时间选择的input绑定点击事件
+        $('#time_cycle input:radio[name="time"]').on('click', function (e) {
+            // 解除确认按钮的锁定
+            if ($(e.target).hasClass('monthly') !== $('#number_box_month').hasClass('active')) {
+                $('#time_cycle .form-btn button').removeAttr('disabled');
+            }
+            if ($(e.target).hasClass('monthly')) {
+                // 按月订阅
+                $('#number_box_month').addClass('active');
+                $('#number_box_year span').removeClass('active');
+            } else {
+                // 按年订阅
+                $('#number_box_month').removeClass('active');
+            }
+        });
+
+        /* --------控制月份number_box的事件  点击加减号触发的事件------- */
+        $('#number_box_month').on('click', 'button', function (e) {
+            // 点击加减号让input radio选中
+            $('#monthly').prop('checked', true);
+            $('#yearly').prop('checked', false);
+            $('.number_box span').removeClass('active');
+            $('#number_box_month').addClass('active');
+
+            var $number = $('#number_box_month span.month_number');
+            var $monthlyInput = $('#monthly');
+            // 未整理的data数组,里面的值都是字符串
+            var preData = e.delegateTarget.dataset;
+            var currentNum = parseInt($number.text());
+            var data = {};
+            // 把字符串转换成数字
+            for (var i in preData) {
+                data[i] = preData[i] - 0
+            }
+
+            if (!$monthlyInput.prop('checked')) {
+                return
+            }
+            // 判断是点击的是+ 还是-
+            if ($(e.target).hasClass('add') || $(e.currentTarget).hasClass('add')) {
+                if (currentNum == 11) { //12个月自动跳转1年
+                    $("#number_box_year .year_number:eq(0)").trigger("click");
+                    return
+                }
+                // 点的+
+                currentNum = currentNum >= data.numboxMax ? data.numboxMax : (currentNum + data.numboxStep);
+            } else {
+                // 点的-
+                currentNum = currentNum <= data.numboxMin ? data.numboxMin : (currentNum - data.numboxStep);
+            }
+            $number.text(currentNum);
+
+            _this.onTimePickerChange()
+
+            var firstButton = $('#number_box_month button:first');
+            var lastButton = $('#number_box_month button:last');
+            // 如果为操作后的结果为1,则锁定减号按钮
+            if (currentNum === data.numboxMin) {
+                firstButton.attr('disabled', true)
+            } else {
+                firstButton.removeAttr('disabled')
+            }
+            // 如果为操作后的结果为12,则锁定加号按钮
+            if (currentNum === data.numboxMax) {
+                lastButton.attr('disabled', true)
+            } else {
+                lastButton.removeAttr('disabled')
+            }
+        });
+
+        /* -------- 控制年份number_box的事件  点击1年 2年 3年触发的事件------- */
+        $('#number_box_year').on('click', 'span', function (e) {
+            $('#number_box_month').removeClass('active');
+            var id = e.target.dataset.id;
+            $(this).addClass('active').siblings().removeClass('active');
+            $('#yearly').prop('checked', true);
+            $("#monthly").prop('checked', false);
+
+            _this.onTimePickerChange()
+        });
+
+        /* -------- 选择按月订阅  radio触发的事件------- */
+        $('#monthly').on('change', function (e) {
+            var isChecked = $(this).is(':checked');
+            var val = $('.month_number').text();
+            if (!isChecked) {
+                $('#number_box_month button').attr('disabled', true)
+            }
+            _this.onTimePickerChange()
+        });
+
+        /* -------- 选择按年订阅  radio触发的事件------- */
+        $('#yearly').on('change', function (e) {
+            var isChecked = $(this).is(':checked');
+            // 按年订阅默认选择1年
+            var val = 1;
+            if (isChecked) {
+                $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
+            }
+
+            _this.onTimePickerChange()
+        });
+
+        // 计价标准
+        $('.billing-list-btn').on('click', function () {
+            pickerShow('.billing-list-container', true)
+        })
+        // 计算标准隐藏
+        $('.billing-list-container .dialog_hd__close').on('click', function () {
+            pickerShow('.billing-list-container', false)
+        })
+
+        $('.checkbox').on('click', function () {
+            $(this).toggleClass('checked')
+            var state = $(this).hasClass('checked')
+            sessionStorage.setItem("vipSub_read", state)
+            renew.flushSubmit()
+        });
+    }
+}
+$(function () {
+    renew.init()
+})
+
+
+//获取url中"?"符后的字符串并正则匹配
+function GetQueryString(name) {
+  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
+  var r = window.location.search.substr(1).match(reg);
+  var context = "";
+  if (r != null)
+     context = r[2];
+  reg = null;
+  r = null;
+  return context == null || context == "" || context == "undefined" ? "" : context;
+}
+// 隐藏dialog选择框
+function hideDialog() {
+    $('#pay_way').hide(200);
+    $('#time_cycle').hide(200);
+    $('.discount-details').hide()
+    $('.discount-button .icon-arrow').removeClass('up')
+}
+
+function clearSessionStorage() {
+    sessionStorage.removeItem("vipSubSelectTime");
+    sessionStorage.removeItem("vipSub_read");
+    sessionStorage.removeItem("historypushDataCache");
+    sessionStorage.removeItem("endTime");
+    sessionStorage.To_introducePage = 2;
+    //订阅首页
+    sessionStorage.removeItem("sub_vip_state");
+    sessionStorage.removeItem("vip_index_read");
+    sessionStorage.removeItem("vip_change_time");
+
+    sessionStorage.removeItem("pay_read_cache")
+    sessionStorage.removeItem("liveActiveCode_renew");
+    sessionStorage.removeItem("liveActiveCode_new");
+}
+function showToast(text) {
+    weui.toast(text, {
+        duration: 3000,
+        className: 'jy-toast',
+    })
+}
+function pickerShow(selector, f) {
+    if (f) {
+        // 添加进场动画,并显示
+        $(selector).find('.weui-mask').removeClass('weui-animate-fade-out').addClass('weui-animate-fade-in')
+        $(selector).find('.weui-picker').removeClass('weui-animate-slide-down').addClass('weui-animate-slide-up')
+        $(selector).show(300);
+    } else {
+        // 添加离场动画,并隐藏
+        $(selector).find('.weui-mask').removeClass('weui-animate-fade-in').addClass('weui-animate-fade-out')
+        $(selector).find('.weui-picker').removeClass('weui-animate-slide-up').addClass('weui-animate-slide-down')
+        $(selector).hide(300);
+    }
+}
+/* vue 代码 start */
+var coupon = new Vue({ 
+  el: '#coupon-vue',
+  data: function () {
+    return {
+      type: 'vip',
+        initPrice: 0, // 原价
+        realPrice: 0, // 实付价
+        checkboxStatus: false, // checkbox状态
+        submitStatus: true,  // 提交按钮状态
+        links: [
+          {
+            text: '《剑鱼标讯线上购买与服务条款》',
+            url: '/front/staticPage/wx-serviceterms.html',
+            event: this.readEvent
+          }
+        ],
+        buttons: {
+          submit: this.submitOrder
+        }
+    }
+  },
+  mounted () {
+    this.init()
+  }, 
+  methods: {
+    // 更新价格相关
+    updatePrice: function (before) {
+      console.log( '原价:' + before)
+      this.initPrice = before;
+      // 调用子组件查询最优卡券
+      this.$refs.couponRef.getCoupon();
+    },
+    // 初始化及回显相关
+    init: function () {},
+    // 勾选阅读协议
+    updateS: function(data) {
+      data.callback(this.checkSubmitStatus(data.check))
+    },
+    // 校验checkbox
+    checkSubmitStatus: function (checkStatus) {
+      sessionStorage.setItem("vipSub_read", checkStatus)
+      renew.flushSubmit()
+      return renew.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true"
+    },
+    saveEvent: function () {
+      renew.saveState()
+      sessionStorage.setItem("pay_read_cache", "0");
+    },
+    // 阅读协议点击事件
+    readEvent: function () {
+      renew.saveState()
+    },
+    // 订单提交事件
+    submitOrder: function () {
+      this.$refs.couponRef.submitStatus = true
+      $('.vip-footer.renew .confirm').trigger('click')
+      this.$refs.couponRef.submitStatus = false
+    }
+  }
+})
+/* vue 代码 end */

+ 57 - 758
src/web/templates/weixin/vipsubscribe/vip_renew.html

@@ -76,12 +76,19 @@
                             <span class="sub-l">有效日期:</span>
                             <span class="sub-r">
                                 <span class="ellipsis">
-                                    (<span class="month">3个月</span>)<span class="duration"></span>
+                                    (<span class="month">0个月</span>)<span class="duration"></span>
                                 </span>
                             </span>
                         </div>
                     </a>
                 </li>
+                <div class="tips">
+                    <div class="tip-title l-line">续费说明</div>
+                    <div class="tip-content">
+                        <div>1、仅支持原套餐延长周期续费,不支持套餐变更(含增加、减少、更改)原订阅的省份、城市、行业。 <br />续费费用=续费周期(按月/年)/原地区/原行业</div>
+                        <div>2、套餐周期内,用户也可以选择升级超级订阅2.0版享受更多权益。</div>
+                    </div>
+                </div>
             </ul>
         <ul style="padding: 0 .24rem;display: none;" id="giveTimeBox">
                 <li class="body-item select_cycle">
@@ -137,43 +144,43 @@
             </div>
         </div>
     </div>
-            <!-- 优惠明细 -->
-        <div class="j-picker adaption discount-details" style="display:none;">
-            <div class="weui-mask"></div>
-            <div class="weui-half-screen-dialog weui-picker">
-                <div class="weui-half-screen-dialog__hd">
-                    <div class="weui-half-screen-dialog__hd__main">
-                        <strong class="weui-half-screen-dialog__title">优惠明细</strong>
-                    </div>
-                    <span class="j-icon icon-del-grey cancel"></span>
+    <!-- 优惠明细 -->
+    <div class="j-picker adaption discount-details" style="display:none;">
+        <div class="weui-mask"></div>
+        <div class="weui-half-screen-dialog weui-picker">
+            <div class="weui-half-screen-dialog__hd">
+                <div class="weui-half-screen-dialog__hd__main">
+                    <strong class="weui-half-screen-dialog__title">优惠明细</strong>
                 </div>
-                <div class="weui-half-screen-dialog__bd" style="padding-bottom: 0;">
-                    <div class="weui-picker__bd">
-                        <div class="details-bd-item origin-price">
-                            <div class="d-b-left">原价</div>
-                            <div class="d-b-right">
-                                <span class="dis-mon">&yen;</span>
-                                <span class="dis-price price-num">0</span>
-                            </div>
+                <span class="j-icon icon-del-grey cancel"></span>
+            </div>
+            <div class="weui-half-screen-dialog__bd" style="padding-bottom: 0;">
+                <div class="weui-picker__bd">
+                    <div class="details-bd-item origin-price">
+                        <div class="d-b-left">原价</div>
+                        <div class="d-b-right">
+                            <span class="dis-mon">&yen;</span>
+                            <span class="dis-price price-num">0</span>
                         </div>
-                        <div class="details-bd-item discount-price">
-                            <div class="d-b-left">限时优惠</div>
-                            <div class="d-b-right text-red">
-                                <span class="dis-mon">-&yen;</span>
-                                <span class="dis-price">0</span>
-                            </div>
+                    </div>
+                    <div class="details-bd-item discount-price">
+                        <div class="d-b-left">限时优惠</div>
+                        <div class="d-b-right text-red">
+                            <span class="dis-mon">-&yen;</span>
+                            <span class="dis-price">0</span>
                         </div>
-                        <div class="details-bd-item now-price">
-                            <div class="d-b-left">实付</div>
-                            <div class="d-b-right text-red">
-                                <span class="dis-mon">&yen;</span>
-                                <span class="dis-price">0</span>
-                            </div>
+                    </div>
+                    <div class="details-bd-item now-price">
+                        <div class="d-b-left">实付</div>
+                        <div class="d-b-right text-red">
+                            <span class="dis-mon">&yen;</span>
+                            <span class="dis-price">0</span>
                         </div>
                     </div>
                 </div>
             </div>
         </div>
+    </div>
 
     <!-- 计费清单picker -->
     <div class="billing-list-container p13" style="display: none;">
@@ -300,41 +307,6 @@
             </div>
         </div>
     </div>
-    <!-- 选择支付方式 -->
-    <div class="js_dialog pay_way" id="pay_way" style="display: none;">
-        <div class="weui-mask"></div>
-        <div class="box">
-            <div class="box_hd">
-                <span></span>
-                <h3>支付方式</h3>
-                <span class="cancel">取消</span>
-            </div>
-            <div class="box_bd">
-                <div class="weui-cells weui-cells_checkbox choose-form">
-                    <label class="weui-cell weui-check__label wx_label" for="wx">
-                        <div class="weui-cell__bd read">
-                            <i class="icon-wx"></i>
-                            <p>微信支付</p>
-                        </div>
-                        <div class="weui-cell__hd">
-                            <input type="radio" class="weui-check" name="way" value="微信支付" id="wx" checked/>
-                            <i class="weui-icon-checked"></i>
-                        </div>
-                    </label>
-                    <label class="weui-cell weui-check__label zfb_label" for="zfb">
-                        <div class="weui-cell__bd read">
-                            <i class="icon-zfb"></i>
-                            <p>支付宝支付</p>
-                        </div>
-                        <div class="weui-cell__hd">
-                            <input type="radio" class="weui-check" name="way" value="支付宝支付" id="zfb"/>
-                            <i class="weui-icon-checked"></i>
-                        </div>
-                    </label>
-                </div>
-            </div>
-        </div>
-    </div>
     <!-- 优惠码弹窗 -->
     <div class="j-picker adaption coupon-picker">
         <div class="weui-mask weui-animate-fade-in"></div>
@@ -360,12 +332,11 @@
         </div>
     </div>
     <script src="/vipsubscribe/js/jquery-2.1.4.js?v={{Msg "seo" "version"}}"></script>
-    <!--<script src='{{Msg "seo" "cdn"}}/js/check-bind-phone.js?v={{Msg "seo" "version"}}'></script>-->
     <script src=//cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js></script>
     <script src='{{Msg "seo" "cdn"}}/common-module/coupon/js/pay-order-template.js?v={{Msg "seo" "version"}}'></script>
     <script src="/vipsubscribe/js/weui.min.js?v={{Msg "seo" "version"}}"></script>
     <script src="/vipsubscribe/js/common.js?v={{Msg "seo" "version"}}"></script>
-    <script src="/vipsubscribe/js/UpgradePrice.js?v={{Msg "seo" "version"}}"></script>
+    <script src="/vipsubscribe/js/price.js?v={{Msg "seo" "version"}}"></script>
     {{include "/common/weixin.html"}}
     <script>
     // @NewYearMarketing 2021/1/25
@@ -422,699 +393,27 @@
     }
 
     $(window).bind("pageshow", function (event) {
-            if (event.originalEvent.persisted) {
-                window.location.reload();
-            }
-        });
-        var live20200707 = {
-            startTime: {{.T.liveActiveStartTime}},
-            endTime: {{.T.liveActiveEndTime}},
-            activeDiscount: {{.T.activeDiscount}}
-        }
-
-        var purchase = {
-            areaSelect: {"一个省": ["一个市"]},//已选择地区 {"一个省":["一个市"]}计算价格临时变量
-            industrySelect: ["一个行业"],// 已选择行业 一个行业(计算价格临时变量)
-            timeSelect: [1, 2],//已选择时间 timeSelect[0]时长  timeSelect[1] 1:年 2:月
-            timeValue: "一个月",
-            endTime: "",
-            price: {}, //价格
-            nowBuyset: {},
-            timeCheckOk: false,
-            payWay: "wx_js",
-            initData: function () {
-                //已选择
-                try {
-                    if (sessionStorage.getItem("vipSubSelectArea")) {
-                        this.areaSelect = JSON.parse(sessionStorage.getItem("vipSubSelectArea"));
-                    }
-                    if (sessionStorage.getItem("vipSubSelectIndustry")) {
-                        this.industrySelect = JSON.parse(sessionStorage.getItem("vipSubSelectIndustry"));
-                    }
-                    if (sessionStorage.getItem("endTime")) {
-                        this.endTime = parseInt(sessionStorage.getItem("endTime"))
-                    }
-                    if (sessionStorage.liveActiveCode_renew === "jianyu360") {
-                        $('.coupon-code-tx .keywords-text').text("支付成功赠送30天订阅周期");
-                        $('.coupon-picker .weui-input').val("jianyu360");
-                        $('.coupon-code-tx').off('click');
-                    }
-                    //即将到期 回显已购买
-                    if (!sessionStorage.getItem("vipSubSelectArea") || !sessionStorage.getItem("vipSubSelectIndustry")) {
-                        $DoPost("/subscribepay/vipsubscribe/getSubBuyMsg", {}, function (r) {
-                            if (r.success) {
-                                if (!$.isEmptyObject(r.data.area)) {
-                                    purchase.areaSelect = r.data.area
-                                } else {
-                                    purchase.areaSelect = {"全国": []}
-                                }
-                                if (r.data.industry.length != 0) {
-                                    purchase.industrySelect = r.data.industry
-                                } else {
-                                    purchase.industrySelect = ["全部行业"]
-                                }
-                                if (r.data.endTime) {
-                                    purchase.endTime = r.data.endTime;
-                                }
-                                sessionStorage.setItem("vipSubSelectArea", JSON.stringify(purchase.areaSelect));
-                                sessionStorage.setItem("vipSubSelectIndustry", JSON.stringify(purchase.industrySelect));
-                                sessionStorage.setItem("endTime", JSON.stringify(purchase.endTime))
-                                sessionStorage.setItem("vipSub_read", true);
-                            }
-                        }, false)
-                    }
-                    if (sessionStorage.getItem("vipSubSelectTime")) {
-                        // console.log("ggggg", sessionStorage.getItem("vipSubSelectTime"))
-                        this.timeSelect = JSON.parse(sessionStorage.getItem("vipSubSelectTime"));
-                    }
-
-                    //加载价格
-                    $DoPost("/subscribepay/vipsubscribe/getPrice", {}, function (r) {
-                        if (r) {
-                            purchase.price = r;
-                            purchase.can1111 = r.isActiving && r.isWritten === 0
-                            if (purchase.can1111) {
-                                if (!sessionStorage.getItem("vipSubSelectTime")) {
-                                    purchase.timeValue = "1年";
-                                    purchase.timeSelect_tmp = [1,1]
-                                    purchase.timeSelect = purchase.timeSelect_tmp;
-                                    purchase.showTime();
-                                    purchase.flushPrice(purchase.timeSelect, 1);
-                                    sessionStorage.setItem("vipSubSelectTime", JSON.stringify(purchase.timeSelect));
-                                }
-                                showGiveStatus(true)
-                            } else {
-                                showGiveStatus(false)
-                            }
-                        }
-                    }, false)
-                    var areaSelect = JSON.parse(sessionStorage.getItem('vipSubSelectArea'))
-                    var industrySelect = JSON.parse(sessionStorage.getItem('vipSubSelectIndustry'))
-                    var endTime = sessionStorage.getItem('endTime')
-                    var readSelect = sessionStorage.getItem('vipSub_read') === 'true' ? true : false
-                    if (readSelect) {
-                      coupon.checkboxStatus = true
-                    }
-                    console.log(areaSelect && industrySelect && readSelect,'22222',coupon.$refs.couponRef.submitStatus)
-                    if (areaSelect && industrySelect && readSelect) {
-                      coupon.$refs.couponRef.submitStatus = false
-                      console.log(coupon.$refs.couponRef.submitStatus)
-                    } else {
-                      coupon.$refs.couponRef.submitStatus = true
-                    }
-
-                } catch (e) {
-                    console.log(e)
-                }
-                this.nowBuyset = getBuySet(purchase.areaSelect, purchase.industrySelect, this.price);
-            },
-            showArea: function () {
-                if (!$.isEmptyObject(this.areaSelect) && !this.areaSelect["一个省"]) { //有选择
-                    if (this.nowBuyset.areacount === -1) {
-                        $(".area .item-r").text("全国");
-                    } else {
-                        var tipTxt = "";
-                        if (this.nowBuyset.areacount > 0) tipTxt += this.nowBuyset.areacount + " 个省";
-                        var count = 0;
-                        this.nowBuyset.citys.forEach(function (item, index) {
-                            count += item;
-                        });
-                        if (count > 0) {
-                            if (this.nowBuyset.areacount > 0) tipTxt += "、";
-                            tipTxt += count + " 个市";
-                            if (this.nowBuyset.citys.length > 1) tipTxt += "(分布在" + this.nowBuyset.citys.length + "个省内)"
-                        }
-                        $(".area .item-r").text(tipTxt);
-                    }
-                } else {
-                    $(".area .item-r").text("");
-                }
-            },
-            showPrice: function () {
-                $('.monthly span:eq(0)').text(purchase.price.month.oneCity_oneBuyerClass / 100);
-                $('.monthly span:eq(1)').text(purchase.price.month.oneCity_allBuyerClass / 100);
-                $('.monthly span:eq(2)').text(purchase.price.month.oneProvince_oneBuyerClass / 100);
-                $('.monthly span:eq(3)').text(purchase.price.month.oneProvince_allBuyerClass / 100);
-                $('.monthly span:eq(4)').text(purchase.price.month.allProvince_oneBuyerClass / 100);
-                $('.monthly span:eq(5)').text(purchase.price.month.allProvince_allBuyerClass / 100);
-
-                $('.yearly span:eq(0)').text(purchase.price.year.oneCity_oneBuyerClass / 100);
-                $('.yearly span:eq(1)').text(purchase.price.year.oneCity_allBuyerClass / 100);
-                $('.yearly span:eq(2)').text(purchase.price.year.oneProvince_oneBuyerClass / 100);
-                $('.yearly span:eq(3)').text(purchase.price.year.oneProvince_allBuyerClass / 100);
-                $('.yearly span:eq(4)').text(purchase.price.year.allProvince_oneBuyerClass / 100);
-                $('.yearly span:eq(5)').text(purchase.price.year.allProvince_allBuyerClass / 100);
-            },
-            showIndustry: function () {
-                if (this.industrySelect.length > 0 && this.industrySelect[0] != "一个行业") { //选择有行业信息
-                    if (this.nowBuyset.buyerclasscount == -1) {
-                        $(".industry .item-r").text("全部行业");
-                    } else {
-                        var tipTxt = "";
-                        $(".industry .item-r").text(tipTxt + this.nowBuyset.buyerclasscount + " 个行业");
-                    }
-                } else {
-                    $(".industry .item-r").text("");
-                }
-            },
-            showTime: function () {
-                var tmp = this.timeSelect[0];
-                if (this.timeSelect[1] === 1) {
-                    tmp += "年";
-                    $("#yearly").prop('checked', true);
-                    //$('.year_number:eq(' + (this.timeSelect[0] - 1) + ')').trigger("click");
-                    $('.year_number:eq(' + (this.timeSelect[0] - 1) + ')').addClass("active")
-                    //$(".number_box:eq(1)").addClass("active");
-                } else {
-                    tmp += "个月";
-                    $("#monthly").prop('checked', true);
-                    $(".number_box:eq(0)").addClass("active");
-                    $("#number_box_month .month_number").text(this.timeSelect[0]);
-                    //if (this.timeSelect[0] >= 10) {
-                    //    $('.profit_tips').text("已选择" + this.timeSelect[0] + "个月,建议“按年订阅”").show();
-                    //}
-                    if (this.timeSelect[0] === 1) {
-                        $('#number_box_month button:eq(0)').attr("disabled", "disabled");
-                    } else {
-                        $('#number_box_month button:eq(0)').removeAttr("disabled");
-                    }
-                }
-                this.timeValue = tmp;
-            },
-            flushPrice: function (time, flag) {
-                //var price = getsubVipOrderPrice(this.areaSelect, this.industrySelect, time, this.price);
-                var times = [time[0], time[1]];
-                var price = getsubVipOrderPriceBybuyset(this.nowBuyset, time);
-                var givePrice = getsubVipOrderPriceBybuyset(this.nowBuyset, [time[1] === 1 ? 1 :time[0], time[1]]);
-                var showPrice = formatMoney(price);
-                var nowTime = new Date().getTime();
-                var startTime = live20200707.startTime;
-                var endTime = live20200707.endTime;
-                var activeDiscount = parseFloat(live20200707.activeDiscount);
-                var startTimes = parseInt(startTime) * 1000;
-                var endTimes = parseInt(endTime) * 1000;
-                if (nowTime >= startTimes && nowTime < endTimes) {
-                    if (flag !== 2) {
-                        $(".price-num").text(showPrice);
-                        var activePrice = formatMoney(parseFloat(price) - parseFloat(price) * activeDiscount);
-                        $(".reduce-price").text(formatMoney(activePrice));
-                    }
-                    showPrice = formatMoney(parseFloat(price) * activeDiscount);
-                }
-                if (flag === 1) {
-                    $('.billing-price').text(showPrice);
-                    $('.origin-price .price-num').text(formatMoney(parseFloat(price + givePrice)));
-                    // 优惠明细
-                    $('.discount-price .dis-price').text(formatMoney(givePrice))
-                    $('.now-price .dis-price').text(formatMoney(price));
-
-                } else if (flag === 2) {
-                    $('.computed_price').html(showPrice);
-                } else {
-                    $('.billing-price').text(showPrice);
-                    $('.origin-price .price-num').text(formatMoney(parseFloat(price + givePrice)));
-
-                    $('.computed_price').html(showPrice);
-                    // 优惠明细
-                    $('.discount-price .dis-price').text(formatMoney(givePrice))
-                    $('.now-price .dis-price').text(formatMoney(price));
-
-                }
-                this.flushSelectTime(times, flag === undefined ? 1 : flag);
-                coupon.updatePrice(price)
-            },
-            flushSelectTime(thisValue, flag) {
-                if (this.endTime) {
-                    var time1 = new Date(this.endTime * 1000).pattern('yyyy年MM月dd日');
-                    var end = getVipEndDate(thisValue[1], thisValue[0], this.endTime);
-                    var time2 = new Date(end * 1000).pattern('yyyy年MM月dd日');
-
-                    if (flag === 1) {
-                        $(".select_cycle .month").text(this.timeValue);
-                        var giveTime = this.timeValue
-                        if (this.timeValue.indexOf('年') !== -1) {
-                            giveTime = '1年'
-                        }
-                        $(".select_cycle #giveTime").text(giveTime);
-
-                        $(".select_cycle .duration").text(time1 + "-" + time2);
-                        $(".select_cycle .duration").show();
-                        // @NewYearMarketing 2021/1/25
-                        checkMonth()
-                    }
-
-                    //是否超过三年
-                    var now = Math.floor(new Date().getTime() / 1000);
-                    var MaxEnd = getVipEndDate(1, 3, now);
-                    if (!purchase.can1111 && end > MaxEnd) {
-                        var timeShow = getDateSub(now, this.endTime);
-                        var showTipText = "<div style='white-space: nowrap;'>最长订阅周期不可超过3年</div>剩余周期:";
-                        if (timeShow[0] !== 0) {
-                            showTipText += timeShow[0] + "年"
-                        }
-                        if (timeShow[1] !== 0) {
-                            showTipText += timeShow[1] + "个月"
-                        }
-                        weui.toast(showTipText, {
-                            duration: 3000,
-                            className: 'jy-toast',
-                        });
-                        if (flag === 1) this.timeCheckOk = false;
-                        if (flag === 2) $("#enter_period").prop("disabled", true);
-                    } else {
-                        if (flag === 1) this.timeCheckOk = true;
-                        if (flag === 2) $("#enter_period").prop("disabled", false);
-                    }
-                    this.flushSubmit();
-                } else {
-                    $(".select_cycle .duration").hide();
-                }
-            },
-            showTip() {//是否展示即将到期
-                var timeSub = this.endTime * 1000 - new Date().getTime();
-                if (timeSub > 0 && timeSub < 60 * 60 * 24 * 1000 * 3) {
-                    $(".vip-header").show();
-                }
-            },
-            flushSubmit() {//是否可提交
-                if (this.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true") {
-                    $('.vip-footer.renew .confirm').prop('disabled', false)
-                } else {
-                    $('.vip-footer.renew .confirm').prop('disabled', true)
-                }
-            }
-        };
-
-
-        $(function () {
-            purchase.initData();
-            purchase.showArea();
-            purchase.showIndustry();
-            purchase.showPrice();
-            purchase.showTime();
-            purchase.showTip();
-            purchase.flushPrice(purchase.timeSelect);
-            purchase.flushSubmit();
-            var time_limit;//定义一个周期变量
-            /*------ 关闭弹窗事件  点击取消或遮罩层 -----*/
-            $('.weui-mask').click(hideDialog);
-            $('.cancel').click(hideDialog);
-
-            /* -----  订阅周期、支付方式弹窗弹出事件 -------*/
-            // 选择订阅周期
-            $('.select_cycle a').click(function (e) {
-                $('#time_cycle').show(200);
-            });
-
-
-            /* -----  选择完支付方式、订阅周期 回显到页面 -------*/
-            $('.vip-body .pay-mode').on('click', function () {
-                pickerShow('#pay_way', true)
-            })
-
-            $('#pay_way input:radio[name="way"]').click(function () {
-                var checkValue = $('input:radio[name="way"]:checked').val();
-                pickerShow('#pay_way', false)
-                $('.vip-body .pay-mode .pay-mode-text').text(checkValue);
-                if (checkValue === "微信支付") {
-                    purchase.payWay = "wx_app"
-                } else {
-                    purchase.payWay = "ali_app"
-                }
-            });
-
-
-            // 对订阅时间选择的input绑定点击事件
-            $('#time_cycle input:radio[name="time"]').on('click', function (e) {
-                // 解除确认按钮的锁定
-                if ($(e.target).hasClass('monthly') !== $('#number_box_month').hasClass('active')) {
-                  $('#time_cycle .form-btn button').removeAttr('disabled');
-                }
-                if ($(e.target).hasClass('monthly')) {
-                    // 按月订阅
-                    $('#number_box_month').addClass('active');
-                    $('#number_box_year span').removeClass('active');
-                } else {
-                    // 按年订阅
-                    $('#number_box_month').removeClass('active');
-                    // $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active');
-                }
-            });
-
-            /* --------控制月份number_box的事件  点击加减号触发的事件------- */
-            $('#number_box_month').on('click', 'button', function (e) {
-                // 点击加减号让input radio选中
-                $('#monthly').prop('checked', true);
-                $('#yearly').prop('checked', false);
-                $('.number_box span').removeClass('active');
-                $('#number_box_month').addClass('active');
-
-                var $number = $('#number_box_month span.month_number');
-                var $monthlyInput = $('#monthly');
-                // 未整理的data数组,里面的值都是字符串
-                var preData = e.delegateTarget.dataset;
-                var currentNum = parseInt($number.text());
-                var data = {};
-                // 把字符串转换成数字
-                for (var i in preData) {
-                    data[i] = preData[i] - 0
-                }
-
-                if (!$monthlyInput.prop('checked')) {
-                    return
-                }
-                // 判断是点击的是+ 还是-
-                if ($(e.target).hasClass('add') || $(e.currentTarget).hasClass('add')) {
-                    if (currentNum == 11) { //12个月自动跳转1年
-                        $("#number_box_year .year_number:eq(0)").trigger("click");
-                        return
-                    }
-                    // 点的+
-                    currentNum = currentNum >= data.numboxMax ? data.numboxMax : (currentNum + data
-                        .numboxStep);
-                } else {
-                    // 点的-
-                    currentNum = currentNum <= data.numboxMin ? data.numboxMin : (currentNum - data
-                        .numboxStep);
-                }
-                $number.text(currentNum);
-                purchase.timeSelect_tmp = [Number(currentNum), 2];
-                purchase.flushPrice(purchase.timeSelect_tmp, 2);
-                //var price = (5.8 * currentNum).toFixed(1);
-                //$('.computed_price').html('¥' + price)
-                var firstButton = $('#number_box_month button:first');
-                var lastButton = $('#number_box_month button:last');
-                /*if (currentNum >= 10) {
-                    $('.profit_tips').text("已选择" + currentNum + "个月,建议“按年订阅”").show();
-                } else {
-                    $('.profit_tips').hide();
-                }*/
-                // 如果为操作后的结果为1,则锁定减号按钮
-                if (currentNum === data.numboxMin) {
-                    firstButton.attr('disabled', true)
-                } else {
-                    firstButton.removeAttr('disabled')
-                }
-                // 如果为操作后的结果为12,则锁定加号按钮
-                if (currentNum === data.numboxMax) {
-                    lastButton.attr('disabled', true)
-                } else {
-                    lastButton.removeAttr('disabled')
-                }
-            });
-
-            /* -------- 控制年份number_box的事件  点击1年 2年 3年触发的事件------- */
-            $('#number_box_year').on('click', 'span', function (e) {
-                // console.log(e.target.dataset.id);
-                $('#number_box_month').removeClass('active');
-                var id = e.target.dataset.id;
-                //$('.profit_tips').hide();
-                $(this).addClass('active').siblings().removeClass('active');
-                $('#yearly').prop('checked', true);
-                $("#monthly").prop('checked', false);
-
-                // 渲染结果 保留一位小数
-                //var result = (Number(id) * 58).toFixed(1);
-                //$('.computed_price').html('¥' + result)
-                purchase.timeSelect_tmp = [Number(id), 1];
-                purchase.flushPrice(purchase.timeSelect_tmp, 2);
-            });
-
-            /* -------- 选择按月订阅  radio触发的事件------- */
-            $('#monthly').on('change', function (e) {
-                var isChecked = $(this).is(':checked');
-                var val = $('.month_number').text();
-                /*if (val >= 10) {
-                    $('.profit_tips').show()
-                }*/
-                if (!isChecked) {
-                    $('#number_box_month button').attr('disabled', true)
-                }
-                //var result = (Number(val) * 5.8).toFixed(1);
-                //$('.computed_price').html('¥' + result);
-                purchase.timeSelect_tmp = [Number(val), 2];
-                purchase.flushPrice(purchase.timeSelect_tmp, 2);
-            });
-            //计价清单
-            // $('.billing-list-btn').on('click', function () {
-            //     pickerShow('.billing-list-container', true)
-            // })
-            // 计算标准隐藏
-            $('.billing-list-container .dialog_hd__close').on('click', function () {
-                pickerShow('.billing-list-container', false)
-            })
-
-            $('.checkbox').on('click', function () {
-                $(this).toggleClass('checked');
-                var state = $(this).hasClass('checked');
-                sessionStorage.setItem("vipSub_read", state);
-                purchase.flushSubmit();
-                //$('.vip-footer.renew .confirm').prop('disabled', !state)
-            });
-            //是否点击已读
-            if (sessionStorage.getItem("vipSub_read") === "true") {
-                $('.checkbox').addClass("checked");
-            }
-
-            /* -------- 选择按年订阅  radio触发的事件------- */
-            $('#yearly').on('change', function (e) {
-                //$('.profit_tips').hide();
-                // console.log($(this).is(':checked'))
-                var isChecked = $(this).is(':checked');
-                // 按年订阅默认选择1年
-                var val = 1;
-                //$('.computed_price').html('¥' + Number(val) * 58)
-                if (isChecked) {
-                    $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
-                }
-                purchase.timeSelect_tmp = [Number(val), 1];
-                purchase.flushPrice(purchase.timeSelect_tmp, 2);
-            });
-
-            // 确认订阅周期
-            $('#enter_period').on('click', function () {
-                var val;
-                var selectedDOM = $('#time_cycle input[name=time]:checked');
-                if (selectedDOM.val() === 'year') {
-                    val = $('#number_box_year .year_number.active').attr('data-id');
-                    purchase.timeSelect_tmp = [parseInt(val), 1];
-                    $('#time_cycle').hide(function () {
-                        purchase.timeValue = val + "年";
-                    });
-                } else if (selectedDOM.val() === 'month') {
-                    val = $('#number_box_month .month_number').text();
-                    purchase.timeSelect_tmp = [parseInt(val), 2];
-                    $('#time_cycle').hide(function () {
-                        purchase.timeValue = val + "个月";
-                    });
-                }
-
-                purchase.timeSelect = purchase.timeSelect_tmp;
-                purchase.showTime();
-                purchase.flushPrice(purchase.timeSelect, 1);
-                sessionStorage.setItem("vipSubSelectTime", JSON.stringify(purchase.timeSelect));
-            });
-            $('.vip-footer.renew .confirm').click(function () {
-                $('.vip-footer.renew .confirm').attr("disabled", "disabled");
-                //支付请求
-                var area = purchase.areaSelect;
-                var industry = purchase.industrySelect;
-                if (area["全国"]) {
-                    area = {};
-                }
-                if (industry.length === 1 && industry[0] === "全部行业") {
-                    industry = [];
-                }
-                //优惠码
-                var activeCode = $('.coupon-picker .weui-input').val();
-                var activeCodes = "";
-                if (activeCode.toLowerCase() === couponInfo.code && $('.coupon-code-tx .keywords-text').text() === couponInfo.successTip) {
-                    activeCodes = couponInfo.code;
-                }
-                //付费用户
-                var param = {
-                    "userLotteryId":coupon.$refs.couponRef.coupon.userLotteryId,
-                    "lotteryId": coupon.$refs.couponRef.coupon.lotteryId,
-                    "area": JSON.stringify(area),
-                    "industry": industry.join(","),
-                    "time": purchase.timeValue.trim(),
-                    "orderType": 5,
-                    "activeCode": activeCodes,
-                    "disWord":GetQueryString("disWord"),
-                };
-                $DoPost("/subscribepay/vipsubscribe/createOrder", param, function (r) {
-                    if (r.success) {
-                        clearSessionStorage();
-                        history.replaceState({}, '', '/front/vipsubscribe/toOrderDetailPage?orderCode=' + r.data.code);
-                        window.location.href = "/weixin/pay/checkout_subvip?t=1&orderCode=" + r.data.code;
-                    } else {
-                        $('.vip-footer.renew .confirm').removeAttr("disabled");
-                    }
-                }, false);
-            })
-
-        });
-        //获取url中"?"符后的字符串并正则匹配
-        function GetQueryString(name) {
-          var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
-          var r = window.location.search.substr(1).match(reg);
-          var context = "";
-          if (r != null)
-             context = r[2];
-          reg = null;
-          r = null;
-          return context == null || context == "" || context == "undefined" ? "" : context;
-        }
-
-        // 隐藏dialog选择框
-        function hideDialog() {
-            $('#pay_way').hide(200);
-            $('#time_cycle').hide(200);
-            $('.j-picker').hide();
-            $('.discount-details').hide()
-            $('.discount-button .icon-arrow').removeClass('up')
-        }
-
-        function clearSessionStorage() {
-            sessionStorage.removeItem("vipSubSelectArea");
-            sessionStorage.removeItem("vipSubSelectIndustry");
-            sessionStorage.removeItem("vipSubSelectTime");
-            sessionStorage.removeItem("vipSub_read");
-            sessionStorage.removeItem("historypushDataCache");
-            sessionStorage.removeItem("endTime");
-            sessionStorage.To_introducePage = 2;
-            //订阅首页
-            sessionStorage.removeItem("sub_vip_state");
-            sessionStorage.removeItem("vip_index_read");
-            sessionStorage.removeItem("vip_change_time");
-            sessionStorage.removeItem("liveActiveCode_renew");
-            sessionStorage.removeItem("liveActiveCode_new");
+        if (event.originalEvent.persisted) {
+            window.location.reload();
         }
-
-        function pickerShow(selector, f) {
-            if (f) {
-                // 添加进场动画,并显示
-                $(selector).find('.weui-mask').removeClass('weui-animate-fade-out').addClass('weui-animate-fade-in')
-                $(selector).find('.weui-picker').removeClass('weui-animate-slide-down').addClass('weui-animate-slide-up')
-                $(selector).show(300);
-            } else {
-                // 添加离场动画,并隐藏
-                $(selector).find('.weui-mask').removeClass('weui-animate-fade-in').addClass('weui-animate-fade-out')
-                $(selector).find('.weui-picker').removeClass('weui-animate-slide-up').addClass('weui-animate-slide-down')
-                $(selector).hide(300);
-            }
-        }
-
-        // 活动事件绑定
-        var couponInfo = {
-            code: 'jianyu360',
-            successTip: '支付成功赠送30天订阅周期'
-        }
-        $('.coupon-code-tx').on('click', function () {
-            if ($('.vip-renew').hasClass('live-20200707')) {
-                $('.coupon-picker').show()
-            } else {
-                return
-            }
-            var input = $('.coupon-picker .weui-input')
-            var confirmButton = $('.coupon-picker .weui-picker__btn')
-            var cancelButton = $('.coupon-picker .cancel')
-            var value = input.val()
-            input.focus().on('input', function () {
-                value = this.value
-                confirmButton.prop('disabled', (value === '' || value === undefined))
-            })
-
-            confirmButton.on('click', function () {
-                if (value.toLowerCase() !== couponInfo.code) {
-                    weui.toast('优惠码输入错误', {
-                        className: 'j-toast',
-                        duration: 1500
-                    })
-                    return
-                }
-                if (value.length === couponInfo.code.length && value.toLowerCase() === couponInfo.code) {
-                    $('.coupon-code-tx .keywords-text').text(couponInfo.successTip)
-                    sessionStorage.liveActiveCode_renew = "jianyu360";
-                    $('.coupon-code-tx').off('click')
-                    cancelButton.trigger('click')
-                }
-            })
-        })
-
-        document.body.addEventListener("focusout", function () {
-            //软键盘收起的事件处理
-            setTimeout(function () {
-                const scrollHeight =
-                    document.documentElement.scrollTop || document.body.scrollTop || 0;
-                window.scrollTo(0, Math.max(scrollHeight - 1, 0));
-            }, 100);
-        })
-
-        /* vue 代码 start */
-        var coupon = new Vue({ 
-          el: '#coupon-vue',
-          data: function () {
-            return {
-              type: 'vip',
-              initPrice: 0, // 原价
-              realPrice: 0, // 实付价
-              checkboxStatus: false, // checkbox状态
-              submitStatus: true,  // 提交按钮状态
-              links: [
-                {
-                  text: '《剑鱼标讯线上购买与服务条款》',
-                  url: '/front/staticPage/wx-serviceterms.html',
-                  event: this.readEvent
-                }
-              ],
-              buttons: {
-                submit: this.submitOrder
-              },
-            }
-          },
-          mounted () {
-            this.init()
-          }, 
-          methods: {
-            // 更新价格相关
-            updatePrice: function (before) {
-              console.log( '原价:' + before)
-              this.initPrice = before;
-              // 调用子组件查询最优卡券
-              this.$refs.couponRef.getCoupon();
-            },
-            // 初始化及回显相关
-            init: function () {},
-            // 勾选阅读协议
-            updateS: function(data) {
-              data.callback(this.checkSubmitStatus(data.check))
-            },
-            // 校验checkbox
-            checkSubmitStatus: function (checkStatus) {
-              sessionStorage.setItem("vipSub_read", checkStatus);
-              var areaSelect = JSON.parse(sessionStorage.getItem('vipSubSelectArea'))
-              var industrySelect = JSON.parse(sessionStorage.getItem('vipSubSelectIndustry'))
-              var endTime = sessionStorage.getItem('endTime')
-              var readSelect = sessionStorage.getItem('vipSub_read') === 'true' ? true : false
-              purchase.flushSubmit();
-              return Object.keys(areaSelect).length > 0 && industrySelect.length > 0 && readSelect
-            },
-            saveEvent: function() {
-              // sessionStorage.setItem("vipSub_read", 0)
-            },
-            // 阅读协议点击事件
-            readEvent: function () {},
-            // 订单提交事件
-            submitOrder: function () {
-              this.$refs.couponRef.submitStatus = true
-              $('.vip-footer.renew .confirm').trigger('click')
-              this.$refs.couponRef.submitStatus = false
-            }
-          }
-        })
-        /* vue 代码 end */
+    });
+
+
+    document.body.addEventListener("focusout", function () {
+        //软键盘收起的事件处理
+        setTimeout(function () {
+            const scrollHeight =
+                document.documentElement.scrollTop || document.body.scrollTop || 0;
+            window.scrollTo(0, Math.max(scrollHeight - 1, 0));
+        }, 100);
+    })
+    var live20200707 = {
+        startTime: {{.T.liveActiveStartTime}},
+        endTime: {{.T.liveActiveEndTime}},
+        activeDiscount: {{.T.activeDiscount}}
+    }
     </script>
+    <script src="/vipsubscribe/js/vip_renew.js?v={{Msg "seo" "version"}}"></script>
     {{include "/common/baiducc.html"}}
 </body>