66 lines
1.7 KiB
JavaScript
66 lines
1.7 KiB
JavaScript
// import base from "@/config/baseUrl";
|
||
// let baseUrl = 'https://ceshi.excellentkk.cn/api';
|
||
import store from '../store';
|
||
import { HTTP_REQUEST_URL_TWO, HTTP_REQUEST_URL_THREE, HEADER } from '@/config/app';
|
||
let header = HEADER;
|
||
if (store.state.app.token){
|
||
header.token = store.state.app.token;
|
||
}
|
||
function uploads(src, type) {
|
||
return new Promise((resolve, reject) => {
|
||
// //console.log('上传', type === 'img' ? '图片' : '视频', ':', src)
|
||
let a = uni.uploadFile({
|
||
// url: base.baseUrl + '/upload?token=',
|
||
url: HTTP_REQUEST_URL_TWO + '/api' + '/upload?token=',
|
||
filePath: src,
|
||
name: 'file',
|
||
success: (res) => {
|
||
let data = JSON.parse(res.data)
|
||
if (data.code != 1) {
|
||
uni.$u.toast(data.msg)
|
||
return false
|
||
} else {
|
||
resolve(data.data.url) // 返回线上地址
|
||
}
|
||
},
|
||
fail: (err) => {
|
||
reject(err)
|
||
//console.log('upload-上传失败', err)
|
||
}
|
||
});
|
||
})
|
||
}
|
||
|
||
function oaUploads(src, type) {
|
||
return new Promise((resolve, reject) => {
|
||
// //console.log('上传', type === 'img' ? '图片' : '视频', ':', src)
|
||
|
||
let a = uni.uploadFile({
|
||
url: HTTP_REQUEST_URL_THREE + '/api/common/upload',
|
||
filePath: src,
|
||
name: 'file',
|
||
header: header,
|
||
success: (res) => {
|
||
|
||
let data = JSON.parse(res.data)
|
||
if (data.code == 0) {
|
||
resolve(data.data) // 返回线上地址
|
||
} else {
|
||
uni.$u.toast(data.msg)
|
||
return false
|
||
}
|
||
},
|
||
fail: (err) => {
|
||
reject(err)
|
||
//console.log('upload-上传失败', err)
|
||
}
|
||
});
|
||
})
|
||
}
|
||
|
||
|
||
export {
|
||
uploads,
|
||
oaUploads
|
||
}
|