获取小程序码base64后无法显示,请给出方法或思路,别让大家在这里瞎折腾好吗?
wx.request({ //获取小程序码 url: "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + getApp().globalData.access_token, //获取小程序码 header: { 'content-type' : 'application/json' }, data:{ scene: json.content, page: "pages/news/detial" , width:430 }, method: "POST" , success: function (res) { console.log(res); var json = res.data; console.log( "json.length=" + json.length); console.log( "content length=" + res.header[ 'Content-Length' ]); var a = new Uint8Array(json.length) for ( var i=0;i<json.length;++i){ a[i]=json.charCodeAt(i); } var b = wx.arrayBufferToBase64(a); console.log(b.substring(0,100)) that.setData({ img: b }) wx.hideNavigationBarLoading(); } }) |
console.log返回的结果:
{data: “����”, header: {…}, statusCode: 200, errMsg: “request:ok”}
json.length=91729
content length=96702
/f39/QAQSkZJRgABAQAAAQABAAD9/QBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEB
可以看出:
res.data是字符串格式的图片数据,然而转换成base64后图片并不能显示出来,
请问微信的技术人员,该如何显示潘慧的小程序码图片呢?
如果现在显示不出来,能不能说一声,避免大家浪费数据在这里瞎测试,
如果能显示,请给出方法或思路,别让大家在这里瞎折腾好吗????
3 回复