xcx 4 anni fa
parent
commit
dcdce35aa8
2 ha cambiato i file con 31 aggiunte e 9 eliminazioni
  1. 17
    7
      src/pages/ShouYe/index.jsx
  2. 14
    2
      src/pages/WuYe/index.jsx

+ 17
- 7
src/pages/ShouYe/index.jsx Vedi File

15
 
15
 
16
   const { user } = useModel('user')
16
   const { user } = useModel('user')
17
   const [OwnerList] = useState([
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
     { icon: 'iconrenzheng', name: '业主认证', id: 4, router: '/pages/WoDe/WoDeRenZheng/index', isTab: false }
21
     { icon: 'iconrenzheng', name: '业主认证', id: 4, router: '/pages/WoDe/WoDeRenZheng/index', isTab: false }
22
   ])
22
   ])
23
   const [NavList] = useState([
23
   const [NavList] = useState([
24
     { icon: 'iconhuodong1', name: '活动', id: 1, router: '/pages/ShouYe/HuoDong/index', isTab: false },
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
     { icon: 'iconxinwen', name: '资讯', id: 4, router: '/pages/ShouYe/ZiXun/index', isTab: false }
27
     { icon: 'iconxinwen', name: '资讯', id: 4, router: '/pages/ShouYe/ZiXun/index', isTab: false }
28
   ])
28
   ])
29
   const [BannerList, setBannerList] = useState([])
29
   const [BannerList, setBannerList] = useState([])
93
   const NavClick = (item) => {
93
   const NavClick = (item) => {
94
     return () => {
94
     return () => {
95
       if (item.isTab) {
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
       } else {
102
       } else {
98
         Taro.navigateTo({ url: item.router })
103
         Taro.navigateTo({ url: item.router })
99
       }
104
       }
107
   const OwnerClick = (item) => {
112
   const OwnerClick = (item) => {
108
     return () => {
113
     return () => {
109
       if (item.isTab) {
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
       } else {
121
       } else {
112
         Taro.navigateTo({ url: item.router })
122
         Taro.navigateTo({ url: item.router })
113
       }
123
       }

+ 14
- 2
src/pages/WuYe/index.jsx Vedi File

1
-import React, { useState } from 'react'
1
+import React, { useState, useEffect } from 'react'
2
 import TabPageCutNav from '@/components/TabPageCutNav/index'
2
 import TabPageCutNav from '@/components/TabPageCutNav/index'
3
 import NavHeader from '@/components/NavHeader/index'
3
 import NavHeader from '@/components/NavHeader/index'
4
 import WuYeGongGao from '@/components/WuYeGongGao/index'
4
 import WuYeGongGao from '@/components/WuYeGongGao/index'
6
 import WuYeBaoXiu from '@/components/WuYeBaoXiu/index'
6
 import WuYeBaoXiu from '@/components/WuYeBaoXiu/index'
7
 import WuYeJiaoFei from '@/components/WuYeJiaoFei/index'
7
 import WuYeJiaoFei from '@/components/WuYeJiaoFei/index'
8
 import Page from '@/layouts'
8
 import Page from '@/layouts'
9
+import Taro from '@tarojs/taro'
9
 import '@/assets/css/reset.less'
10
 import '@/assets/css/reset.less'
10
 import '@/assets/css/iconfont.less'
11
 import '@/assets/css/iconfont.less'
11
 import './index.less'
12
 import './index.less'
13
 export default function WuYe () {
14
 export default function WuYe () {
14
 
15
 
15
   const [NavList] = useState([{ name: '公告', id: 1 }, { name: '服务', id: 2 }, { name: '报修', id: 3 }, { name: '缴费', id: 4 }])
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
   const NavChange = (e) => {
30
   const NavChange = (e) => {
19
     return () => {
31
     return () => {