wangkaiyue 5 роки тому
батько
коміт
185b4b68d5

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

@@ -257,7 +257,7 @@ func (this *SubscribeChange) SaveChange() {
 		}
 		//支付提醒
 		util.MsgRemind.Add(qutil.IntAll(orderid), final_price, qutil.If(filter.OrderType == 5, 1, -1).(int), 0, ordercode, userId, now.Unix())
-		return &entity.FuncResult{true, nil, map[string]interface{}{"code": ordercode, "res": payStr}}
+		return &entity.FuncResult{true, nil, map[string]interface{}{"code": ordercode, "res": payStr, "needPay": true}}
 	}()
 	if r.Err != nil {
 		log.Printf("%s CreateOrder err:%v\n", userId, r.Err.Error())

+ 80 - 84
src/web/staticres/vipsubscribe/js/vip_index_new.js

@@ -88,69 +88,28 @@ $(function () {
         })
     }
 
-    //获取选择
-    function getCount(area, industry) {
-        if (industry[0] === "全部行业") industry = [];
-        if (area["全国"]) area = {};
-        //计算地区数量
-        var count = {
-            "areacount": -1,  //省份数量
-            "buyerclasscount": -1,
-            "citys": [] //购买省份中城市数量
-        };
-        //行业
-        if (industry.length != 0) {
-            count.buyerclasscount = industry.length
-        }
-        //地区
-        if (!$.isEmptyObject(area)) {
-            count.areacount = 0;
-            for (var i in area) {
-                var citys = area[i];
-                var thisLen = citys.length;
-                if (thisLen === 0) {
-                    count.areacount++
-                } else {
-                    count.citys.push(thisLen)
-                }
-            }
-        }
-        return count
-    }
 
     // 设置已选择的区域和行业
