From 6d9139269517b8446df5ebabadee825d16bb240b Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Mon, 23 Jun 2025 17:13:54 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.js | 6 +- pages/randomlySnapPicture/addSnapPhoto.vue | 121 ++++++++++++++------- utils/aescbc.js | 4 +- 3 files changed, 86 insertions(+), 45 deletions(-) diff --git a/config.js b/config.js index 102e938..c4cc77d 100644 --- a/config.js +++ b/config.js @@ -7,8 +7,10 @@ module.exports = { // baseUrl: 'http://192.168.0.58:19090', // 杰 // baseUrl: 'http://192.168.0.176:18080', // 强 // baseUrl: 'http://192.168.0.38:18080', // 强 - fileUrl: 'http://192.168.0.14:21626/file/statics/', // 测试环境 - fileUrl2: 'http://192.168.0.14:21626/file/statics', // 测试环境 + // fileUrl: 'http://192.168.0.14:21626/file/statics/', // 测试环境 + fileUrl: 'http://192.168.0.14:1999/file/statics/', // 测试环境 + // fileUrl2: 'http://192.168.0.14:21626/file/statics', // 测试环境 + fileUrl2: 'http://192.168.0.14:1999/file/statics', // 测试环境 // 课件: 文件视频路径 coursewareUrl: 'http://192.168.0.14:9090/nxdt-courseware', // fileUrl: 'http://218.21.27.6:1999/file/statics/', // 产线环境 diff --git a/pages/randomlySnapPicture/addSnapPhoto.vue b/pages/randomlySnapPicture/addSnapPhoto.vue index 69123a4..91a3cd2 100644 --- a/pages/randomlySnapPicture/addSnapPhoto.vue +++ b/pages/randomlySnapPicture/addSnapPhoto.vue @@ -31,9 +31,9 @@ :disabled="opt.pageType === 'view'" /> - + { - item.filePath = item.url = config.fileUrl + item.filePath + // this.formData.photoType = [] + this.photoType = JSON.parse(opt.params).photoList - console.log(item.filePath, '************', item.url) - }) + if (this.photoType.length > 0) { + this.photoType.forEach(item => { + item.url = config.fileUrl + item.filePath + }) + } } }, methods: { @@ -143,9 +148,11 @@ export default { }, selectImg(e) { console.log('🚀 ~ selectImg ~ e:', e) - e.tempFiles.forEach(item => { - this.formData.photoList.push(item) - }) + // e.tempFiles.forEach(item => { + // this.formData.photoList.push(item) + // }) + + this.upload(e.tempFiles[0].path) }, upload(path) { console.log('🚀 ~ upload ~ path:', path) @@ -160,21 +167,48 @@ export default { tokenType: 'APP' }, success: res => { - console.log('🚀 ~ upload ~ res:', res) - console.log(decryptCBC(JSON.parse(res.data).data)) - this.formData.photoType.push(JSON.parse(res.data).data[0]) - console.log('🚀 ~ upload ~ this.formData.photoType:', this.formData.photoType) + // console.log('上传成功-----', res) + // console.log(decryptCBC(JSON.parse(res.data).data)) + + const data = JSON.parse(res.data).data[0] + + console.log('data-----', data) + // this.formData.photoType.push(JSON.parse(res.data).data[0]) + + // console.log(this.formData.photoType, ' this.formData.photoType') + this.photoType.push({ + ...data, + url: config.fileUrl + data.filePath + }) + this.formData.photoList.push({ + ...data, + url: config.fileUrl + data.filePath + }) + // console.log('🚀 ~ upload ~ this.formData.photoType:', this.formData.photoType) }, fail: err => { console.log('🚀 ~ upload ~ err:', err) + + uni.showToast({ + title: '上传失败', + icon: 'none', + duration: 500 + }) } }) }, deleteImg(e) { - this.formData.photoList.splice(e.index, 1) + console.log(e, '删除----') + // this.formData.photoType.splice(e.index, 1) + // this.formData.photoType = this.formData.photoType.filter(item => item.uuid !== e.uuid) + + this.photoType = this.photoType.filter(item => item.filePath !== e.tempFile.filePath) + this.formData.photoList = this.formData.photoList.filter(item => item.filePath !== e.tempFile.filePath) + + // console.log(this.formData.photoType, '删除----') }, async submitForm() { - if (!this.formData.photoList.length) { + if (!this.photoType.length) { uni.showToast({ title: '请添加照片', icon: 'none', @@ -186,29 +220,30 @@ export default { this.$refs.uForm .validate() .then(async valid => { - this.formData.photoType = [] + // this.formData.photoType = [] + this.submit() // 调用上传 - const uploadPromises = this.formData.photoList.map(item => { - console.log('🚀 ~ submitForm ~ item:', item) - if (item.uuid) { - return this.upload(item.path) - } - return Promise.resolve() - }) + // const uploadPromises = this.formData.photoList.map(item => { + // console.log('🚀 ~ submitForm ~ item:', item) + // if (item.uuid) { + // return this.upload(item.path) + // } + // return Promise.resolve() + // }) - Promise.all(uploadPromises) - .then(() => { - // 所有上传操作完成后再提交 - setTimeout(() => { - this.submit() - }, 800) - }) - .catch(error => { - // 处理上传失败的情况 - console.error('上传失败', error) - this.isLoading = false - this.formData.photoType = [] - }) + // Promise.all(uploadPromises) + // .then(() => { + // // 所有上传操作完成后再提交 + // setTimeout(() => { + // this.submit() + // }, 800) + // }) + // .catch(error => { + // // 处理上传失败的情况 + // console.error('上传失败', error) + // this.isLoading = false + // this.formData.photoType = [] + // }) }) .catch(() => { this.isLoading = false @@ -221,7 +256,11 @@ export default { if (this.opt.pageType === 'edit') { this.formData.id = this.opt.id } - const res = await addSnapshotForm(this.formData) + const params = JSON.parse(JSON.stringify(this.formData)) + params.photoType = params.photoList + + console.log('提交参数---', params) + const res = await addSnapshotForm(params) console.log('🚀 ~ submit ~ res:', res) this.isLoading = false uni.showToast({ diff --git a/utils/aescbc.js b/utils/aescbc.js index 160297e..1964a71 100644 --- a/utils/aescbc.js +++ b/utils/aescbc.js @@ -6,12 +6,12 @@ const cbc_iv = CryptoJS.enc.Utf8.parse('1234567812345678') * 默认参数需要加密 * @type {boolean} */ -const jia_mi = false +const jia_mi = true /** * 默认后台会自动加密 * @type {boolean} */ -const jie_mi = false +const jie_mi = true /** * 加密 * @param word