2024-10-09 13:34:36 +08:00
|
|
|
|
<script>
|
2025-08-11 17:42:50 +08:00
|
|
|
|
import config from '@/config'
|
|
|
|
|
import request from '@/utils/request';
|
2025-08-12 18:52:12 +08:00
|
|
|
|
import store from '@/store'
|
2024-10-09 13:34:36 +08:00
|
|
|
|
export default {
|
|
|
|
|
onLaunch: function() {
|
2024-10-31 19:05:38 +08:00
|
|
|
|
console.log('app lunch');
|
2025-08-11 17:42:50 +08:00
|
|
|
|
let version = config.appInfo.version
|
|
|
|
|
request({
|
|
|
|
|
url: '/admin-api/system/config/configKey/repairVersion',
|
|
|
|
|
method: 'get',
|
|
|
|
|
params: ''
|
|
|
|
|
}).then(res => {
|
|
|
|
|
console.log(res, 1444);
|
|
|
|
|
if (res.code == 200 && res.data && res.data != version) {
|
|
|
|
|
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/repairWorker.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 => {
|
|
|
|
|
// state.percent = res.progress;
|
|
|
|
|
waiting.setTitle("正在下载 - " + res.progress + "%");
|
|
|
|
|
// console.log('下载进度百分比:' + res.progress); // 下载进度百分比
|
|
|
|
|
// console.log('已经下载的数据长度:' + res.totalBytesWritten); // 已经下载的数据长度,单位 Bytes
|
|
|
|
|
// console.log('预期需要下载的数据总长度:' + res.totalBytesExpectedToWrite); // 预期需要下载的数据总长度,单位 Bytes
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-08-12 18:52:12 +08:00
|
|
|
|
// 判断本地是否有 token,有的话就去获取权限
|
|
|
|
|
if (store.state.user.token) {
|
|
|
|
|
store.dispatch('GetInfo').catch(err => {
|
|
|
|
|
console.error('获取用户信息失败', err)
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-09-30 09:37:26 +08:00
|
|
|
|
|
|
|
|
|
// #ifdef APP-PLUS
|
|
|
|
|
plus.screen.lockOrientation('portrait-primary'); //锁死屏幕方向为竖屏
|
|
|
|
|
plus.navigator.setFullscreen(false);
|
|
|
|
|
// #endif
|
2025-08-11 17:42:50 +08:00
|
|
|
|
},
|
2024-10-09 13:34:36 +08:00
|
|
|
|
onShow: function() {
|
|
|
|
|
console.log('App Show')
|
|
|
|
|
},
|
|
|
|
|
onHide: function() {
|
|
|
|
|
console.log('App Hide')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
|
2025-08-11 17:42:50 +08:00
|
|
|
|
@import "@/uni_modules/uview-ui/index.scss";
|
2024-10-09 13:34:36 +08:00
|
|
|
|
</style>
|
|
|
|
|
<style>
|
|
|
|
|
/*每个页面公共css */
|
|
|
|
|
page,
|
|
|
|
|
uni-page-body,
|
|
|
|
|
html,
|
|
|
|
|
body {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
2024-10-13 23:24:23 +08:00
|
|
|
|
|
2025-08-11 17:42:50 +08:00
|
|
|
|
* {
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.image-view-img {
|
|
|
|
|
background: white;
|
|
|
|
|
}
|
|
|
|
|
</style>
|