electricity_bill_calc_wx/service/public.js

43 lines
1.1 KiB
JavaScript

import apis from '../utils/request';
import { getConfigByEnv } from "../utils/index"
const { GET, POST, PUT, DELETE } = apis
export const uploadFile = (filePath) => {
const { api } = getConfigByEnv();
return new Promise((resolve, reject) => {
wx.uploadFile({
filePath: filePath,
name: 'file',
url: `${api}/file/upload`,
header: {
authorization: 'Bearer ' + wx.getStorageSync("token")
},
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
}
})
})
}
export const uploadPublicFile = (filePath) => {
const { api } = getConfigByEnv();
return new Promise((resolve, reject) => {
wx.uploadFile({
filePath: filePath,
name: 'file',
url: `${api}/wx/public/upload`,
header: {
authorization: wx.getStorageSync("token")
},
success: (res) => {
resolve(res);
},
fail: (err) => {
reject(err);
}
})
})
}