From f946789c8eb72af1c1a0b16cb4206bc12a11450b Mon Sep 17 00:00:00 2001 From: PQZ Date: Wed, 9 Apr 2025 11:26:49 +0800 Subject: [PATCH] 1 --- pages/mine/card/card-detail.vue | 33 ++++++++++++++++++++++++++++----- utils/upload.js | 2 +- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/pages/mine/card/card-detail.vue b/pages/mine/card/card-detail.vue index cdf9f1a..2218f3c 100644 --- a/pages/mine/card/card-detail.vue +++ b/pages/mine/card/card-detail.vue @@ -108,11 +108,14 @@ }, data() { return { + uploadUrl: config.baseUrl+'/common/upload', + headers: {}, //所有可选的平台 range: [], sizeType: ['compressed'], //图片数组 fileList: [], + imageUrl:[], //地址集合 addressList: [], //名片数据对象 @@ -141,12 +144,23 @@ /**初始化数据*/ initData(id) { + this.fileList = [] + this.imageUrl = [] if (id) { getBusiCardById({ id: id }).then(res => { console.log(res.data, 133) this.dataObj = res.data + if (this.dataObj.image != null && this.dataObj.image != ''){ + console.log(this.dataObj.image,'this.dataObj.image') + this.imageUrl = this.dataObj.image.split(',') + this.imageUrl.map((item)=>{ + this.fileList.push({ + url:config.baseUrl + item + }) + }) + } }).catch((e) => { uni.showToast({ icon: 'error', @@ -230,7 +244,11 @@ toast("收货地址不能为空") return } - // console.log(this.fileList,'fileList') + if (this.fileList.length == 0) { + toast("证明材料不能为空") + return + } + this.dataObj.image = this.imageUrl.join(','); applyBusiCard(this.dataObj).then(res => { if (res.code == 200) { uni.showToast({ @@ -250,24 +268,29 @@ }, afterRead(file) { - for (let i = 0; i < file.tempFilePaths.length; i++) { upload({ url: '', filePath: file.tempFilePaths[i] }).then((res) => { - console.log(res, '215') this.fileList.push({ - url: config.baseUrl + res.data + url: res.url }) - console.log(this.fileList, 'fileList') + this.imageUrl.push(res.fileName) }) } }, deleteFile(file, index) { console.log('删除文件'); this.fileList.splice(index, 1); + this.imageUrl.splice(index, 1); }, + uploadSuccess(res, file) { + console.log('上传成功', res); + }, + uploadFail(error, file) { + console.log('上传失败', error); + }, } } diff --git a/utils/upload.js b/utils/upload.js index 740387e..856aa8e 100644 --- a/utils/upload.js +++ b/utils/upload.js @@ -23,7 +23,7 @@ const upload = config => { return new Promise((resolve, reject) => { uni.uploadFile({ timeout: config.timeout || timeout, - url: baseUrl + config.url, + url: baseUrl + '/common/upload' + config.url, filePath: config.filePath, name: config.name || 'file', header: config.header,