录屏信息: https://pan.baidu.com/s/1GsbTGWUYGUeg-KL9DV-34Q
代码如下:
chooseImage(e) {
const type = e.target.dataset.type || e.currentTarget.dataset.type
let key = type == 1 ? ‘loadUrl’ : ‘unloadUrl’
let baseKey = type == 1 ? ‘baseLoadUrl’ : ‘baseUnloadUrl’
wx.chooseImage({
count: 1,
sizeType: [‘compressed’],
sourceType: [‘album’, ‘camera’],
success: (res) => {
wx.uploadFile({
url: hostName + ‘file/upload’,
filePath: res.tempFilePaths[0],
name: ‘file’,
success: (res) => {
this.setData({
[key]: JSON.parse(res.data).data.visitUrl,
[baseKey]: JSON.parse(res.data).data.baseUrl,
})
},
fail: function () {
wx.showToast({
title: “上传失败”,
icon: ‘none’,
duration: 2000
})
}
})
}
})
}
手机信息如下 :