uploadFile(index){//选择图片 this.biuldPlanId = this.arr[index].id let _this = this // #ifdef H5 uni.chooseImage({ // count: 允许上传的照片数量 count: 1, // sizeType: original 原图,compressed 压缩图,默认二者都有 sizeType: "compressed", success(res) { // _this.iconFile = res.tempFiles[0] _this.iconFile = res.tempFiles[0] _this.uploadImg() }, fail(res) { console.log('失败', res); } }); // #endif // #ifdef MP-WEIXIN uni.getSetting({ success(res) { if (res.authSetting['scope.camera']) { uni.chooseImage({ // count: 允许上传的照片数量 count: 1, // sizeType: original 原图,compressed 压缩图,默认二者都有 sizeType: "compressed", success(res) { _this.iconFile = res.tempFilePaths[0] _this.uploadImg() }, fail(res) { console.log('失败', res); } }); } else { _this.getLimit('scope.camera') } } }) // #endif }, uploadImg(){//上传图片 let _this = this // #ifdef H5 uni.uploadFile({ url: _this.uploadUrl, header: { "Authorization": uni.getStorageSync('access_token'), }, name: 'IconFiles', file: _this.iconFile, success(res) { let obj = JSON.parse(res.data) _this.confirmImg(obj.message); }, fail(res) { console.log('失败', res) } }) // #endif // #ifdef MP-WEIXIN uni.uploadFile({ url: _this.uploadUrl, header: { "Authorization": uni.getStorageSync('access_token'), }, filePath: _this.iconFile, name: 'IconFiles', // files: aa, success(res) { let obj = JSON.parse(res.data) // 得到 图片路径 _this.confirmImg(obj.message); }, fail(res) { console.log('失败', res) } }) // #endif },