acdr-ui/dist/dev/mp-weixin/sheep/api/infra/file.js

46 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-09-19 07:20:14 +08:00
"use strict";
const common_vendor = require("../../../common/vendor.js");
const sheep_config_index = require("../../config/index.js");
const FileApi = {
// 上传文件
uploadFile: (file) => {
common_vendor.index.getStorageSync("token");
common_vendor.index.showLoading({
title: "上传中"
});
return new Promise((resolve, reject) => {
common_vendor.index.uploadFile({
url: sheep_config_index.baseUrl + sheep_config_index.apiPath + "/infra/file/upload",
filePath: file,
name: "file",
header: {
// Accept: 'text/json',
Accept: "*/*",
"tenant-id": sheep_config_index.tenantId
// Authorization: 'Bearer test247',
},
success: (uploadFileRes) => {
const result = JSON.parse(uploadFileRes.data);
if (result.error === 1) {
common_vendor.index.showToast({
icon: "none",
title: result.msg
});
} else {
return resolve(result);
}
},
fail: (error) => {
console.log("上传失败:", error);
return resolve(false);
},
complete: () => {
common_vendor.index.hideLoading();
}
});
});
}
};
exports.FileApi = FileApi;
//# sourceMappingURL=file.js.map