12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <script>
- import {
- getNewestVersion
- } from '@/api/login.js'
- import {
- validateVersion
- } from "@/utils/validateVersion.js"
- import {
- appInit,
- delMsg
- } from '@/utils/jpush.js'
- export default {
- onLaunch: function() {
- //#ifdef APP-PLUS
- appInit()
- // 检测版本更新
- uni.getSystemInfo({
- success: async (res) => {
- // 获取最新版本
- const newsetVersionRes = await getNewestVersion().catch(() => {
- uni.showModal({
- title: '错误',
- content: '获取最新系统版本失败。'
- })
- })
- let newsetVersion = newsetVersionRes.data.version;
- uni.setStorageSync('visionNow', res.appWgtVersion)
- let higherThanNewest = validateVersion(res.appWgtVersion, newsetVersion)
- // 如果版本低于服务上的最新版
- if (higherThanNewest) {
- //检测是否已登录
- let token = uni.getStorageSync('App-Token');
- if (token) {
- let kind = uni.getStorageSync('userKind')
- // uni.switchTab({
- // url: '/pages/home/companyHome'
- // })
- // uni.switchTab({
- // url: '/pages/home/oversawHome'
- // })
- uni.switchTab({
- url: '/pages/home/headHome'
- })
- }
- }
- },
- fail: () => {
- uni.showModal({
- title: '错误',
- content: '获取当前系统版本失败。'
- })
- }
- })
- //#endif
- },
- onShow: function() {
- // console.log('App Show')
- },
- onHide: function() {
- // console.log('App Hide')
- },
- }
- </script>
- <style lang="scss">
- @import '@/static/scss/index.scss';
- page {
- height: 100%;
- background-color: #F2F7FF;
- }
- </style>
|