master
huanghai 5 years ago
parent 3133d7f5dc
commit 1c3d7d77e8

@ -21,6 +21,7 @@ import (
"fmt"
"github.com/dchest/captcha"
"github.com/gin-gonic/gin"
"github.com/opesun/goquery"
"github.com/tidwall/gjson"
"io/ioutil"
"net/http"
@ -48,6 +49,8 @@ func Routers(r *gin.RouterGroup) {
r.GET("/resetRemainCount", resetRemainCount)
//微信登录
r.POST("/wxLogin", wxLogin)
//微信二维码
r.GET("/wxShowImg", wxShowImg)
return
}
@ -524,3 +527,24 @@ func wxLogin(context *gin.Context) {
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "openid": ""})
}
}
// @Summary 微信显示二维码
// @Description 微信显示二维码
// @Tags 登录验证类
// @Accept application/x-www-form-urlencoded
// @Produce json
// @Success 200 {string} string
// @Router /oauth2/wxShowImg [get]
// http://10.10.14.187/oauth2/wxShowImg
func wxShowImg(context *gin.Context) {
url := `https://open.weixin.qq.com/connect/qrconnect?appid=wx3e0449144386938a&redirect_uri=http://fort.edusoa.com:7777/sso/static/jumpWx.html&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect`
//获取http代码
p, err := goquery.ParseUrl(url)
if err != nil {
context.JSON(http.StatusOK, map[string]interface{}{"success": false, "imgSrc": "", "message": "获取微信图片发生异常!"})
} else {
pTitle := p.Find("img").Attr("src")
pTitle = `https://open.weixin.qq.com/` + pTitle
context.JSON(http.StatusOK, map[string]interface{}{"success": true, "imgSrc": pTitle})
}
}

@ -33,6 +33,7 @@ require (
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-sqlite3 v1.10.0 // indirect
github.com/oklog/ulid v1.3.1
github.com/opesun/goquery v0.0.0-20160908163916-0d77e43213cd // indirect
github.com/pborman/uuid v1.2.0 // indirect
github.com/pkg/errors v0.9.1
github.com/pkg/sftp v1.11.0

@ -241,6 +241,8 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/opesun/goquery v0.0.0-20160908163916-0d77e43213cd h1:taV1toAfzAdRwNWpIB7JMdgX2xL+JT3Rq8GXzyPK1Is=
github.com/opesun/goquery v0.0.0-20160908163916-0d77e43213cd/go.mod h1:XIY7IuxoZH2deZdjIgzLqXlYkOHiwNC+hL1m3vS2A8g=
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/pierrec/lz4 v2.4.1+incompatible h1:mFe7ttWaflA46Mhqh+jUfjp2qTbPYxLB2/OyBppH9dg=

Loading…
Cancel
Save