You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
"use strict";
|
|
const common_vendor = require("../common/vendor.js");
|
|
const config_site_config = require("../config/site.config.js");
|
|
let goPage = (url, params = {}, type = "navigateTo") => {
|
|
common_vendor.index.$u.route({
|
|
url,
|
|
params,
|
|
type
|
|
});
|
|
};
|
|
let { H5_API, WX_API, httpPrefix } = config_site_config.obj;
|
|
var _url = H5_API + WX_API + httpPrefix;
|
|
function uploadImgApi(filePath, imgName, imgLink = "image") {
|
|
console.log(filePath);
|
|
let token = "Bearer " + common_vendor.index.getStorageSync("token");
|
|
let timer = /* @__PURE__ */ new Date() * 1;
|
|
return new Promise((reslove, reject) => {
|
|
common_vendor.index.uploadFile({
|
|
url: _url + "infra/file/upload",
|
|
//接口
|
|
filePath,
|
|
//要上传的图片的本地路径
|
|
name: "file",
|
|
// complain
|
|
formData: {
|
|
path: imgLink + "/" + common_vendor.index.$u.date(timer, "yyyy-mm-dd") + "/" + timer + "-" + imgName,
|
|
type: 1,
|
|
fileSuffix: "png"
|
|
},
|
|
header: {
|
|
Authorization: token
|
|
// 'tenant-id': '1704459882232553474'
|
|
},
|
|
success(res) {
|
|
console.log("上传成功??");
|
|
console.log(res);
|
|
let res2 = JSON.parse(res.data);
|
|
reslove(res2.data);
|
|
},
|
|
fail(error) {
|
|
return Promise.reject(error);
|
|
},
|
|
complete: (err) => {
|
|
common_vendor.index.hideLoading();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
exports.goPage = goPage;
|
|
exports.uploadImgApi = uploadImgApi;
|