add QQ扫码登录

This commit is contained in:
ZJY 2021-09-29 11:39:58 +08:00
parent e9e86e6d24
commit f1ebe0999d
2 changed files with 20 additions and 18 deletions

View File

@ -86,7 +86,6 @@ func (c *LoginController) GetQrcode1() {
if err1 == nil { if err1 == nil {
fmt.Println(string(body)) fmt.Println(string(body))
} }
s := &models.QQuery{} s := &models.QQuery{}
if len(body) > 0 { if len(body) > 0 {
err := json.Unmarshal(body, &s) err := json.Unmarshal(body, &s)
@ -97,10 +96,11 @@ func (c *LoginController) GetQrcode1() {
//jsonByte, _ := json.Marshal(s) //jsonByte, _ := json.Marshal(s)
//jsonStr := string(jsonByte) //jsonStr := string(jsonByte)
//fmt.Printf("%v", jsonStr) //fmt.Printf("%v", jsonStr)
ddd, _ := base64.StdEncoding.DecodeString(s.Data.QqLoginQrcode.Bytes) //ddd, _ := base64.StdEncoding.DecodeString(s.Data.QqLoginQrcode.Bytes)
c.Ctx.WriteString(`{"url":"` + "url" + `","img":"` + base64.StdEncoding.EncodeToString(ddd) + `"}`) //"data:image/png;base64," + //c.Ctx.WriteString(`{"url":"` + "url" + `","img":"` + base64.StdEncoding.EncodeToString(ddd) + `"}`) //"data:image/png;base64," +
//c.Ctx.WriteString(s.Data.QqLoginQrcode.Bytes) //"data:image/png;base64," + fmt.Println(`{"url":"` + "url" + `","img":"` + s.Data.QqLoginQrcode.Bytes + `"}`)
c.Ctx.WriteString(`{"url":"` + "url" + `","img":"` + s.Data.QqLoginQrcode.Bytes + `"}`)
return
} }
func (c *LoginController) GetQrcode() { func (c *LoginController) GetQrcode() {

View File

@ -1,12 +1,10 @@
package models package models
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/beego/beego/v2/client/httplib" "github.com/beego/beego/v2/client/httplib"
"github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/core/logs"
"io/ioutil"
"regexp" "regexp"
"strings" "strings"
"time" "time"
@ -141,20 +139,24 @@ var codeSignals = []CodeSignal{
{ {
Command: []string{"qrcode", "扫码", "二维码", "scan"}, Command: []string{"qrcode", "扫码", "二维码", "scan"},
Handle: func(sender *Sender) interface{} { Handle: func(sender *Sender) interface{} {
rsp, err := httplib.Post("https://api.kukuqaq.com/jd/qrcode").Response() //rsp, err := httplib.Post("https://api.kukuqaq.com/jd/qrcode").Response()
//if err != nil {
// return nil
//}
//body, err1 := ioutil.ReadAll(rsp.Body)
//if err1 == nil {
// fmt.Println(string(body))
//}
//s := &QQuery{}
//if len(body) > 0 {
// json.Unmarshal(body, &s)
//}
//logs.Info(s.Data.QqLoginQrcode.Bytes)
//ddd, _ := base64.StdEncoding.DecodeString(s.Data.QqLoginQrcode.Bytes)
rsp, err := httplib.Get("http://127.0.0.1:5703/api/login/qrcode1").Response()
if err != nil { if err != nil {
return nil return nil
} }
body, err1 := ioutil.ReadAll(rsp.Body)
if err1 == nil {
fmt.Println(string(body))
}
s := &QQuery{}
if len(body) > 0 {
json.Unmarshal(body, &s)
}
logs.Info(s.Data.QqLoginQrcode.Bytes)
//ddd, _ := base64.StdEncoding.DecodeString(s.Data.QqLoginQrcode.Bytes)
return rsp return rsp
}, },
}, },