From 1678913eb54d4af40d9f6e44556cda316188dd9d Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Wed, 05 Jun 2024 19:10:22 +0800 Subject: [PATCH] 金额格式化优化,支持阅读模式 --- forms/userSignature/CUserSignature.vue | 61 ++++++------------------------ 1 files changed, 12 insertions(+), 49 deletions(-) diff --git a/forms/userSignature/CUserSignature.vue b/forms/userSignature/CUserSignature.vue index 8182423..71a7882 100644 --- a/forms/userSignature/CUserSignature.vue +++ b/forms/userSignature/CUserSignature.vue @@ -48,6 +48,7 @@ import { $bridge } from '@components/common/Bridge'; import { $hostBoot } from '@components/bases/HostBoot'; import CSignatureLayer from '@components/forms/userSignature/CSignatureLayer'; +import { uploadImage } from '@components/forms/imagePicker'; import project from '@project'; import './cUserSignature.scss'; @@ -86,8 +87,7 @@ if (sign.indexOf('http') >= 0) { this.itemRes.onChange(sign); } else { - const url = this._transBase64ToBlob(sign); - this.itemRes.onChange(url); + this.itemRes.onChange(sign); } }); } @@ -113,57 +113,20 @@ url: this.itemRes.formData[this.itemRes.name], fileName: 'file-' + Date.now() + '.png', }; - // 没有上传内容,视为上传成功 + // 没有上传内容,视为无需上传 if (!file.url) { callback('success'); return; } - // 不是临时文件,视为上传成功 - if ( - file.url.indexOf('blob') < 0 && - file.url.indexOf('wxfile') < 0 && - file.url.indexOf('http://tmp/') < 0 - ) { - callback('success'); - return; - } - // 开始上传 - let header = {}; - if (process.env.TARO_ENV === 'weapp') { - const localCookies = JSON.parse(Taro.getStorageSync('cookies') || '{}'); - const cookiesArr = []; - Object.keys(localCookies).forEach(key => { - cookiesArr.push(key + '=' + localCookies[key]); - }); - header['Cookie'] = cookiesArr.join('; '); - } - Taro.uploadFile({ - url: $hostBoot.getHost() + $fetchCommon.getUploadImgURL(), - header, - filePath: file.url, - fileName: file.fileName, - name: 'file', - formData: {}, - success: res => { - const res2 = - typeof res.data === 'string' ? JSON.parse(res.data) : res.data; - if (res2.state.code === 2000) { - const serverUrl = $fetchCommon.transImgPath( - 'fix', - res2.data.src || res2.data.file || res2.data.url - ); - this.itemRes.onChange(serverUrl); - callback('success'); - } else { - callback('error', res2.state.msg); - } - }, - cancel() { - callback('error', '上传图片已取消!'); - }, - fail() { - callback('error', '上传图片失败!'); - }, + uploadImage([file], (state, res) => { + if (state === 'success') { + this.itemRes.onChange(res[0]); + setTimeout(() => { + callback(state); + }, 10); + } else if (state === 'error') { + callback(state, res); + } }); }, }, -- Gitblit v1.9.1