12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <script>
- import config from './config'
- import {
- getToken
- } from '@/utils/auth'
- export default {
- onLaunch: function() {
- this.initApp();
- },
- onShow() {},
- methods: {
- // 初始化应用
- initApp() {
- console.log('初始化应用开始~')
- // 是否有版本更新
- this.isUpdate()
- // 初始化应用配置
- this.initConfig()
- // 免登录
- this.checkLogin()
- },
- initConfig() {
- this.globalData.config = config
- },
- async checkLogin() {
- console.log('检测是否登录开始!')
- if (getToken() && uni.getStorageSync('sysId')) {
- console.log('已登录!')
- await this.$store.dispatch('GetPermis')
- //判断用户是否有任一菜单权限
- if (this.$store.state.permission.permissions_menu && this.$store.state.permission
- .permissions_menu != '[]') {
- // 开发模式下取消免登录,直接跳转调试页面,生产免登录跳转主页
- if (process.env.NODE_ENV == 'production') {
- this.$tab.reLaunch('/pages/globalPages/home')
- }
- } else {
- this.$modal.msg('该用户无权限~')
- }
- } else {
- console.log('未登录!')
- }
- },
- isUpdate() {
- console.log('检测更新开始~')
- const updateManager = wx.getUpdateManager()
- updateManager.onCheckForUpdate(function(res) {
- // 请求完新版本信息的回调
- console.log(res.hasUpdate)
- })
- updateManager.onUpdateReady(function() {
- wx.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate()
- }
- }
- })
- })
- updateManager.onUpdateFailed(function() {
- // 新版本下载失败
- })
- }
- }
- }
- </script>
- <style lang="scss">
- @import "@/uni_modules/uview-ui/index.scss";
- @import '@/static/scss/index.scss'
- </style>
|