#
whycq
2023-02-01 149dab1e6cb8af57634d49e5467c467691635cc0
#
2个文件已修改
132 ■■■■ 已修改文件
App.vue 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/login/login.vue 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
App.vue
@@ -84,8 +84,8 @@
            ]
        },
        onShow: function() {
            this.getVersion();
            this.baseUrll = uni.getStorageSync("baseUrl")
            // this.getVersion();
            // this.baseUrll = uni.getStorageSync("baseUrl")
            // console.log(this.baseUrll);
            console.log('App Show')
        },
@@ -177,6 +177,70 @@
                });
                complete: () => {}
            },
            downWgt() {
                let that = this;
                const downloadUrl = "http://192.168.4.188:8088/jfwms/static/appupload/android_debug.apk"
                console.log('url:' + downloadUrl)
                uni.showLoading({
                    title: '更新中……'
                })
                // return
                const downloadTask = uni.downloadFile({ //执行下载
                    url: downloadUrl, //下载地址
                    timeout: 1000 * 30, //30秒超时时间
                    success: downloadResult => { //下载成功
                        console.log(downloadResult);
                        that.showdownLine = false
                        uni.hideLoading();
                        console.log('downloadResult.statusCode' + downloadResult.statusCode)
                        if (downloadResult.statusCode == 200) {
                            console.log('更新中')
                            uni.showModal({
                                title: '',
                                content: '更新成功,确定现在重启吗?',
                                confirmText: '重启',
                                confirmColor: '#EE8F57',
                                success: function(res) {
                                    if (res.confirm == true) {
                                        plus.runtime.install( //安装
                                            downloadResult.tempFilePath, {
                                                force: true
                                            },
                                            function(res) {
                                                utils.showToast('更新成功,重启中');
                                                plus.runtime.restart();
                                            }
                                        );
                                    }
                                }
                            });
                        }
                    },
                    fail: err => {
                        uni.hideLoading();
                        that.showdownLine = false
                        that.$u.toast(err.errMsg)
                        console.log(err)
                    },
                    complete: com => {
                        console.log(com)
                    }
                });
                // 下载进度
                downloadTask.onProgressUpdate(res => {
                    // that.$u.toast(res.progress)
                    that.downloadNum = res.progress
                    console.log('下载进度' + that.downloadNum);
                    // console.log('已经下载的数据长度' + res.totalBytesWritten);
                    // console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
                    // 满足测试条件,取消下载任务。
                    // if (res.progress > 50) {
                    //     downloadTask.abort();
                    // }
                });
            },
        }
    }
</script>
pages/login/login.vue
@@ -202,70 +202,6 @@
            },
        },
        methods: {
            downWgt() {
                let that = this;
                const downloadUrl = "http://192.168.4.188:8088/jfwms/static/appupload/android_debug.apk"
                console.log('url:' + downloadUrl)
                uni.showLoading({
                    title: '更新中……'
                })
                // return
                const downloadTask = uni.downloadFile({ //执行下载
                    url: downloadUrl, //下载地址
                    timeout: 1000 * 30, //30秒超时时间
                    success: downloadResult => { //下载成功
                        console.log(downloadResult);
                        that.showdownLine = false
                        uni.hideLoading();
                        console.log('downloadResult.statusCode' + downloadResult.statusCode)
                        if (downloadResult.statusCode == 200) {
                            console.log('更新中')
                            uni.showModal({
                                title: '',
                                content: '更新成功,确定现在重启吗?',
                                confirmText: '重启',
                                confirmColor: '#EE8F57',
                                success: function(res) {
                                    if (res.confirm == true) {
                                        plus.runtime.install( //安装
                                            downloadResult.tempFilePath, {
                                                force: true
                                            },
                                            function(res) {
                                                utils.showToast('更新成功,重启中');
                                                plus.runtime.restart();
                                            }
                                        );
                                    }
                                }
                            });
                        }
                    },
                    fail: err => {
                        uni.hideLoading();
                        that.showdownLine = false
                        that.$u.toast(err.errMsg)
                        console.log(err)
                    },
                    complete: com => {
                        console.log(com)
                    }
                });
                // 下载进度
                downloadTask.onProgressUpdate(res => {
                    // that.$u.toast(res.progress)
                    that.downloadNum = res.progress
                    console.log('下载进度' + that.downloadNum);
                    // console.log('已经下载的数据长度' + res.totalBytesWritten);
                    // console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
                    // 满足测试条件,取消下载任务。
                    // if (res.progress > 50) {
                    //     downloadTask.abort();
                    // }
                });
            },
            // 配置 URL PORT 项目(jkwms)
            config() {
                this.$refs.popup.open("center")