Browse Source

支付提交

wangkaiyue 5 years ago
parent
commit
9e78d07c78

+ 3 - 3
src/jfw/front/front.go

@@ -1453,14 +1453,14 @@ func (f *Front) Msgremind() error {
 		return f.Redirect("/weixin/pay/toOrderDetailPage?orderCode=" + param["ordercode"])
 	} else if t == "paid" {
 		if i_vip_status > 0 {
-			return f.Redirect("/front/vipsubscribe/toSetPage")
+			return f.Redirect("/weixin/pay/toSubVipSetPage")
 		} else {
 			return f.Redirect("/weixin/pay/vipsubscribe_new?orderCode=" + myLastOrderCode(userId))
 		}
 	} else if t == "ontrial_soonexprie" || t == "ontrial_expried" || t == "soonexprie" || t == "expried" { //试用即将到期 试用已到期 即将到期 已到期
 		if t == "ontrial_soonexprie" || t == "ontrial_expried" {
 			if i_vip_status == 2 {
-				return f.Redirect("/front/vipsubscribe/toSetPage")
+				return f.Redirect("/weixin/pay/toSubVipSetPage")
 			} else {
 				return f.Redirect("/weixin/pay/vipsubscribe_new")
 			}
@@ -1469,7 +1469,7 @@ func (f *Front) Msgremind() error {
 			l_vip_endtime := util.Int64All((*user)["l_vip_endtime"])
 			if now_unix < l_vip_endtime-259200 {
 				//已续费
-				return f.Redirect("/front/vipsubscribe/toSetPage")
+				return f.Redirect("/weixin/pay/toSubVipSetPage")
 			} else {
 				if now_unix > l_vip_endtime {
 					//未续费已到期,跳转到再次购买页面

+ 13 - 13
src/jfw/front/vipsubscribe.go

@@ -24,32 +24,32 @@ type Subscribepay struct {
 	toOrderDetailPage xweb.Mapper `xweb:"/weixin/pay/toOrderDetailPage"`        //订阅收费支付订单详情页面
 	toSetKeyWordPage  xweb.Mapper `xweb:"/front/vipsubscribe/toSetKeyWordPage"` //订阅收费设置关键词
 
-	toSetPageOld      xweb.Mapper `xweb:"/front/vipsubscribe/toSetPageOld"`      //订阅收费设置
+	//toSetPageOld      xweb.Mapper `xweb:"/front/vipsubscribe/toSetPageOld"`      //订阅收费设置
 	toSetInfoTypePage xweb.Mapper `xweb:"/front/vipsubscribe/toSetInfoTypePage"` //订阅收费设置信息类型
 	toSetOtherKwsPage xweb.Mapper `xweb:"/front/vipsubscribe/toSet(.*)Page"`     //订阅收费附加词和排除词设置
 	toVIPViewPage     xweb.Mapper `xweb:"/front/vipsubscribe/toVIPViewPage"`     //订阅收费预览
 
 	//修改升级
-	toSetPage        xweb.Mapper `xweb:"/front/vipsubscribe/toSetPage"`        //订阅收费设置
+	toSetPage        xweb.Mapper `xweb:"/weixin/pay/toSubVipSetPage"`          //订阅收费设置
 	toChangeArea     xweb.Mapper `xweb:"/front/vipsubscribe/toChangeArea"`     //修改区域
 	toChangeIndustry xweb.Mapper `xweb:"/front/vipsubscribe/toChangeIndustry"` //修改行业
 	toChangeTime     xweb.Mapper `xweb:"/front/vipsubscribe/toChangeTime"`     //修改时间
 	toSetPushSetPage xweb.Mapper `xweb:"/front/vipsubscribe/toSetPushSetPage"` //订阅收费推送设置
 
 	//修改
-	toEditSubPage       xweb.Mapper `xweb:"/front/vipsubscribe/toEditSubPage"`       //订阅收费修改页面
-	toEditSubAreaPage   xweb.Mapper `xweb:"/front/vipsubscribe/toEditSubAreaPage"`   //订阅收费修改地区
-	toEditSubInduPage   xweb.Mapper `xweb:"/front/vipsubscribe/toEditSubInduPage"`   //订阅收费修改行业
-	submitEditSubFinish xweb.Mapper `xweb:"/front/vipsubscribe/submitEditSubFinish"` //订阅收费修改成功
+	//toEditSubPage       xweb.Mapper `xweb:"/front/vipsubscribe/toEditSubPage"`       //订阅收费修改页面
+	//toEditSubAreaPage   xweb.Mapper `xweb:"/front/vipsubscribe/toEditSubAreaPage"`   //订阅收费修改地区
+	//toEditSubInduPage   xweb.Mapper `xweb:"/front/vipsubscribe/toEditSubInduPage"`   //订阅收费修改行业
+	//submitEditSubFinish xweb.Mapper `xweb:"/front/vipsubscribe/submitEditSubFinish"` //订阅收费修改成功
 
 	//升级
-	toUpgradePage xweb.Mapper `xweb:"/weixin/pay/toUpgradePage"`                   //订阅收费升级服务页面
-	addArea       xweb.Mapper `xweb:"/front/vipsubscribe/toChooseAreaUpgrade"`     //订阅收费升级新增区域页面
-	addIndustry   xweb.Mapper `xweb:"/front/vipsubscribe/toChooseIndustryUpgrade"` //订阅收费升级新增行业页面
+	//toUpgradePage xweb.Mapper `xweb:"/weixin/pay/toUpgradePage"`                   //订阅收费升级服务页面
+	//addArea       xweb.Mapper `xweb:"/front/vipsubscribe/toChooseAreaUpgrade"`     //订阅收费升级新增区域页面
+	//addIndustry   xweb.Mapper `xweb:"/front/vipsubscribe/toChooseIndustryUpgrade"` //订阅收费升级新增行业页面
 
 	//续费
-	renewPage    xweb.Mapper `xweb:"/front/vipsubscribe/renewPage/(.*)"` //订阅到期(will:即将到期,exprie:已到期)
-	renewPayPage xweb.Mapper `xweb:"/weixin/pay/renewPayPage"`           //订阅到期续费
+	renewPage xweb.Mapper `xweb:"/front/vipsubscribe/renewPage/(.*)"` //订阅到期(will:即将到期,exprie:已到期)
+	//renewPayPage xweb.Mapper `xweb:"/weixin/pay/renewPayPage"`           //订阅到期续费
 
 	//发票
 	openInvoice xweb.Mapper `xweb:"/front/vipsubscribe/openInvoice/(\\w+)"` //开发票
@@ -178,7 +178,7 @@ func (s *Subscribepay) Introduce() error {
 	}
 	obj := util.ObjToMap((*m)["o_vipjy"])
 	if util.IntAll((*m)["i_vip_status"]) > 0 {
-		return s.Redirect("/front/vipsubscribe/toSetPage")
+		return s.Redirect("/weixin/pay/toSubVipSetPage")
 	}
 	s.T["notShowTrial"] = util.IntAll((*obj)["i_trial"]) == -1 || (*m)["i_vip_status"] != nil
 	s.T["signature"] = wx.SignJSSDK(s.Site() + s.Url())
@@ -346,7 +346,7 @@ func (s *Subscribepay) PreheatPoster() {
 	u, ok := public.MQFW.FindOne("user", `{"s_m_openid":"`+myopenid+`"}`)
 	if len(*u) > 0 && ok {
 		if util.Int64All((*u)["i_vip_status"]) == 1 || util.Int64All((*u)["i_vip_status"]) == 2 {
-			s.Redirect("/front/vipsubscribe/toSetPage")
+			s.Redirect("/weixin/pay/toSubVipSetPage")
 		} else {
 			s.Redirect("/front/vipsubscribe/introducePage")
 		}

+ 1 - 1
src/web/staticres/js/wxSupersearch.js

@@ -2078,7 +2078,7 @@ var SuperSearch = {
 	initHomePage:function(){
 		$(".home_toset").click(function(){
 			if(SuperSearch.isVip){
-				window.location.href="/front/vipsubscribe/toSetPage"
+				window.location.href="/weixin/pay/toSubVipSetPage"
 			}else{
 				sessionStorage.removeItem("keysetindexToHistory");
 				window.location.href="/swordfish/historypush"

+ 12 - 4
src/web/staticres/vipsubscribe/js/vip_index_new.js

@@ -532,7 +532,7 @@ $(function () {
         var tmp1 = getAreaClassArr(reqData.oldArea);
         var tmp2 = getAreaClassArr(reqData.area);
         var areaNoChange = (JSON.stringify(tmp1[0].sort()) === JSON.stringify(tmp2[0].sort())) && (JSON.stringify(tmp1[1].sort()) === JSON.stringify(tmp2[1].sort()));
-        if (IndustryNoChange && areaNoChange && changeTime.length==0) {
+        if (IndustryNoChange && areaNoChange && changeTime.length == 0) {
             return
         }
 
@@ -602,9 +602,17 @@ $(function () {
             "payWay": "wx_js",
             "time": sessionStorage.getItem("vip_change_time"),
             "price": submitPrice
-        }, function (res) {
-            console.log(res)
+        }, function (r) {
+            if (r.success) {
+                onBridgeReady(JSON.parse(r.data.res), r.data.code);
+            }
         }, false);
     }
 
-});
+});
+
+function clearSessionStorage() {
+    sessionStorage.removeItem("sub_vip_state");
+    sessionStorage.removeItem("vip_index_read");
+    sessionStorage.removeItem("vip_change_time");
+}

+ 1 - 1
src/web/templates/weixin/historypush.html

@@ -669,7 +669,7 @@
 		//vip设置
 		function tosetpage(){
 			setSessionStorage();
-			window.location.href="/front/vipsubscribe/toSetPage";
+			window.location.href="/weixin/pay/toSubVipSetPage";
 		}
 		//vip关键词设置
 		function tosetkeyspage(){

+ 1 - 1
src/web/templates/weixin/my.html

@@ -119,7 +119,7 @@
 			$(".vip").on("click",function(){
 				$.post("/subscribepay/orderListDetails/isVip?v="+nowTimestamp,{},function(data){
 					if (data.isvip){
-						window.location.href="/front/vipsubscribe/toSetPage";		//vip订阅入口  试用或正式vip
+						window.location.href="/weixin/pay/toSubVipSetPage";		//vip订阅入口  试用或正式vip
 					}else{
 						window.location.href="/front/vipsubscribe/introducePage";		//vip订阅入口  非vip
 					}

+ 1 - 1
src/web/templates/weixin/treasure_box.html

@@ -85,7 +85,7 @@
 			$(".vip").on("click",function(){
 				$.post("/subscribepay/orderListDetails/isVip?v="+nowTimestamp,{},function(data){
 					if (data.isvip){
-						window.location.href="/front/vipsubscribe/toSetPage";		//vip订阅入口  试用或正式vip
+						window.location.href="/weixin/pay/toSubVipSetPage";		//vip订阅入口  试用或正式vip
 					}else{
 						window.location.href="/front/vipsubscribe/introducePage";		//vip订阅入口  非vip
 					}

+ 65 - 0
src/web/templates/weixin/vipsubscribe/vip_index_new.html

@@ -321,6 +321,71 @@
 <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/vip_index_new.js?v={{Msg "seo" "version"}}"></script>
+{{include "/common/weixin.html"}}
 </body>
+<script>
+    $(window).bind("pageshow", function (event) {
+        if (event.originalEvent.persisted) {
+            window.location.reload();
+        }
+    });
+    try {
+        var signature = {{.T.signature}};
+        var isConfigSuccess = true;
+        var id = {{.T._id}}
+        if (signature && signature.length == 4) {
+            wx.config({
+                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+                appId: signature[0], // 必填,公众号的唯一标识
+                timestamp: signature[1], // 必填,生成签名的时间戳
+                nonceStr: signature[2], // 必填,生成签名的随机串
+                signature: signature[3],// 必填,签名,见附录1
+                jsApiList: ['chooseWXPay', 'hideAllNonBaseMenuItem'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
+            });
+            wx.ready(function () {
+                if (!isConfigSuccess) {
+                    return;
+                }
+                wx.hideAllNonBaseMenuItem();
+            });
+            wx.error(function (res) {
+                //config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
+                //alert(res);
+                isConfigSuccess = false;
+            });
+        }
 
+        //调用微信支付接口
+        function onBridgeReady(res, ordercode) {
+            WeixinJSBridge.invoke('getBrandWCPayRequest', {
+                    "appId": res["appId"],
+                    "timeStamp": res["timestamp"],
+                    "nonceStr": res["nonceStr"],
+                    "package": res["prepayId"],
+                    "signType": res["signType"],
+                    "paySign": res["sign"]
+                },
+                function (r) {
+                    if (r.err_msg == "get_brand_wcpay_request:ok") {
+                        setTimeout(function () {
+                            clearSessionStorage();
+                            window.location.replace("/front/vipsubscribe/toPaySuccessPage?orderCode=" + ordercode);
+                        }, 500)
+                    } else if (r.err_msg == "get_brand_wcpay_request:cancel") {
+                        console.log("支付已取消")
+                    } else {
+                        weui.toast("系统异常,请稍微再试", {
+                            duration: 2000,
+                            className: 'custom-toast',
+                        });
+                    }
+                });
+        }
+
+        //微信支付end
+    } catch (e) {
+        console.log(e)
+    }
+
+</script>
 </html>

+ 1 - 1
src/web/templates/weixin/vipsubscribe/vip_pay_success.html

@@ -49,7 +49,7 @@
       })
       //设置关键词
       $(".right_btn").on("click",function(){
-        window.location.href ='/front/vipsubscribe/toSetPage'
+        window.location.href ='/weixin/pay/toSubVipSetPage'
       }) 
       
       var orderCode=decodeURIComponent(getParam("orderCode"));