yyb
2 天以前 0c04de484a2a2bebbd08a06a604c3cdbb7b9cb47
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
<script>
    import config from '@/common/config.js';
    export default {
        onLaunch() {
            // #ifdef APP-PLUS
            // 检测升级
            // let appid = plus.runtime.appid;
            // let version = plus.runtime.version;
            // uni.showToast({
            //     title:plus.runtime.version
            // })
            /*uni.request({
                url: 'https://www.pgyer.com/apiv2/app/check', //检查更新的服务器地址(蒲公英)
                data: {
                    _api_key: config._api_key,
                    appKey: config.appKey,
                    buildVersion: plus.runtime.version
                },
                success: (res) => {
                    // uni.showToast({
                    //     title: JSON.stringify(res.data.data.downloadURL)
                    // })
                    if (res.data.code == 0 && res.data.data.buildHaveNewVersion) {
                        // let openUrl = plus.os.name === 'iOS' ? res.data.iOS : res.data.Android;
                        let openUrl = res.data.data.downloadURL;
                        // 提醒用户更新
                        uni.showModal({
                            title: '更新提示',
                            confirmText:'更新',
                            content: res.data.buildUpdateDescription ? res.data.buildUpdateDescription : '是否选择更新?',
                            success: (showResult) => {
                                if (showResult.confirm) {
                                    if (uni.getSystemInfoSync().platform == "android") {
                                        uni.showToast({
                                            title: '正在后台进行下载...',  
                                            icon:'none',
                                            mask: false,
                                            duration: 1500  
                                        });  
                                        var dtask = plus.downloader.createDownload( openUrl, {}, function ( d, status ) {  
                                            // 下载完成  
                                            if ( status == 200 ) {   
                                                plus.runtime.install(plus.io.convertLocalFileSystemURL(d.filename),{},{},function(error){  
                                                    uni.showToast({  
                                                        title: '安装失败',  
                                                        icon:'none',
                                                        mask: false,  
                                                        duration: 1500  
                                                    });  
                                                })  
                                            } else {  
                                                 uni.showToast({  
                                                    title: '更新失败', 
                                                    icon:'none',
                                                    mask: false,  
                                                    duration: 1500  
                                                 });  
                                            }    
                                        });  
                                        dtask.start();  
                                    } else {
                                        plus.runtime.openURL(openUrl);
                                    }
                                }
                            }
                        })
                    }
                }
            })*/
            // #endif
        }
    }
</script>
<style>
    @import url("@/static/iconfont/iconfont.css");
</style>
<style lang="scss">
    @import "uview-ui/index.scss";
    @import "pages/common/common.scss";
</style>