zqbao пре 9 месеци
родитељ
комит
063530fe2a
3 измењених фајлова са 13 додато и 1 уклоњено
  1. 3 0
      controllers/mini_config.go
  2. 6 1
      services/wechat/wechat.go
  3. 4 0
      utils/config.go

+ 3 - 0
controllers/mini_config.go

@@ -68,6 +68,9 @@ func (this *MiniConfigController) MiniConfig() {
 	}, response.MiniConfigResp{
 		ConfKey: "Logo",
 		ConfVal: miniConf["Logo"],
+	}, response.MiniConfigResp{
+		ConfKey: "WxAppId",
+		ConfVal: miniConf["WxAppId"],
 	})
 
 	br.Data = list

+ 6 - 1
services/wechat/wechat.go

@@ -115,7 +115,12 @@ func GetOpenId(code string) (info *WxUserToken, err error) {
 
 	httpUrl := `https://api.weixin.qq.com/sns/oauth2/access_token?
 		appid=%s&secret=%s&code=%s&grant_type=authorization_code`
-	httpUrl = fmt.Sprintf(httpUrl, utils.WX_APPID, utils.WX_APP_SECRET, code)
+
+	confMap, err := models.GetMiniConf()
+	if err != nil {
+		return
+	}
+	httpUrl = fmt.Sprintf(httpUrl, confMap["WxAppId"], confMap["WxAppSecret"], code)
 
 	client := http.Client{}
 	wxReq, err := http.NewRequest("GET", httpUrl, nil)

+ 4 - 0
utils/config.go

@@ -39,6 +39,8 @@ var (
 
 // 微信相关
 var (
+	HZ_WX_APPID            string
+	HZ_WX_APP_SECRET       string
 	DW_WX_Id               string //微信原始ID
 	WX_APPID               string
 	WX_APP_SECRET          string
@@ -93,6 +95,8 @@ func init() {
 	ETA_MINI_BRIDGE_URL = config["eta_mini_bridge_url"]
 	ETA_MINI_APPID = config["eta_mini_appid"]
 	ETA_MINI_APP_SECRET = config["eta_mini_app_secret"]
+	HZ_WX_APPID = config["hz_wx_appid"]
+	HZ_WX_APP_SECRET = config["hz_wx_app_secret"]
 
 	initRedis(config)
 }