Blame view

App.vue 2.24 KB
c293da23   刘淇   新园林init
1
  <script setup>
a2702f6d   刘淇   巡查计划
2
  import { onLaunch, onShow } from '@dcloudio/uni-app';
c293da23   刘淇   新园林init
3
  
a2702f6d   刘淇   巡查计划
4
  // 应用启动时初始化
c293da23   刘淇   新园林init
5
6
  onLaunch(() => {
    console.log('App Launch');
a2702f6d   刘淇   巡查计划
7
8
    // 清空登录重定向残留(可选)
    uni.removeStorageSync('loginRedirectPath');
c293da23   刘淇   新园林init
9
  });
a2702f6d   刘淇   巡查计划
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
  
  // 监听所有页面显示(核心:检测登录状态)
  onShow(() => {
    checkLoginStatus();
  });
  
  // 登录检测核心函数
  const checkLoginStatus = () => {
    // 1. 获取当前页面信息(避免登录页循环跳转)
    const pages = getCurrentPages();
    if (pages.length === 0) return; // 无页面时跳过
    const currentPage = pages[pages.length - 1];
    const currentPath = currentPage.route; // 当前页面路径(如:pages/plan/index)
  
    // // 2. 白名单:无需登录的页面(登录页必须加,其他按需加)
    // const whiteList = ['pages/login/index', 'pages/register/index']; // 可追加首页等
    // if (whiteList.includes(currentPath)) return;
  
    // 3. 检测登录状态(仅判断token是否存在,极简版)
    const token = uni.getStorageSync('jcss_token'); // 登录成功后需存token
    if (!token) {
      // 记录当前页面(登录后可返回)
      uni.setStorageSync('loginRedirectPath', currentPath);
      // 跳转到登录页(用redirectTo避免返回栈残留)
      uni.redirectTo({
        url: '/pages/login/index'
      });
    }
  };
c293da23   刘淇   新园林init
39
40
41
42
43
44
45
46
47
48
49
  </script>
  
  <style lang="scss">
  /* 注意要写在第一行,注意不能引入至uni.scss,同时给style标签加入lang="scss"属性 */
  @import "@/uni_modules/uview-plus/index.scss";
  
  /* 你的全局样式 */
  page {
    background-color: #f8f8f8;
    height: 100%;
  }
993d98fa   刘淇   工作台
50
  
fb13622a   刘淇   养护计划列表 样式 差去一个卡片的头部
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  // 卡片列表样式
  .common-card-list {
    .common-card-title {
  
    }
  
    .u-body-item {
      margin-bottom: 16rpx;
      &:last-child {
        margin-bottom: 0;
      }
    }
  
    .u-body-value {
      flex: 1
    }
  }
  
  
  // 通用样式
  .common-item-center {
    align-items: center;
  }
  
  .common-justify-between {
    justify-content: space-between;
  }
  
  
993d98fa   刘淇   工作台
80
81
82
83
84
85
86
87
88
89
90
91
92
  // 底部按钮样式
  .fixed-bottom-btn-wrap {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    padding: 0;
    /* #ifdef MP-WEIXIN */
    //padding-bottom: constant(safe-area-inset-bottom);
    //padding-bottom: env(safe-area-inset-bottom);
    /* #endif */
  }
9b30ab8c   刘淇   新增快速工单,原版
93
94
95
96
  .commonPageLRpadding{
    padding-left: 15px;
    padding-right: 15px;
  }
c293da23   刘淇   新园林init
97
  </style>