From 51b397a2717b800bda92144fa67d89b2ee231d3c Mon Sep 17 00:00:00 2001 From: Tevin <tingquanren@163.com> Date: Tue, 22 Feb 2022 15:21:33 +0800 Subject: [PATCH] Merge branch 'master' of ssh://dev.zhiheiot.com:29418/mob-components --- forms/imagePicker/CImagePicker.vue | 24 ++++++++++++++++++++---- 1 files changed, 20 insertions(+), 4 deletions(-) diff --git a/forms/imagePicker/CImagePicker.vue b/forms/imagePicker/CImagePicker.vue index 09012bd..8ab735c 100644 --- a/forms/imagePicker/CImagePicker.vue +++ b/forms/imagePicker/CImagePicker.vue @@ -32,6 +32,7 @@ import Taro from '@tarojs/taro'; import { $ } from '@tarojs/extend'; import { AtInput, AtImagePicker, AtCurtain } from 'taro-ui-vue'; +import { Fetcher } from '@components/bases/Fetcher'; import { $fetchCommon } from '@fetchers/FCommon'; import { Tools } from '@components/common/Tools'; import CImageCompressor from './CImageCompressor.vue'; @@ -160,7 +161,6 @@ this.showImg = false; }, handleFail(msg) { - console.log(msg); Taro.showToast({ title: msg, icon: 'none', @@ -169,19 +169,35 @@ }); }, $uploadImage(callback) { - const url = $fetchCommon.getUploadImgURL(); + const url = Fetcher.host + $fetchCommon.getUploadImgURL(); const uploadTeam = []; const imgs = []; this.files.forEach(file => { if (file.type === 'btn') { return; } - // blob 临时文件才上传 - if (file.url.indexOf('blob') >= 0) { + // 临时文件才上传 + if ( + file.url.indexOf('blob') >= 0 || + file.url.indexOf('wxfile') >= 0 || + file.url.indexOf('http://tmp/') >= 0 + ) { + 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('; '); + } uploadTeam.push( new Promise((resolve, reject) => { Taro.uploadFile({ url, + header, filePath: file.url, name: 'file', formData: {}, -- Gitblit v1.9.1