merchapp/java-mall-app-shop-admin/api/upload.js
2025-05-09 17:16:48 +08:00

33 lines
777 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 上传接口
* @author Seven
* @data 2025-3-1
* @param {
* filePath:'文件路径'
* formData二进制
* }
* @returns { }
* @seehttps://mall.gpxscs.cn/mobile/shop/oss/upload
*/
export function UploadFilePromise(filePath, formData) {
let ukey = uni.getStorageSync('ukey');
return new Promise((resolve, reject) => {
uni.uploadFile({
// 完整上传路径 H5端需要解决跨域问题
url: 'https://mall.gpxscs.cn/mobile/shop/oss/upload',
method: 'POST',
filePath: filePath,
name: 'upfile',
formData: { perm_key: ukey, ...formData },
success: (res) => {
const result = JSON.parse(res.data);
resolve(result);
},
fail: (res) => {
reject(res);
},
});
});
}