zhiyong.zhou
2024-02-26 60d911172b1dbebe0ab952ce10366b327d5744f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
    }
}