| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <script setup>
- import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
- import {
- store
- } from '@/store/index.js'
- import { useGlobalEventRemove, useInit } from '@/utils/useBarcodeModule.js'
- import { useRouteMonitor } from '@/utils/useRouteMonitor.js'
- onLaunch(() => {
- console.log('App Launch')
- // 尝试去获取本地的 token 和用户信息,填充到 store 中
- if (!store.token) {
- let token = uni.getStorageSync('token')
- if (token) {
- store.setToken(token)
- let userInfo = uni.getStorageSync('userInfo')
- if (userInfo) {
- if (userInfo.userId) {
- store.setUserInfo(userInfo)
- }
- }
- }
- }
- // #ifdef APP-PLUS
- // 初始化扫码模块
- useInit()
- // #endif
- })
- onShow(() => {
- console.log('App Show');
- // #ifdef APP-PLUS
- // 页面显示时重新添加全局监听
- useRouteMonitor((url, from) => {
- console.log('onShow', url, from)
- // #ifdef APP-PLUS
- // 页面隐藏时移除全局监听
- useGlobalEventRemove()
- // #endif
- })
- // #endif
- })
- onHide(() => {
- console.log('App Hide');
- })
- </script>
- <style lang="scss">
- @import "@/uni_modules/uview-plus/index.scss";
- @import "@/static/css/mystyle.css";
- @import '@/static/css/common.scss';
- /*每个页面公共css */
- page {
- background: #F5F6FA;
- height: 100%;
- }
- </style>
|