data:{source:""}
uploadimg: function () {
var that = this;
wx.chooseImage({ //从本地相册选择图片或使用相机拍照
count: 1, // 默认9
sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
success: function (res) {
var tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: app.globalData.baseUrl + "/Video/video_upload_img",
filePath: tempFilePaths[0],
name: 'file',
formData: {
file: tempFilePaths[0],
},
success: function (res) {
var jso = JSON.parse(res.data)
console.log("单图", jso.data);
that.setData({
source: jso.data,
sourcel: true
})
}
})
}
})
},
<button class="imagess" bindtap="uploadimg">请上传自拍照</button>