From aaa8b1b2fca572d6a989179d568991ce4bd48cfb Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期二, 04 三月 2025 17:30:32 +0800 Subject: [PATCH] - --- src/components/tem/tem-upload-file.vue | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/components/tem/tem-upload-file.vue b/src/components/tem/tem-upload-file.vue index 09379ea..d49b47b 100644 --- a/src/components/tem/tem-upload-file.vue +++ b/src/components/tem/tem-upload-file.vue @@ -27,14 +27,24 @@ <fui-icon name="close" color="#fff" :size="32"></fui-icon> </view> </view> + <view class="fui-upload__item" + :class="[borderColor && borderColor!==true?'fui-upload__border':'fui-upload__noborder']" + :style="{width:width+'rpx',borderRadius:radius+'rpx',borderColor:borderColor,borderStyle:borderSytle}" + v-if="showAdd" @tap.stop="chooseImage"> + <slot> + <u-button type="primary" text="涓婁紶" size="small"></u-button> + <!-- <fui-icon name="plus" :size="addSize" :color="addColor"></fui-icon> --> + </slot> + </view> + <!-- <view class="fui-upload__item" :class="[borderColor && borderColor!==true?'fui-upload__border':'fui-upload__noborder']" :style="{width:width+'rpx',height:height+'rpx',background:background,borderRadius:radius+'rpx',borderColor:borderColor,borderStyle:borderSytle}" v-if="showAdd" @tap.stop="chooseImage"> <slot> <fui-icon name="plus" :size="addSize" :color="addColor"></fui-icon> </slot> - </view> + </view> --> </view> </template> @@ -164,13 +174,13 @@ type: [Number, String], default: 0 }, - fileType:{ - type:String, - default:'file' + fileType: { + type: String, + default: 'file' }, - fileExtension:{ - type:Array, - default:[] + fileExtension: { + type: Array, + default: [] } }, data() { @@ -178,7 +188,8 @@ urls: [], tempFiles: [], //preupload銆乽ploading銆乻uccess銆乪rror - status: [] + status: [], + formDataNew: {} }; }, created() { @@ -289,6 +300,17 @@ }, chooseImage() { let max = Number(this.max) + this.$api.GetToken().then(res => { + this.formDataNew = { + policy: res.data.policy, //琛ㄥ崟鍩� + 'x-oss-signature-version': res.data.x_oss_signature_version, //鎸囧畾绛惧悕鐨勭増鏈拰绠楁硶 + 'x-oss-credential': res.data.x_oss_credential, //鎸囨槑娲剧敓瀵嗛挜鐨勫弬鏁伴泦 + 'x-oss-date': res.data.x_oss_date, //璇锋眰鐨勬椂闂� + 'x-oss-signature': res.data.signature, //绛惧悕璁よ瘉鎻忚堪淇℃伅 + 'x-oss-security-token': res.data.security_token, //瀹夊叏浠ょ墝 + 'success_action_status': "200" //涓婁紶鎴愬姛鍚庡搷搴旂姸鎬佺爜 + } + }) wx.chooseMessageFile({ count: max === -1 ? 9 : max - this.urls.length, type: this.fileType, @@ -307,6 +329,7 @@ // #ifdef H5 let type = e.tempFiles[i].type; format = type.split('/')[1] + console.log(format, 'eeeeeeeeeeeeee鈥�'); // #endif // #ifndef H5 @@ -339,7 +362,9 @@ if (this.immediate) { for (let j = 0; j < imageArr.length; j++) { let index = start + j - this.uploadImage(index, imageArr[j]).then((res) => { + let obj = JSON.parse(JSON.stringify(this.formDataNew)) + obj.key = this.$util.generateTimestampWithRandom(imageArr[j]) + this.uploadImage(index, imageArr[j], null, obj).then((res) => { this._success(res) }).catch((res) => { this._error(res) @@ -473,16 +498,18 @@ // } // }) // }, - uploadImage(index, imgUrl, url) { + uploadImage(index, imgUrl, url, formDataNew) { return new Promise((resolve, reject) => { uni.uploadFile({ url: this.url || url, name: this.name, header: this.header, - formData: this.formData, + formData: formDataNew, filePath: imgUrl, success: (res) => { if (res.statusCode === 200) { + res.data = + `https://appimchat.oss-cn-chengdu.aliyuncs.com/${formDataNew.key}` this.$set(this.status, index, 'success') resolve({ res, @@ -632,8 +659,9 @@ /* #endif */ align-items: center; justify-content: center; - margin-right: 20rpx; - margin-bottom: 20rpx; + /* margin-right: 20rpx; + margin-bottom: 20rpx; */ + margin: 10rpx 10rpx 10rpx 0; /* #ifdef H5 */ cursor: pointer; /* #endif */ -- Gitblit v1.9.1