张延森 3 лет назад
Родитель
Сommit
d87cd28305

+ 3
- 20
src/app.config.js Просмотреть файл

@@ -1,24 +1,7 @@
1
+import { pages } from './routes'
2
+
1 3
 export default {
2
-  pages: [
3
-    'pages/index/index',
4
-    'pages/test/index',
5
-    'pages/search/search',
6
-    'pages/searchResult/searchResult',
7
-    'pages/details/foodDetails/foodDetails',
8
-    'pages/details/mjDetails/sceneryDetails',
9
-    'pages/login/login',
10
-    'pages/spread/spreadIndex',
11
-    'pages/landlord/landlord',
12
-    'pages/PayOrder/index',
13
-    'pages/MineUserAll/ContactMe/index',
14
-    'pages/MineUserAll/HomeLogo/index',
15
-    'pages/MineUserAll/Collect/index',
16
-    'pages/MineUserAll/Rules/index',
17
-    'pages/MineUserAll/RefundMoney/index',
18
-    'pages/MineUserAll/RefundMoney/CheckRefund/index',
19
-    'pages/MineUserAll/AllOrder/index',//我的订单
20
-    'pages/TobeShop/index',
21
-  ],
4
+  pages,
22 5
   window: {
23 6
     backgroundTextStyle: 'light',
24 7
     navigationBarBackgroundColor: '#fff',

+ 2
- 0
src/app.js Просмотреть файл

@@ -11,6 +11,8 @@ class App extends Component {
11 11
 
12 12
     // 预拉取数据
13 13
     preFetchData().then((fetchData) => {
14
+      console.log('----fetchData--->', new Date())
15
+
14 16
       setPerson({
15 17
         personId: fetchData.personId,
16 18
         openid: fetchData.openid,

+ 0
- 7
src/layouts/Demo1.jsx Просмотреть файл

@@ -1,7 +0,0 @@
1
-import React from 'react'
2
-
3
-export default (props) => {
4
-  return (
5
-    <view>demo1</view>
6
-  )
7
-}

+ 0
- 7
src/layouts/Demo2.jsx Просмотреть файл

@@ -1,7 +0,0 @@
1
-import React from 'react'
2
-
3
-export default (props) => {
4
-  return (
5
-    <view>demo2</view>
6
-  )
7
-}

+ 6
- 28
src/layouts/index.jsx Просмотреть файл

@@ -1,31 +1,9 @@
1
-import React, { Suspense, useState } from 'react'
2
-import tabList from './tabbar'
3
-import './style.less'
1
+import { useModel } from '@/store'
2
+import useRouter from '@/utils/hooks/useRouter'
4 3
 
5
-const Demo1 = React.lazy(() => import('./Demo1'))
6
-const Demo2 = React.lazy(() => import('./Demo2'))
4
+export default (Child) => (props) => {
5
+  const [person] = useModel('person')
6
+  const router = useRouter()
7 7
 
8
-export default (props) => {
9
-  const [currentTab, setCurrentTab] = useState(1)
10
-
11
-  const handleTabChange = (e) => {
12
-    const { item } = e.detail
13
-    setCurrentTab(item.id)
14
-  }
15
-
16
-  const Comp = currentTab === 1 ? Demo1 : Demo2
17
-
18
-  return (
19
-    <Suspense fallback='loading...'>
20
-      <view className='main-layout'>
21
-        <view className='main-navbar'></view>
22
-        <view className='main-container'>
23
-          <Comp />  
24
-        </view>
25
-        <view className='main-tabbar'>
26
-          <mp-tabbar list={tabList} onChange={handleTabChange}></mp-tabbar>
27
-        </view>
28
-      </view>
29
-    </Suspense>
30
-  )
8
+  return <Child {...props} person={person} router={router} />
31 9
 }

+ 0
- 4
src/pages/MineUserAll/HomeLogo/index.config.js Просмотреть файл

@@ -1,4 +0,0 @@
1
-export default {
2
-  navigationBarTitleText: '入住指引',
3
-  navigationStyle: 'custom',
4
-}

+ 0
- 11
src/pages/MineUserAll/HomeLogo/index.jsx Просмотреть файл

@@ -1,11 +0,0 @@
1
-
2
-import CustomNav from '@/components/CustomNav'
3
-import './style.less'
4
-
5
-export default (props) => {
6
-  return (
7
-    <view className='box-content'>
8
-      <CustomNav title='入住指引' />
9
-    </view>
10
-  )
11
-}

+ 0
- 2
src/pages/MineUserAll/HomeLogo/style.less Просмотреть файл

@@ -1,2 +0,0 @@
1
-.box-content {
2
-}

+ 3
- 2
src/pages/index/index.jsx Просмотреть файл

@@ -3,6 +3,7 @@ import { useRouter } from '@tarojs/taro'
3 3
 import CustomNav from '@/components/CustomNav'
4 4
 import { useModel } from '@/store'
5 5
 import logo from '@/assets/icons/comm/logo_small.png'
6
+import withLayout from '@/layouts'
6 7
 import tabList from './tabbar'
7 8
 import './index.less'
8 9
 import Guide from './tabs/Guide'
@@ -16,7 +17,7 @@ import Recommend from './tabs/Recommend'
16 17
 // const Mine =  import'./tabs/Mine'
17 18
 
18 19
 
19
-export default (props) => {
20
+export default withLayout((props) => {
20 21
   const { params } = useRouter()
21 22
   const { tab } = params || {}
22 23
 
@@ -53,4 +54,4 @@ export default (props) => {
53 54
 
54 55
   )
55 56
 
56
-}
57
+})

+ 91
- 0
src/routes.js Просмотреть файл

@@ -0,0 +1,91 @@
1
+
2
+const routes = [
3
+  {
4
+    title: '首页',
5
+    roles: ['person'],
6
+    page: 'pages/index/index',
7
+  },
8
+  {
9
+    title: '搜索',
10
+    roles: ['person'],
11
+    page: 'pages/search/search',
12
+  },
13
+  {
14
+    title: '搜索结果',
15
+    roles: ['person'],
16
+    page: 'pages/searchResult/searchResult',
17
+  },
18
+  {
19
+    title: '商铺详情',
20
+    roles: ['person'],
21
+    page: 'pages/details/foodDetails/foodDetails',
22
+  },
23
+  {
24
+    title: '景点详情',
25
+    roles: ['person'],
26
+    page: 'pages/details/mjDetails/sceneryDetails',
27
+  },
28
+  {
29
+    title: '民宿管理',
30
+    roles: ['hotel'],
31
+    page: 'pages/landlord/landlord',
32
+  },
33
+  {
34
+    title: '商铺管理',
35
+    roles: ['shop'],
36
+    page: 'pages/spread/spreadIndex',
37
+  },
38
+  {
39
+    title: '订单',
40
+    roles: ['person'],
41
+    page: 'pages/PayOrder/index',
42
+  },
43
+  {
44
+    title: '联系我们',
45
+    roles: ['person'],
46
+    page: 'pages/MineUserAll/ContactMe/index',
47
+  },
48
+  {
49
+    title: '我的收藏',
50
+    roles: ['person'],
51
+    page: 'pages/MineUserAll/Collect/index',
52
+  },
53
+  {
54
+    title: '协议声明',
55
+    roles: ['person'],
56
+    page: 'pages/MineUserAll/Rules/index',
57
+  },
58
+  {
59
+    title: '退款申请',
60
+    roles: ['person'],
61
+    page: 'pages/MineUserAll/RefundMoney/index',
62
+  },
63
+  {
64
+    title: '确认退款',
65
+    roles: ['person'],
66
+    page: 'pages/MineUserAll/RefundMoney/CheckRefund/index',
67
+  },
68
+  {
69
+    title: '我的订单',
70
+    roles: ['person'],
71
+    page: 'pages/MineUserAll/AllOrder/index',
72
+  },
73
+  {
74
+    title: '套餐核销',
75
+    roles: ['person'],
76
+    page: 'pages/TobeShop/index',
77
+  },
78
+];
79
+
80
+const pages = routes.map(x => x.page);
81
+
82
+function getPage(role) {
83
+  return routes.filter(x => x.roles.includes(role))
84
+                .map(x => x.page);
85
+}
86
+
87
+module.exports = {
88
+  routes,
89
+  pages,
90
+  getPage
91
+}