楼主你好, 我是在java后台获取小程序二维码的, 也是base64编码, 跟你一样也是显示不出来.请问你是怎么解决的
获取小程序码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后图片并不能显示出来, 请问微信的技术人员,该如何显示潘慧的小程序码图片呢? 如果现在显示不出来,能不能说一声,避免大家浪费数据在这里瞎测试, 如果能显示,请给出方法或思路,别让大家在这里瞎折腾好吗????
2018-11-12