ke_junjie
2025-06-04 4bf0783db564f0d446c74d7b42242aff879b894c
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<template>
    <view class="loginP">
        <view class="logo">
            <image src="@/static/image/login/logo-qq.jpg" mode=""></image>
        </view>
        <view class="mainTitle">
            <h3>智能化立体库系统</h3>
            <h2>系统登录</h2>
        </view>
        <view class="user-pwd">
            <view class="userP">
                <i class="iconfont icon-yonghutouxiang"></i>
                <view class="inputC">
                    <u-input v-model="phone" type="text" placeholder="用户名/手机号" />
                </view>
            </view>
            <view class="pwdP">
                <i class="iconfont icon-mima"></i>
                <view class="inputC">
                    <u-input v-model="pwd" type="password" placeholder="密码" />
                </view>
            </view>
        </view>
        <view class="loginBtnP" style="padding: 2rem 0 1rem 0;">
            <view class="loginBtn" @click="goHome">
                系统登录
            </view>
        </view>
        <view class="forgot-register">
            <view class="forgot">
                <!-- 设置接口地址 -->
            </view>
            <view class="register" @click="update">
                更新APP
            </view>
        </view>
        <view class="" style="position: fixed;left:12px;bottom: 5px;width: 100%;text-align: center;">
            应用版本号 {{wgtVer}}
        </view>
        <u-toast ref="uToast" />
    </view>
</template>
<script lang='js'>
    import {
        login
    } from '../../api/login.js'
    import {
        SearchOne
    } from '../../api/upDate.js'
    export default {
        data() {
            return {
                phone: "",
                pwd: "",
                wgtVer: '',
                version: '',
                data: null,
                isandroid: ''
            }
        },
        created() {
            this.plusReady()
        },
        methods: {
            //自动更新
            update() {
                this.plusReady();
                this.AndroidCheckUpdate();
            },
            // 获取当前版本号
            plusReady() {
                var that = this;
                // 获取本地应用资源版本号  
                try{
                    plus.runtime.getProperty(plus.runtime.appid, function(inf) {
                        that.data = inf
                        that.wgtVer = inf.version; //获取当前版本号
                        that.version = plus.runtime.version;
                    });
                }catch(e){
                    //TODO handle the exception
                }
            },
            // 自动更新
            AndroidCheckUpdate() {
                var that2 = this;
                let params = {
                    Url: '',
                    Version: ''
                }
                SearchOne(params).then((res) => {
                    if (res.Version != that2.version) {
                        // if (plus.networkinfo.getCurrentType() != 3) {
                        //     uni.showToast({
                        //         title: '有新的版本发布,检测到您目前非Wifi连接,为节约您的流量,程序已停止自动更新,将在您连接WIFI之后重新检测更新。',
                        //         mask: false,
                        //         duration: 5000,
                        //         icon: "none"
                        //     });
                        //     return;
                        // }
                        // uni.showToast({
                        //     title: '有新的版本发布,检测到您目前为Wifi连接,程序已启动自动更新。新版本下载完成后将自动弹出安装程序。',
                        //     mask: false,
                        //     duration: 5000,
                        //     icon: "none"
                        // });
                        //res.data.androidurl    是apk的下载链接
                        var url = this.$myHOST + '/Home/GetDownLoad?name=' + res
                            .Url; //文件名称可以在上传时进行保存,下载时取出,当文件名称中存在单双引号时,要做好处理,否则会报错
                        var name = 'qingqi.apk';
                        // plus.runtime.openURL(this.$myHOST + '/Home/GetDownLoad?name=' + res.Url, function(res) {console.log(res);});  
                        var dtask = plus.downloader.createDownload(url, {}, function(d, status) {
                            //d为下载的文件对象
                            // if (res.statusCode == 200) {
                            //选择软件打开文件
                            plus.runtime.install(d.filename, {}, {}, function(e) {
                                console.log(e)
                            })
                            // } else {
                            //     //下载失败
                            //     plus.downloader.clear(); //清除下载任务
                            // }
                        })
                        // dtask.start(); //执行下载
                        try {
                            dtask.start(); // 开启下载的任务
                            var prg = 0;
                            var showLoading = plus.nativeUI.showWaiting("正在下载"); //创建一个showWaiting对象 
 
                            dtask.addEventListener('statechanged', function(task, status) {
                            
                                // 给下载任务设置一个监听 并根据状态  做操作
                                switch (task.state) {
                                    case 1:
                                        showLoading.setTitle("正在下载");
                                        break;
                                    case 2:
                                        showLoading.setTitle("已连接到服务器");
                                        break;
                                    case 3:
                                        prg = parseInt((parseFloat(task.downloadedSize) / parseFloat(task
                                                .totalSize)) *
                                            100);
                                        showLoading.setTitle("  正在下载" + JSON.stringify(task.downloadedSize));
                                        break;
                                    case 4:
                                        plus.nativeUI.closeWaiting();
                                        //下载完成
                                        break;
                                }
                            });
                        } catch (err) {
                            console.log('错误信息', err)
                            plus.nativeUI.closeWaiting();
                        }
                    } else {
                        uni.showToast({
                            title: '已经是最新版',
                            mask: false,
                            duration: 1500,
                            icon: "none"
                        });
                    }
                })
 
            },
            // 点击登录按钮
            goHome() {
                uni.clearStorageSync()
                let params = {
                    userName: this.phone,
                    password: this.pwd
                }
                login(params).then((res) => {
                    if (res.code == 0) {
                        uni.setStorageSync('admin', this.phone);
                        uni.setStorageSync('pwd', this.pwd);
                        uni.setStorageSync('roleName', res.data[0].roleName);
                        uni.switchTab({
                            //存储好后跳转页面
                            url: "../Home/index",
                        });
                    } else {
                        // this.$u.toast(res.data.msg)
                        this.$u.toast('请输入正确的账号密码')
                    }
                })
            }
        }
    }
