| 12345678910111213141516171819202122232425 |
- import store from '../store'
- import { baseURL } from '@/api/config'
- export function upload({ url, ...config }, loading = false) {
- if (loading) uni.showLoading({ title: '上传中' })
- return new Promise((resolve, reject) => {
- uni.uploadFile({
- url: baseURL + url,
- header: {
- token: store.state.token
- },
- name: 'file',
- ...config,
- success: res => {
- resolve(res.data)
- },
- fail: err => {
- reject(err)
- },
- complete: () => {
- if (loading) uni.hideLoading()
- }
- })
- })
- }
|