PDA
dengjunjie
2024-12-28 4d93a579467776c503fa88f1731ef82f7dc20671
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<template>
    <!-- <u-card :title="title" > -->
    <view class="" slot="body">
        <!-- <view v-for="(item,index) in tree" :key="item.id"> -->
        <u-grid :col="2">
            <u-grid-item @tap="clickCoupon(item.url,item.menuId,item.description,item.menuName)" v-for="(item) in tree"
                :key="item.menuId">
                <u-icon  :name="item.icon" custom-prefix="custom-icon" size="50"
                    color="#888888"></u-icon>
                <view class="grid-text">{{item.menuName}}</view>
            </u-grid-item>
        </u-grid>
        <!-- </view> -->
        <u-toast ref="uToast" />
    </view>
 
    <!-- </u-card> -->
</template>
 
<script>
    import {
        config
    } from '../../common/config.js'
    export default {
        data() {
            return {
                // title: '操作功能'
                datas: [],
                tree: [],
                version: ""
            }
        },
        onShow() {
            // uni.getSystemInfo({
            //     success: (res) => {
            //         this.version = res.appWgtVersion;
            //         // console.log(res);
            //         //检测当前平台,如果是安卓则启动安卓更新 
            //         if (res.platform == "android") {
            //             this.AndroidCheckUpdate();
            //         }
            //     }
            // });
        },
        onLoad() {
            this.getCurrentTree();
        },
        mounted() {
 
        },
        methods: {
            AndroidCheckUpdate: function() {
                var _this = this;
                uni.request({
                    url: 'http://10.1.211.101:9004/api/PDA/GetPDAVersion?version=' + this.version,
                    method: 'GET',
                    data: {},
                    success: res => {
                        if (res.data.data) {
 
                            uni.showToast({
                                title: '有新的版本发布,检测到您目前为Wifi连接,程序已启动自动更新。新版本下载完成后将自动弹出安装程序。',
                                mask: false,
                                duration: 5000,
                                icon: "none"
                            });
                            var dtask = plus.downloader.createDownload(
                                "http://10.1.211.101:9004/api/PDA/DownLoadApp", {},
                                function(d, status) {
                                    // 下载完成 
                                    if (status == 200) {
                                        plus.runtime.install(plus.io.convertLocalFileSystemURL(d
                                            .filename), {}, {}, function(error) {
                                            uni.showToast({
                                                title: '安装失败',
                                                mask: false,
                                                duration: 1500
                                            });
                                        })
                                    } else {
                                        uni.showToast({
                                            title: '更新失败',
                                            mask: false,
                                            duration: 1500
                                        });
                                    }
                                });
                            dtask.start();
                        }
                    },
                    fail: () => {
                        console.log('请求失败')
                    },
                    complete: () => {}
                });
            },
            getCurrentTree(ParentId) {
                this.$u.post('/api/Sys_Menu/GetTreeMenuPDAStash?ParentId=' + ParentId, {}).then(result => {
                    this.tree = result;
                })
            },
            getTree(id, data, isRootId) {
                this.datas.forEach((x) => {
                    if (x.pid == id) {
                        x.lv = data.lv + 1;
                        if (isRootId) {
                            x.rootId = id;
                        }
                        if (!data.children) data.children = [];
                        data.children.push(x);
                        this.getTree(x.id, x, isRootId);
                    }
                });
            },
            getPermission(text) {
                // return true;
                return this.datas.find(x => x.text == text);
            },
            clickCoupon(url, menuid, warehouseid, menuname) {
                // console.log("clickCoupon")
                if (this.hasLogin()) {
                    this.$u.route({
                        url: url,
                        params: {
                            menuId: menuid,
                            warehouseId: warehouseid,
                            menuName: menuname
                        }
                    })
                } else {
                    this.$t.message.loading('登录失效请重新登录')
                    uni.reLaunch({
                        url: '/pages/login/login'
                    });
                }
            },
            lock() {
                console.log("lock")
                if (this.hasLogin()) {
                    this.$u.route("pages/feeding/feeding")
                } else {
                    this.$t.message.loading('登录失效请重新登录')
                    uni.reLaunch({
                        url: '/pages/login/login'
                    });
                }
            },
 
            //判断是否登录
            hasLogin() {
                let haslogin = uni.getStorageSync('jo_user')
                if (haslogin == null || haslogin == "") {
                    return false
                } else {
                    return true
                }
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .grid-text {
        font-size: 28rpx;
        margin-top: 4rpx;
        color: $u-type-info;
    }
</style>