浏览代码

wip:页面展示优化

wkyuer 8 月之前
父节点
当前提交
e4f49685c4

+ 76 - 67
src/jfw/front/returnMoneyPage.go

@@ -62,85 +62,94 @@ func (this *ReturnMoneyPage) ToRedirect() error {
 	}
 }
 
-func (this *ReturnMoneyPage) WxReturnMoney() error {
-	var (
-		getSession = this.Session().GetMultiple()
-		openid     = gconv.String(getSession["s_m_openid"])
-		data       = map[string]interface{}{
-			"token": this.GetString("token"),
-		}
-	)
-	//没有用户session 或  有session但是没有关注(刚刚取关 session信息存留)
-	if openid == "" || (openid != "" && !CheckUserIsSubscribe(openid)) {
-		stateKey := this.GetString("state")
-		if stateKey == "" { //公众号回调
-			stateKey = getTmpKey()
-			//暂存参数
-			for k, v := range this.Request.Form {
-				if len(v) > 0 {
-					data[k] = v[0]
+func (this *ReturnMoneyPage) WxReturnMoney() {
+	err := func() error {
+		var (
+			getSession = this.Session().GetMultiple()
+			openid     = gconv.String(getSession["s_m_openid"])
+			data       = map[string]interface{}{
+				"token": this.GetString("token"),
+			}
+		)
+		//没有用户session 或  有session但是没有关注(刚刚取关 session信息存留)
+		if openid == "" || (openid != "" && !CheckUserIsSubscribe(openid)) {
+			stateKey := this.GetString("state")
+			if stateKey == "" { //公众号回调
+				stateKey = getTmpKey()
+				//暂存参数
+				for k, v := range this.Request.Form {
+					if len(v) > 0 {
+						data[k] = v[0]
+					}
 				}
+				redis.Put("other", stateKey, data, 60*5) //存储信息
+				return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), stateKey), 302)
 			}
-			redis.Put("other", stateKey, data, 60*5) //存储信息
-			return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), stateKey), 302)
-		}
-		//获取wx跳转前参数
-		if redisValue := redis.Get("other", stateKey); redisValue != nil {
-			if param, ok := redisValue.(map[string]interface{}); ok {
-				data = param
+			//获取wx跳转前参数
+			if redisValue := redis.Get("other", stateKey); redisValue != nil {
+				if param, ok := redisValue.(map[string]interface{}); ok {
+					data = param
+				}
 			}
+			//获取用户openid
+			openid = jyutil.Getopenid(this.GetString("code"))
 		}
-		//获取用户openid
-		openid = jyutil.Getopenid(this.GetString("code"))
-	}
 
-	if openid == "" {
-		return fmt.Errorf("请在微信端打开")
-	}
-	this.Session().Set("openid_returnMoney", openid)
+		if openid == "" {
+			return fmt.Errorf("请在微信端打开")
+		}
+		this.Session().Set("openid_returnMoney", openid)
 
-	token := gconv.String(data["token"])
-	if token == "" {
-		return errors.New("未知回款单")
-	}
-	rData, err := getReturnPayDetail(token)
-	if err != nil {
-		return err
-	}
-	if err != nil {
-		log.Print("WxPayCommon.ReturnMoneyOnline.Err", err)
-		return err
-	}
+		token := gconv.String(data["token"])
+		if token == "" {
+			return errors.New("未知回款单")
+		}
+		rData, err := getReturnPayDetail(token)
+		if err != nil {
+			return err
+		}
+		if err != nil {
+			log.Print("WxPayCommon.ReturnMoneyOnline.Err", err)
+			return err
+		}
 
-	var pay_param map[string]interface{}
-	if payWay, payParam := gconv.String(rData["pay_way"]), gconv.String(rData["pay_param"]); payWay == "wx_js" && payParam != "" {
-		pay_param = gconv.Map(payParam)
+		var pay_param map[string]interface{}
+		if payWay, payParam := gconv.String(rData["pay_way"]), gconv.String(rData["pay_param"]); payWay == "wx_js" && payParam != "" {
+			pay_param = gconv.Map(payParam)
+		}
+		this.T["pay_param"] = pay_param
+		this.T["token"] = token
+		this.T["data"] = rData
+		this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
+		return this.Render("/common/returnMoney/wxReturnMoney.html", &this.T)
+	}()
+	if err != nil {
+		_ = this.Write(err.Error())
 	}
-	this.T["pay_param"] = pay_param
-	this.T["token"] = token
-	this.T["data"] = rData
-	this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
-	return this.Render("/common/returnMoney/wxReturnMoney.html", &this.T)
 }
 
-func (this *ReturnMoneyPage) AliReturnMoney() error {
-	token := this.GetString("token")
-	if token == "" {
-		return errors.New("参数异常")
-	}
-	rData, err := getReturnPayDetail(token)
+func (this *ReturnMoneyPage) AliReturnMoney() {
+	err := func() error {
+		token := this.GetString("token")
+		if token == "" {
+			return errors.New("参数异常")
+		}
+		rData, err := getReturnPayDetail(token)
+		if err != nil {
+			return err
+		}
+		var pay_param string
+		if gconv.String(rData["pay_way"]) == "ali_pc" {
+			pay_param = gconv.String(rData["pay_param"])
+		}
+		this.T["pay_param"] = pay_param
+		this.T["token"] = token
+		this.T["data"] = formatShow(rData)
+		return this.Render("/common/returnMoney/aliReturnMoney.html", &this.T)
+	}()
 	if err != nil {
-		return err
-	}
-
-	var pay_param string
-	if gconv.String(rData["pay_way"]) == "ali_pc" {
-		pay_param = gconv.String(rData["pay_param"])
+		_ = this.Write(err.Error())
 	}
-	this.T["pay_param"] = pay_param
-	this.T["token"] = token
-	this.T["data"] = formatShow(rData)
-	return this.Render("/common/returnMoney/aliReturnMoney.html", &this.T)
 }
 
 func getReturnPayDetail(token string) (map[string]interface{}, error) {

+ 1 - 1
src/web/templates/common/returnMoney/aliReturnMoney.html

@@ -4,7 +4,7 @@
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>支付</title>
+    <title>剑鱼标讯</title>
 </head>
 <style>
   *{

+ 1 - 1
src/web/templates/common/returnMoney/wxReturnMoney.html

@@ -8,7 +8,7 @@
     <meta name="apple-mobile-web-app-capable" content="yes">
     <meta name="apple-mobile-web-app-status-bar-style" content="black">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
-    <title>{{.T.data.product}}</title>
+    <title>剑鱼标讯</title>
     <script src="{{Msg "seo" "cdn"}}/js/rem.js"></script>
     <link rel="stylesheet" href=//cdn-common.jianyu360.com/cdn/lib/reset-css/5.0.1/reset.min.css />
     <link rel="stylesheet" href=//cdn-common.jianyu360.com/cdn/lib/vant/2.12.24/lib/index.css />