lanan-app/App.vue

118 lines
2.6 KiB
Vue
Raw Normal View History

2024-08-20 20:02:05 +08:00
<script>
import config from '@/config'
import request from './utils/request';
import {
2024-08-22 20:54:43 +08:00
getToken,
setTenantId
2024-08-20 20:02:05 +08:00
} from '@/utils/auth'
2024-08-22 20:54:43 +08:00
import {
getTenantIdByWebsite
} from '@/api/login.js'
2024-08-20 20:02:05 +08:00
export default {
onLaunch: function() {
/*#ifdef MP*/
return
/*#endif*/
2024-08-22 20:54:43 +08:00
2024-08-20 20:02:05 +08:00
if (!getToken()) {
return
}
let version = config.appInfo.version
request({
url: '/system/config/configKey/rescueUserVersion',
method: 'get',
params: ''
}).then(res => {
console.log('rescueUserVersion', res);
if (res.code == 200 && res.msg && res.msg != version) {
console.log(res);
uni.showModal({
title: '版本升级',
content: '新版本上线了,根据您自己的选择是否升级',
showCancel: true,
confirmText: '升级',
success: res => {
if (res.cancel) return;
let waiting = plus.nativeUI.showWaiting("正在下载 - 0%");
// uni.showLoading({
// title: '安装包下载中'
// });
// wgt 和 安卓下载更新
const downloadTask = uni.downloadFile({
url: 'http://159.75.168.143:88/apk/rescueUser.apk',
success: res => {
if (res.statusCode !== 200) {
console.error('下载安装包失败', err);
return;
}
// 下载好直接安装,下次启动生效
plus.runtime.install(res.tempFilePath, {
force: false
}, () => {
uni.hideLoading()
if (is_mandatory) {
//更新完重启app
plus.runtime.restart();
return;
}
uni.showModal({
title: '安装成功是否重启?',
success: res => {
if (res.confirm) {
//更新完重启app
plus.runtime
.restart();
}
}
});
}, err => {
uni.hideLoading()
uni.showModal({
title: '更新失败',
content: err.message,
showCancel: false
});
});
},
//接口调用结束
complete: () => {
uni.hideLoading();
downloadTask.offProgressUpdate(); //取消监听加载进度
}
});
//监听下载进度
downloadTask.onProgressUpdate(res => {
waiting.setTitle("正在下载 - " + res.progress + "%");
});
}
});
}
})
},
onShow: function() {
console.log('2')
},
onHide: function() {
console.log('3')
}
}
</script>
<style lang="scss">
@import "@/node_modules/uview-ui/index.scss";
2024-08-22 19:35:07 +08:00
page,
uni-page-body,
html,
body {
height: 100%;
}
2024-08-22 20:54:43 +08:00
</style>