import {getToken} from '@/libs/auth.js';
import config from "@/config/index.js"
const baseUrl = process.env.NODE_ENV === 'development' ? config.uploadFile.dev : config.uploadFile.pro;	
/*
opCode	
0 上传
1删除
*/
export const upload=({formData,filePath,callback})=>{
	return new Promise(function(resolve,reject){
		const uploadTask=uni.uploadFile({
			url: baseUrl+'/admin/uploadFile',
			filePath,
			header:{
				[config.TokenKey]:getToken()
			},
			name: 'file',
			formData,
			success: (uploadFileRes) => {
				resolve(uploadFileRes.data)
			},
			fail({errMsg}){
				reject(errMsg)
			}
		});	
		if(callback){
			callback(uploadTask);
		}
				
	})
}	