소스 검색

静态页面

xcx 4 년 전
부모
커밋
dcdce35aa8
2개의 변경된 파일31개의 추가작업 그리고 9개의 파일을 삭제
  1. 17
    7
      src/pages/ShouYe/index.jsx
  2. 14
    2
      src/pages/WuYe/index.jsx

+ 17
- 7
src/pages/ShouYe/index.jsx 파일 보기

@@ -15,15 +15,15 @@ export default function Index (props) {
15 15
 
16 16
   const { user } = useModel('user')
17 17
   const [OwnerList] = useState([
18
-    { icon: 'iconjiaofei', name: '物业缴费', id: 1, router: '/pages/WuYe/index', isTab: true },
19
-    { icon: 'icontongzhi', name: '物业通知', id: 2, router: '/pages/WuYe/index', isTab: true },
20
-    { icon: 'iconbaoxiu', name: '物业报修', id: 3, router: '/pages/WuYe/index', isTab: true },
18
+    { icon: 'iconjiaofei', name: '物业缴费', id: 1, router: '/pages/WuYe/index', setName: 'WuYeNavId', setValue: '4', isTab: true },
19
+    { icon: 'icontongzhi', name: '物业通知', id: 2, router: '/pages/WuYe/index', setName: 'WuYeNavId', setValue: '1', isTab: true },
20
+    { icon: 'iconbaoxiu', name: '物业报修', id: 3, router: '/pages/WuYe/index', setName: 'WuYeNavId', setValue: '3', isTab: true },
21 21
     { icon: 'iconrenzheng', name: '业主认证', id: 4, router: '/pages/WoDe/WoDeRenZheng/index', isTab: false }
22 22
   ])
23 23
   const [NavList] = useState([
24 24
     { icon: 'iconhuodong1', name: '活动', id: 1, router: '/pages/ShouYe/HuoDong/index', isTab: false },
25
-    { icon: 'iconfuli', name: '福利', id: 2, router: '/pages/FuLi/index', isTab: true },
26
-    { icon: 'iconfuwu', name: '服务', id: 3, router: '/pages/WuYe/index', isTab: true },
25
+    { icon: 'iconfuli', name: '福利', id: 2, router: '/pages/FuLi/index', setName: null, setValue: null, isTab: true },
26
+    { icon: 'iconfuwu', name: '服务', id: 3, router: '/pages/WuYe/index', setName: 'WuYeNavId', setValue: '2', isTab: true },
27 27
     { icon: 'iconxinwen', name: '资讯', id: 4, router: '/pages/ShouYe/ZiXun/index', isTab: false }
28 28
   ])
29 29
   const [BannerList, setBannerList] = useState([])
@@ -93,7 +93,12 @@ export default function Index (props) {
93 93
   const NavClick = (item) => {
94 94
     return () => {
95 95
       if (item.isTab) {
96
-        Taro.switchTab({ url: item.router })
96
+        if (item.setName !== null) {
97
+          Taro.setStorageSync(item.setName, item.setValue)
98
+          Taro.reLaunch({ url: item.router })
99
+        } else {
100
+          Taro.switchTab({ url: item.router })
101
+        }
97 102
       } else {
98 103
         Taro.navigateTo({ url: item.router })
99 104
       }
@@ -107,7 +112,12 @@ export default function Index (props) {
107 112
   const OwnerClick = (item) => {
108 113
     return () => {
109 114
       if (item.isTab) {
110
-        Taro.switchTab({ url: item.router })
115
+        if (item.setName !== null) {
116
+          Taro.setStorageSync(item.setName, item.setValue)
117
+          Taro.reLaunch({ url: item.router })
118
+        } else {
119
+          Taro.switchTab({ url: item.router })
120
+        }
111 121
       } else {
112 122
         Taro.navigateTo({ url: item.router })
113 123
       }

+ 14
- 2
src/pages/WuYe/index.jsx 파일 보기

@@ -1,4 +1,4 @@
1
-import React, { useState } from 'react'
1
+import React, { useState, useEffect } from 'react'
2 2
 import TabPageCutNav from '@/components/TabPageCutNav/index'
3 3
 import NavHeader from '@/components/NavHeader/index'
4 4
 import WuYeGongGao from '@/components/WuYeGongGao/index'
@@ -6,6 +6,7 @@ import WuYeFuWu from '@/components/WuYeFuWu/index'
6 6
 import WuYeBaoXiu from '@/components/WuYeBaoXiu/index'
7 7
 import WuYeJiaoFei from '@/components/WuYeJiaoFei/index'
8 8
 import Page from '@/layouts'
9
+import Taro from '@tarojs/taro'
9 10
 import '@/assets/css/reset.less'
10 11
 import '@/assets/css/iconfont.less'
11 12
 import './index.less'
@@ -13,7 +14,18 @@ import './index.less'
13 14
 export default function WuYe () {
14 15
 
15 16
   const [NavList] = useState([{ name: '公告', id: 1 }, { name: '服务', id: 2 }, { name: '报修', id: 3 }, { name: '缴费', id: 4 }])
16
-  const [CurrentNavId, setCurrentNavId] = useState(1)
17
+  const [CurrentNavId, setCurrentNavId] = useState(null)
18
+
19
+  useEffect(() => {
20
+    if (CurrentNavId === null) {
21
+      console.log(Taro.getStorageSync('WuYeNavId'), `111`)
22
+      if (Taro.getStorageSync('WuYeNavId')) {
23
+        setCurrentNavId(Taro.getStorageSync('WuYeNavId') - 0)
24
+      } else {
25
+        setCurrentNavId(1)
26
+      }
27
+    }
28
+  }, [CurrentNavId])
17 29
 
18 30
   const NavChange = (e) => {
19 31
     return () => {