| | |
| | | }).catch(res => { |
| | | that.$message.hideLoading() |
| | | console.error(res) |
| | | that.$message.showToast('文件上传失败,请联系管理员') |
| | | }) |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | |
| | | uni.chooseImage({ |
| | | count: 1, // 最多可以选择的图片张数,默认9 |
| | | sizeType: ['compressed'], //original 原图,compressed 压缩图,默认二者都有 |
| | | sourceType: ['camera', 'album'], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项 |
| | | success: function(res) { |
| | | let errMsg = res.errMsg |
| | | let tempFiles = res.tempFiles |
| | | if (errMsg === 'chooseImage:ok') { |
| | | // console.log(tempFiles[0]) |
| | | if (tempFiles[0].size > 1024 * 1024 * 5) { |
| | | that.$message.confirm('图片最多支持5M大小,超出大小限制') |
| | | // uni.chooseImage({ |
| | | // count: 9, // 最多可以选择的图片张数,默认9 |
| | | // sizeType: ['compressed'], //original 原图,compressed 压缩图,默认二者都有 |
| | | // sourceType: ['camera', 'album'], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项 |
| | | // success: function(res) { |
| | | // debugger; |
| | | // let errMsg = res.errMsg |
| | | // let tempFiles = res.tempFiles |
| | | // if (errMsg === 'chooseImage:ok') { |
| | | // // console.log(tempFiles[0]) |
| | | // if (tempFiles[0].size > 1024 * 1024 * 5) { |
| | | // that.$message.confirm('图片最多支持5M大小,超出大小限制') |
| | | // return |
| | | // } |
| | | // that.$message.showLoading() |
| | | |
| | | // let filePaths = tempFiles.map(file => file.path); |
| | | // that.$http.upload(tempFiles[0].path).then(async res => { |
| | | // console.log('res1', res) |
| | | // var pic = res.data && res.data.length > 0 && res.data[ |
| | | // 0] |
| | | // .url || '' |
| | | // that.$message.hideLoading() |
| | | // that.submitForm.pictureList.push(pic) |
| | | |
| | | // that.$forceUpdate() |
| | | // }).catch(res => { |
| | | // that.$message.hideLoading() |
| | | // console.error(res) |
| | | // // console.log("文件上传失败,请联系管理员") |
| | | // that.$message.showToast('文件上传失败,请联系管理员') |
| | | |
| | | // }) |
| | | // } |
| | | // } |
| | | // }) |
| | | |
| | | // uni.chooseImage({ |
| | | // count: 9, // 最多可以选择的图片张数,默认9 |
| | | // sizeType: ['compressed'], //original 原图,compressed 压缩图,默认二者都有 |
| | | // sourceType: ['camera', 'album'], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项 |
| | | // success: async function(res) { |
| | | |
| | | // let errMsg = res.errMsg |
| | | // let tempFiles = res.tempFiles |
| | | // if (errMsg === 'chooseImage:ok') { |
| | | // // console.log(tempFiles[0]) |
| | | // if (tempFiles[0].size > 1024 * 1024 * 5) { |
| | | // that.$message.confirm('图片最多支持5M大小,超出大小限制') |
| | | // return |
| | | // } |
| | | // that.$message.showLoading() |
| | | |
| | | // let filePaths = tempFiles.map(file => file.path); |
| | | // const resImages=[] |
| | | // for (let i = 0; i < filePaths.length; i++) { |
| | | // try { |
| | | // const res = await that.$http.upload(filePaths[i]); |
| | | // var pic = res.data && res.data.length > 0 && res.data[0].url || ''; |
| | | // if (pic) { |
| | | // // that.submitForm.pictureList.push(pic); |
| | | // resImages.push(pic); |
| | | // } |
| | | // } catch (err) { |
| | | // console.error(err); |
| | | // that.$message.showToast('文件上传失败,请联系管理员'); |
| | | // } |
| | | // } |
| | | // if(filePaths.length==resImages.length){ |
| | | // // that.submitForm.pictureList = resImages; |
| | | // that.submitForm.pictureList.push(...resImages); |
| | | // // 隐藏加载提示 |
| | | // that.$message.hideLoading(); |
| | | // that.$forceUpdate(); |
| | | // }else{ |
| | | // that.$message.showToast('文件上传失败,请联系管理员'); |
| | | // } |
| | | |
| | | // } |
| | | // } |
| | | // }) |
| | | |
| | | if(this.submitForm.pictureList?.length>=9){ |
| | | that.$message.confirm('图片最多上传9张!'); |
| | | return |
| | | } |
| | | that.$message.showLoading() |
| | | that.$http.upload(tempFiles[0].path).then(async res => { |
| | | console.log('res1', res) |
| | | var pic = res.data && res.data.length > 0 && res.data[ |
| | | 0] |
| | | .url || '' |
| | | that.$message.hideLoading() |
| | | that.submitForm.pictureList.push(pic) |
| | | |
| | | that.$forceUpdate() |
| | | }).catch(res => { |
| | | that.$message.hideLoading() |
| | | console.error(res) |
| | | uni.chooseImage({ |
| | | count: 9, // 最多可以选择的图片张数,默认9 |
| | | sizeType: ['compressed'], //original 原图,compressed 压缩图,默认二者都有 |
| | | sourceType: ['camera', 'album'], //album 从相册选图,camera 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项 |
| | | success: async function(res) { |
| | | let errMsg = res.errMsg; |
| | | let tempFiles = res.tempFiles; |
| | | if (errMsg === 'chooseImage:ok') { |
| | | // 检查文件大小 |
| | | let oversizedFile = tempFiles.find(file => file.size > 1024 * 1024 * 5); |
| | | if (oversizedFile) { |
| | | that.$message.confirm('图片最多支持5M大小,超出大小限制'); |
| | | return; |
| | | } |
| | | |
| | | // 显示加载提示 |
| | | that.$message.showLoading(); |
| | | |
| | | console.log("tempFiles") |
| | | console.log(tempFiles) |
| | | |
| | | // 获取所有文件的 path 数组 |
| | | let filePaths = tempFiles.map(file => file.path); |
| | | console.log("filePaths") |
| | | console.log(filePaths) |
| | | |
| | | // 创建上传请求的数组 |
| | | const uploadPromises = filePaths.map(path => { |
| | | return that.$http.upload(path) |
| | | .then(res => { |
| | | let pic = res.data && res.data.length > 0 && res.data[0].url || ''; |
| | | return pic; |
| | | }) |
| | | .catch(err => { |
| | | console.error(err); |
| | | return null; // 上传失败时返回 null |
| | | }); |
| | | }); |
| | | |
| | | // 使用 Promise.all 并发上传 |
| | | try { |
| | | const resImages = await Promise.all(uploadPromises); |
| | | |
| | | // 检查上传结果 |
| | | const successfulImages = resImages.filter(pic => pic !== null); |
| | | that.submitForm.pictureList.push(...successfulImages); |
| | | that.$message.hideLoading(); |
| | | that.$forceUpdate(); |
| | | if (successfulImages.length !== filePaths.length) { |
| | | // 部分上传失败 |
| | | that.$message.showToast('部分文件上传失败,请重新尝试!'); |
| | | } |
| | | } catch (err) { |
| | | console.error(err); |
| | | that.$message.showToast('文件上传失败,请联系管理员'); |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | }); |
| | | |
| | | } |
| | | }, |
| | | |
| | |
| | | <!-- :checked="submitForm.orderItems.indexOf(item.id)>=0" --> |
| | | |
| | | <!-- <image class="flower-img img100 br-4 m-r-6" :src="item.flowerCover" @click="previewImg(item.flowerCover)"></image> --> |
| | | <image class="flower-img img100 br-4 m-r-6" :src="item.flowerCover" @click="toFlowerDetail(item)"></image> |
| | | <image class="flower-img img100 br-4 m-r-6" :src="item.flowerCover" @click="toFlowerDetail(item)"> |
| | | </image> |
| | | <view class="flex1" @click.stop="toFlowerDetail(item)"> |
| | | <view class=" flex"> |
| | | <view class="title"><span class="level">{{ item.flowerCategory || ''}}</span><span |