import functions from "./functions.js"; const apiUrl = `${functions.getDomain()}/api/upload`; export default function() { return new Promise((relove, reject) => { uni.chooseImage({ count: 1, //默认9 sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有 sourceType: ['album',"camera"], //从相册选择 success: function(res) { let path = res.tempFilePaths[0]; uni.uploadFile({ url: apiUrl, filePath: path, name: 'file', formData: {}, success: (uploadFileRes) => { let res = JSON.parse(uploadFileRes.data); if (res.code == 200) { relove(res.data); } else { functions.error(res.msg); } } }); } }); }) }