|
@@ -74,3 +74,44 @@ export function request(options) {
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 文件上传
|
|
|
+ * @param {string} filePath 文件路径
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+export async function uploadFile(filePath) {
|
|
|
+ const { deviceId, osName, osVersion } = await getSystemInfoAsync();
|
|
|
+ const access_token = store.getters.access_token;
|
|
|
+ uni.showLoading({
|
|
|
+ title: '正在上传,请稍后'
|
|
|
+ })
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ uni.uploadFile({
|
|
|
+ url: BASE_URL + '/maintain/file',
|
|
|
+ filePath: filePath,
|
|
|
+ name: 'file',
|
|
|
+ header: {
|
|
|
+ Authorization: `Bearer ${access_token}`,
|
|
|
+ 'Content-Type': 'application/json; charset=utf-8',
|
|
|
+ client_id: 'chelvc_client',
|
|
|
+ client_secret: 'qWBe6jD%GCuPPTkP',
|
|
|
+ grant_type: 'wechat',
|
|
|
+ Device: deviceId,
|
|
|
+ Platform: osName.toUpperCase(),
|
|
|
+ Version: osVersion,
|
|
|
+ Terminal: 'APPLET',
|
|
|
+ Business: 'CUSTOMER',
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ resolve(res.data);
|
|
|
+ },
|
|
|
+ fail: err => {
|
|
|
+ reject(err);
|
|
|
+ },
|
|
|
+ complete:()=>{
|
|
|
+ uni.hideLoading()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|