-    /**
-     * selected = {
-     *      areacount: 2,
-     *      buyerclasscount: 2,
-     *      citys: [1, 2, 3]
-     *  }
-     */
     function setSelectedAreaAndInd(selected) {
-        // selected = {
-        //     areacount: 2,
-        //     buyerclasscount: 2,
-        //     citys: [1, 2, 3]
-        // }
-
         // 设置已选择区域
-        var citySum = arrSum(selected.citys)
+        var citySum = arrSum(selected.citys);
         var text = {
-            p: selected.areacount + '个省',
-            c: citySum + '个市',
-            s: '分布在' + selected.citys.length + '个省内'
-        }
+            p: selected.areacount === 0 ? '' : selected.areacount + '个省',
+            c: citySum === 0 ? '' : citySum + '个市',
+            s: selected.citys.length === 1 ? '' : '(分布在' + selected.citys.length + '个省内)'
+        };
 
         if (selected.areacount === -1) {
             $('.vip-body .area .selected-area').text('全国')
         } else {
-            if (selected.areacount === 0) {
-                $('.vip-body .area .selected-area').text(text.c + '(' + text.s + ')')
-            } else if (selected.citys.length === 0) {
-                $('.vip-body .area .selected-area').text(text.p)
-            } else {
-                $('.vip-body .area .selected-area').text(text.p + '、' + text.c + '(' + text.s + ')')
+            var dunhao = '';
+            if (citySum !== 0 && selected.areacount !== 0) {
+                dunhao = '、'
+            }
+            if (citySum === 0 || citySum === 1) {
+                text.s = ''
             }
+            $('.vip-body .area .selected-area').text(text.p + dunhao + text.c + text.s);
         }
 
         // 设置已选择行业
@@ -163,32 +122,28 @@ $(function () {
 
 
     // 设置已购买的区域和行业
-    /**
-     * buyset = {
-     *      areacount: 2,
-     *      buyerclasscount: 2,
-     *      newcitys: [1, 2, 3]
-     *  }
-     */
     function setBuyAreaAndInd(buySet) {
         // 设置已购买区域
         var buySetCitySum = arrSum(buySet.newcitys)
         var text = {
-            p: buySet.areacount + '个省',
-            c: buySetCitySum + '个市',
-            s: '分布在' + buySet.newcitys.length + '个省内'
+            p: buySet.areacount === 0 ? '' : buySet.areacount + '个省',
+            c: buySetCitySum === 0 ? '' : buySetCitySum + '个市',
+            s: buySet.newcitys.length === 1 ? '' : '(分布在' + buySet.newcitys.length + '个省内)'
         }
 
         if (buySet.areacount === -1) {
             $('.vip-body .area .buy-set-area').text('全国')
         } else {
-            if (buySet.areacount === 0) {
-                $('.vip-body .area .buy-set-area').text(text.c + '(' + text.s + ')')
-            } else if (buySet.newcitys.length === 0) {
-                $('.vip-body .area .buy-set-area').text(text.p)
-            } else {
-                $('.vip-body .area .buy-set-area').text(text.p + '、' + text.c + '(' + text.s + ')')
+            var dunhao = '';
+            // 如果省或者市都不为0,则添加顿号
+            if (buySetCitySum !== 0 && buySet.areacount !== 0) {
+                dunhao = '、'
+            }
+            // 如果市等于0或者1,text.s不需要显示
+            if (buySetCitySum === 0 || buySetCitySum === 1) {
+                text.s = ''
             }
+            $('.vip-body .area .buy-set-area').text(text.p + dunhao + text.c + text.s);
         }
 
         // 设置已选择行业
@@ -199,6 +154,29 @@ $(function () {
         }
     }
 
+    function showTimeOut(endTime, isTrail) {
+        var timeSub = endTime * 1000 - new Date().getTime();
+        console.log("timeSub", timeSub);
+        if (timeSub > 0 && timeSub < 60 * 60 * 24 * 1000 * 3) {
+            var hours = Math.floor(timeSub / (60 * 60 * 1000));
+            var day = Math.floor(hours / 24);
+            if (day > 0) {
+                if (!isTrail) {
+                    $(".vip-header .expire-remind .remind-text").text("VIP订阅服务还有" + (day) + "天到期,请及时续费!");
+                } else {
+                    $(".vip-header .expire-remind .remind-text").text("VIP订阅服务还有" + (day) + "天到期,请及时购买!");
+                }
+            } else {
+                if (!isTrail) {
+                    $(".vip-header .expire-remind .remind-text").text("VIP订阅服务今天到期,请及时续费!");
+                } else {
+                    $(".vip-header .expire-remind .remind-text").text("VIP订阅服务今天到期,请及时购买!");
+                }
+            }
+            $(".vip-header .expire-remind").show();
+        }
+    }
+
     function clearSession() {
         sessionStorage.removeItem("vip_index_read");
         sessionStorage.removeItem('sub_vip_state');
@@ -251,6 +229,9 @@ $(function () {
         pickerShow('.billing-list-container', false)
     })
 
+    $('.close-expire-remind').on("click", function () {
+        $(".expire-remind").hide();
+    });
     // 阅读并接受协议前的模拟checkbox点击事件
     if (sessionStorage.getItem("vip_index_read") == "1") {
         $('.checkbox').addClass("checked")
@@ -463,22 +444,30 @@ $(function () {
             if (isChecked) {
                 $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
             }
-        })
+        });
+
     }
 
+    //提交请求
+    $('.vip-footer .button-r.confirm').on('click', function () {
+        $(this).attr("disabled", "disabled");
+        doSubmit();
+        $(this).removeAttr("disabled");
+    });
     // 以下数据交互 -------------------
     // 定义全部变量state
-    var globalState = {}
+    var globalState = {};
     var changeTime = [];
     var submitPrice = 0;
 
     function init(state) {
         // init 已选择的区域和行业
-        var selectedAreaAndInd = getCount(state.area, state.industry);
+        var selectedAreaAndInd = getBuySet(state.area, state.industry);
         setSelectedAreaAndInd(selectedAreaAndInd);
         // 初始化,已购买的城市和行业
         setBuyAreaAndInd(state.buyset);
-
+        //是否提示即将到期
+        showTimeOut(state.endTime, state.isTrial);
         var dEnd;
         var change = sessionStorage.getItem("vip_change_time");
         var endflag = state.endTime;
@@ -511,7 +500,7 @@ $(function () {
         $('.body-item.cycle .buy-cycle').text(sDuration);
 
         // 初始化关键词
-        if (state.items.lenght === 0) {
+        if (state.items.length === 0) {
             $('.body-item.keywords .keywords-text').text('未分类')
         } else {
             var arr = []
@@ -546,7 +535,9 @@ $(function () {
 
         //试用不展示续费
         if (!state.isTrial) {
-            $(".vip-header").show();
+            $(".vip-header .renew").show();
+        } else {
+            $(".vip-header .trail").show();
         }
 
     }
@@ -642,16 +633,8 @@ $(function () {
         })
     } else {
         getDataWitXHR()
-
     }
 
-    //提交请求
-    $('.vip-footer .button-r.confirm').on('click', function () {
-        $(this).attr("disabled", "disabled");
-        doSubmit();
-        $(this).removeAttr("disabled");
-    })
-
 
     //保存 or 升级
     var submited = false;
@@ -673,7 +656,20 @@ $(function () {
             "price": submitPrice
         }, function (r) {
             if (r.success) {
-                onBridgeReady(JSON.parse(r.data.res), r.data.code);
+                if (r.data.needPay) {
+                    //创建支付订单
+                    onBridgeReady(JSON.parse(r.data.res), r.data.code);
+                } else {
+                    //订阅修改
+                    if (r.data.doSuccess) {
+                        window.history.go(-1);
+                    } else {
+                        weui.toast('修改保存失败', {
+                            duration: 1500,
+                            className: 'jy-toast',
+                        });
+                    }
+                }
             }
         }, false);
     }

+ 7 - 7
src/web/templates/weixin/vipsubscribe/vip_index_new.html

@@ -18,15 +18,15 @@
 
 <body class="no-touch">
 <div class="vip-upgrade">
-    <div class="vip-header" style="display: none">
-        <!-- <div class="header-renew">
+    <div class="vip-header">
+        <div class="header-renew trail" style="display: none">
             <div class="renew-l">
                 <div class="vip-logo"></div>
                 <div class="vip-text free7days">VIP订阅服务</div>
             </div>
-            <a href="vip_purchase.html" class="renew-r">去购买</a>
-        </div> -->
-        <div class="header-renew">
+            <a href="/weixin/pay/vipsubscribe_new" class="renew-r">去购买</a>
+        </div>
+        <div class="header-renew renew" style="display: none">
             <div class="renew-l">
                 <div class="vip-logo"></div>
                 <div class="vip-text">VIP订阅服务</div>
@@ -34,11 +34,11 @@
             <a href="/weixin/pay/vipsubscribe_renew" class="renew-r">续费</a>
         </div>
         <!-- 到期提醒 -->
-        <!-- <div class="expire-remind">
+        <div class="expire-remind" style="display: none">
             <i class="icon iconfont icon-guanbi close-expire-remind"></i>
             <span class="remind-text">VIP订阅服务试用即将过期,请及时购买!</span>
             <a class="remind-link"></a>
-        </div> -->
+        </div>
     </div>
     <ul class="vip-body">
         <li class="body-item area">

+ 2 - 1
src/web/templates/weixin/vipsubscribe/vip_purchase.html

@@ -437,7 +437,8 @@
                     if (provinceArr.length > 0) tipTxt += provinceArr.length + " 个省";
                     if (cityArr.length > 0) {
                         if (provinceArr.length > 0) tipTxt += "、";
-                        tipTxt += cityArr.length + " 个市(分布在" + cityProvinceCount + "个省内)";
+                        tipTxt += cityArr.length + " 个市";
+                        if (cityArr.length > 1) tipTxt += "(分布在" + cityProvinceCount + "个省内)"
                     }
                     $(".choose_area").val(tipTxt);
                     //$(".add_tips.area").text(tipTxt).css("display", "");

+ 3 - 3
src/web/templates/weixin/vipsubscribe/vip_renew.html

@@ -68,7 +68,7 @@
                 </div>
             </a>
         </li>
-        <li class="body-item pay-mode">
+        <!--<li class="body-item pay-mode">
             <a class="item-container" href="javascript:;">
                 <div class="item">
                         <span class="item-l">
@@ -81,7 +81,7 @@
                         </span>
                 </div>
             </a>
-        </li>
+        </li>-->
     </ul>
     <div class="vip-footer renew">
         <div class="footer-preview-container">
@@ -322,7 +322,7 @@
 
         //微信支付end
     } catch (e) {
-        console.log(e)
+        alert(e)
     }
 
     var purchase = {