收藏
回答

获取二维码返回不正确?

//index.js

//获取应用实例

const app = getApp()


Page({

onLoad: function () {

wx.request({

url: 'https://api.weixin.qq.com/cgi-bin/token',

header: { 'content-type': 'application/json' },

data: {

grant_type: 'client_credential',

appid: 'XXXXX',

secret: '秘钥'

},

success(res) {

var accessToken = res.data.access_token

wx.request({

url: 'https://api.weixin.qq.com/wxa/getwxacode?access_token=' + accessToken,

method: 'POST',

responseType: 'arraybuffer',

data: {

"path": 'pages/index/index',

"width": 430,

},

success(res) {

console.log(res.data)

let base64 = wx.arrayBufferToBase64(res.data)

console.log(base64)

let codeImg = 'data:image/PNG;base64,' + base64


console.log(codeImg)

},

})

}

})

}

})

--------------------------------------------------

运行后返回的accessToken有问题

ArrayBuffer(112) {}

eyJlcnJjb2RlIjo0MDAwMSwiZXJybXNnIjoiaW52YWxpZCBjcmVkZW50aWFsLCBhY2Nlc3NfdG9rZW4gaXMgaW52YWxpZCBvciBub3QgbGF0ZXN0IGhpbnRzOiBbaEtmQ0tuQUNlLXJTVG9fIV0ifQ==

data:image/PNG;base64,eyJlcnJjb2RlIjo0MDAwMSwiZXJybXNnIjoiaW52YWxpZCBjcmVkZW50aWFsLCBhY2Nlc3NfdG9rZW4gaXMgaW52YWxpZCBvciBub3QgbGF0ZXN0IGhpbnRzOiBbaEtmQ0tuQUNlLXJTVG9fIV0ifQ==



回答关注问题邀请回答
收藏
登录 后发表内容
问题标签