PC 端微信打开小程序 上传 临时路径返回wxfile://tmp
本地测试无法打开 后端无法接收
修改代码
// /线下支付==》上传
upHeaderPhoto() {
const that = this;
wx.chooseImage({
count: 1,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success(res) {
// tempFilePath可以作为img标签的src属性显示图片
const tempFilePaths = res.tempFilePaths
let imgPathArr = []
tempFilePaths.forEach((item, index) => {
console.log(tempFilePaths[index], '虚拟路径图片')
wx.uploadFile({
url: api.get_UpdataWxCode,
filePath: tempFilePaths[index],
name: 'file',
formData: {
'paytype': 1,
"type": 'paycertificate'
},
header: {
// 'Content-Type': 'multipart/form-data',(这个地方注释掉就可以了 解决PC打开微信小程序上传路径的问题)
'X-Requested-With': 'XMLHttpRequest',
'user-token': wx.getStorageSync('user_token'),
},
responseType: 'text',
success: (res) => {
console.log(JSON.parse(res.data), '服务器返回的微信图片')
imgPathArr.push(JSON.parse(res.data).data.src)
that.setData({
imgPathArr: that.data.imgPathArr.concat(imgPathArr)
})
}
})
})
// }
}
})
},