diff --git a/app/hdl/hdl_wx_open.go b/app/hdl/hdl_wx_open.go index 1b1865a..43b05b6 100644 --- a/app/hdl/hdl_wx_open.go +++ b/app/hdl/hdl_wx_open.go @@ -184,52 +184,54 @@ func GetPreAuthCode(c *gin.Context) { } func GetAuthUrlCallBack(c *gin.Context) { - authCode := c.DefaultQuery("auth_code", "") - if authCode == "" { - e.OutErr(c, e.ERR_NOT_FAN, "auth_code获取失败") - return - } - - fmt.Println("auth_code>>>>>>>>", authCode) - - masterId := c.DefaultQuery("masterId", "") - wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db) - wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId)) - if err != nil { - return - } - if wxOpenThirdPartyAppList == nil { - e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录") - return - } - wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret) - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } - resp, err := wxApiService.GetAuthorizerAccessTokenByAuthCode(authCode) - if err != nil { - e.OutErr(c, e.ERR, err.Error()) - return - } - - userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db) - userWxAppletList, err := userWxAppletListDb.GetUserWxAppletListByAppId(resp.AuthorizationInfo.AuthorizerAppid) - if err != nil { - return - } - if userWxAppletList == nil { - e.OutErr(c, e.ERR_NOT_FAN, "未查询到小程序应用记录") - return - } - userWxAppletList.AuthorizerRefreshToken = resp.AuthorizationInfo.AuthorizerRefreshToken - _, err = userWxAppletListDb.UpdateUserWxAppletList(userWxAppletList, "authorizer_refresh_token") - if err != nil { - e.OutErr(c, e.ERR_DB_ORM, err.Error()) - return - } - - c.String(http.StatusOK, "ok") + //authCode := c.DefaultQuery("auth_code", "") + //if authCode == "" { + // e.OutErr(c, e.ERR_NOT_FAN, "auth_code获取失败") + // return + //} + // + //fmt.Println("auth_code>>>>>>>>", authCode) + // + //masterId := c.DefaultQuery("masterId", "") + //wxOpenThirdPartyAppListDb := implement.NewWxOpenThirdPartyAppListDb(db.Db) + //wxOpenThirdPartyAppList, err := wxOpenThirdPartyAppListDb.GetWxOpenThirdPartyAppList(utils.StrToInt(masterId)) + //if err != nil { + // return + //} + //if wxOpenThirdPartyAppList == nil { + // e.OutErr(c, e.ERR_NOT_FAN, "未查询到对应三方应用记录") + // return + //} + //wxApiService, err := wechat.NewWxApiService(masterId, wxOpenThirdPartyAppList.Appid, wxOpenThirdPartyAppList.AppSecret) + //if err != nil { + // e.OutErr(c, e.ERR, err.Error()) + // return + //} + //resp, err := wxApiService.GetAuthorizerAccessTokenByAuthCode(authCode) + //if err != nil { + // e.OutErr(c, e.ERR, err.Error()) + // return + //} + // + //userWxAppletListDb := implement.NewUserWxAppletListDb(db.Db) + //userWxAppletList, err := userWxAppletListDb.GetUserWxAppletListByAppId(resp.AuthorizationInfo.AuthorizerAppid) + //if err != nil { + // return + //} + //if userWxAppletList == nil { + // e.OutErr(c, e.ERR_NOT_FAN, "未查询到小程序应用记录") + // return + //} + //userWxAppletList.AuthorizerRefreshToken = resp.AuthorizationInfo.AuthorizerRefreshToken + //_, err = userWxAppletListDb.UpdateUserWxAppletList(userWxAppletList, "authorizer_refresh_token") + //if err != nil { + // e.OutErr(c, e.ERR_DB_ORM, err.Error()) + // return + //} + + c.HTML(http.StatusOK, "success.html", gin.H{ + "applet_name": "激活鸟", + }) return } diff --git a/app/router/router.go b/app/router/router.go index 7c17cae..1035106 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -33,7 +33,7 @@ func Init() *gin.Engine { } r.Use(gin.Recovery()) // r.Use(mw.Limiter) - //r.LoadHTMLGlob("static/html/*") + r.Delims("<<<", ">>>").LoadHTMLGlob("static/html/*") r.GET("/favicon.ico", func(c *gin.Context) { c.Status(204) @@ -50,6 +50,7 @@ func Init() *gin.Engine { } func route(r *gin.RouterGroup) { + r.Static("/static", "./static") r.GET("/test", hdl.Demo) wxOpenNotify := r.Group("/wxOpen") { diff --git a/static/html/success.html b/static/html/success.html new file mode 100644 index 0000000..988b641 --- /dev/null +++ b/static/html/success.html @@ -0,0 +1,87 @@ + + + + + + 授权成功 + + + +
+ + +

授权成功!

+

您已成功完成微信小程序授权。

+ 前往微信 + +
+ + + + \ No newline at end of file diff --git a/static/img/success.jpeg b/static/img/success.jpeg new file mode 100644 index 0000000..65ac831 Binary files /dev/null and b/static/img/success.jpeg differ