-
zhangwei
2025-03-04 aaa8b1b2fca572d6a989179d568991ce4bd48cfb
src/components/tem/tem-upload-file.vue
@@ -189,6 +189,7 @@
            tempFiles: [],
            //preupload、uploading、success、error
            status: [],
            formDataNew: {}
         };
      },
      created() {
@@ -299,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,
@@ -317,6 +329,7 @@
                        // #ifdef H5
                        let type = e.tempFiles[i].type;
                        format = type.split('/')[1]
                        console.log(format, 'eeeeeeeeeeeeee’');
                        // #endif
                        // #ifndef H5
@@ -349,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)
@@ -483,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,