Browse Source

更改小程序码参数

master v0.4.8
listen 3 years ago
parent
commit
30e4e1d689
2 changed files with 9 additions and 5 deletions
  1. +3
    -4
      miniapp_qrcode.client.go
  2. +6
    -1
      miniapp_qrcode.client_test.go

+ 3
- 4
miniapp_qrcode.client.go View File

@ -10,7 +10,7 @@ import (
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
) )
func GetMiniAppQrcode(appId, appSecret, page,scene string, url ...string) (string, error) {
func GetMiniAppQrcode(appId, appSecret string, qrcodeParams map[string]interface{}, url ...string) (string, error) {
conn, err := rpc_server_conn(url...) conn, err := rpc_server_conn(url...)
if err != nil { if err != nil {
@ -18,11 +18,10 @@ func GetMiniAppQrcode(appId, appSecret, page,scene string, url ...string) (strin
} }
defer conn.Close() defer conn.Close()
data := map[string]string{}
data := map[string]interface{}{}
data["app_id"] = appId data["app_id"] = appId
data["app_secret"] = appSecret data["app_secret"] = appSecret
data["page"] = page
data["scene"] = scene
data["qrcode"] = qrcodeParams
data_json, err := json.Marshal(data) data_json, err := json.Marshal(data)
if err != nil { if err != nil {


+ 6
- 1
miniapp_qrcode.client_test.go View File

@ -9,7 +9,12 @@ func Test_GetMiniappCode(t *testing.T){
appSecret := "165983626235636be54a16404e3e70a7" appSecret := "165983626235636be54a16404e3e70a7"
page := "" page := ""
scene := "user_id=2" scene := "user_id=2"
qrcode,err := GetMiniAppQrcode(appid,appSecret,page,scene)
qrcodeParams := map[string]interface{}{
"page":page,
"scene":scene,
"is_hyaline":true,
}
qrcode,err := GetMiniAppQrcode(appid,appSecret,qrcodeParams)
t.Log(qrcode) t.Log(qrcode)
t.Log(err) t.Log(err)


Loading…
Cancel
Save