import application from '@/config/application';
|
|
import baseApi from '@/common/services';
|
|
export default {
|
errorToast({title}) {
|
uni.showToast({
|
title,
|
icon: 'error'
|
});
|
},
|
downFile(item) {
|
const filePath = `${application.baseURL}/worder/root/file/download?id=${item.id}`;
|
const tempLink = document.createElement("a");
|
tempLink.style.display = "none";
|
tempLink.href = filePath;
|
tempLink.setAttribute("download", item.name);
|
tempLink.setAttribute("target", "_blank");
|
document.body.appendChild(tempLink);
|
tempLink.click();
|
document.body.removeChild(tempLink);
|
},
|
uploadFile(path) {
|
return new Promise((resolve, reject) => {
|
//获取图片临时路径
|
uni.uploadFile({
|
url: baseApi.fileUploadUrl, //【必填】图片上传地址
|
filePath: path, //【必填】(files和filePath选其一)要上传文件资源的路径。
|
name: 'file', //【必填】上传名字,注意与后台接收的参数名一致
|
success: res => {
|
const id = JSON.parse(res.data).data.ids[0];
|
resolve(id);
|
}
|
});
|
});
|
},
|
pageBack(vue) {
|
window.setTimeout(() => {
|
vue.$router.go(-1);
|
}, 500);
|
},
|
pageRefresh(vue) {
|
window.setTimeout(() => {
|
vue.$router.go(0);
|
}, 500);
|
},
|
getPageParams() {
|
const currentPages = getCurrentPages();
|
const currentPage = currentPages[currentPages.length - 1];
|
return currentPage.options;
|
}
|
}
|