</script>
 
<style lang="scss" scoped>
    .logo {
        text-align: center;
 
        image {
            width: 75px;
            height: 70px;
            margin: 0 auto -25px;
        }
    }
 
    .btn {
        border: 1px solid #717171;
        padding: 5px 7px;
        border-radius: 5px;
        color: #717171;
    }
 
    .iconfont {
        color: #ccc;
    }
 
    .loginP {
        padding: 2rem;
        margin-top: 20px;
    }
 
    .mainTitle {
        color: #717171;
        text-align: center;
        font-size: 1.1rem;
        padding: 2rem 2rem 0 2rem;
    }
 
    .classesifyP {
        text-align: center;
        display: flex;
        justify-content: center;
    }
 
    .classesify {
        width: 11rem;
        height: 2.1875rem;
        border: 1px solid #02af74;
        display: flex;
        align-items: center;
        border-radius: 100px;
    }
 
    .classesify-puc {
        width: 50%;
        font-size: 0.6rem;
        border-bottom-left-radius: 100px;
        border-top-left-radius: 100px;
        height: 100%;
        line-height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #02af74;
    }
 
    .classesify-pucs {
        width: 50%;
        font-size: 0.6rem;
        border-bottom-left-radius: 100px;
        border-top-left-radius: 100px;
        height: 100%;
        line-height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: white;
    }
 
    .classesify-bus {
        width: 50%;
    }
 
    .classesify-buss {
        width: 50%;
        font-size: 0.6rem;
        border-bottom-right-radius: 100px;
        border-top-right-radius: 100px;
        height: 100%;
        line-height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #02af74;
    }
 
    .userP {
        display: flex;
        align-items: center;
        margin: 4rem 0rem 1rem 0rem;
        padding: 0.3125rem 0rem;
        border-bottom: 1px solid #dfdfdf;
    }
 
    .pwdP {
        display: flex;
        align-items: center;
        margin: 2rem 0rem 1rem 0rem;
        padding: 0.3125rem 0rem;
        border-bottom: 1px solid #dfdfdf;
    }
 
    .inputC {
        width: 100%;
        padding-left: 1rem;
    }
 
    .rightIcon {
        margin: 0 auto;
    }
 
    .loginBtnP {
        width: 100%;
        display: flex;
        justify-content: center;
    }
 
    .loginBtn {
        width: 14rem;
        padding: 0.5rem;
        background-color: #7abbff;
        border-radius: 0.5rem;
        color: white;
        text-align: center;
        font-size: 1.1rem;
    }
 
    .forgot-register {
        padding: 1rem 0rem;
        display: flex;
        justify-content: space-between;
        color: #747474;
        margin-top: 15px;
    }
 
    .user-pwd {
        margin-bottom: 2rem;
        margin-top: -20px;
    }
</style>