| | |
| | | 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'; |
| | |
| | | this.showImg = false; |
| | | }, |
| | | handleFail(msg) { |
| | | console.log(msg); |
| | | Taro.showToast({ |
| | | title: msg, |
| | | icon: 'none', |
| | |
| | | }); |
| | | }, |
| | | $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: {}, |