张延森 3 years ago
parent
commit
649994cda3

+ 15
- 0
src/components/PageLoading/index.jsx View File

1
+
2
+import Taro from '@tarojs/taro';
3
+import { View } from '@tarojs/components'
4
+
5
+import './style.less'
6
+
7
+export default function (props) {
8
+  const { tips } = props
9
+
10
+  return (
11
+    <View className="page-loading">
12
+      <mp-loading extClass="page-loading-circle" type="circle" tips={tips} show />
13
+    </View>
14
+  )
15
+}

+ 14
- 0
src/components/PageLoading/style.less View File

1
+
2
+.page-loading {
3
+  display: flex;
4
+  justify-content: center;
5
+  align-items: center;
6
+  height: 80vh;
7
+
8
+  .page-loading-circle {
9
+    .weui-loading {
10
+      width: 96rpx;
11
+      height: 96rpx;
12
+    }
13
+  }
14
+}

+ 2
- 2
src/layouts/withBasic.jsx View File

4
 export default function withBasic (Comp, Loading) {
4
 export default function withBasic (Comp, Loading) {
5
   return (props) => {
5
   return (props) => {
6
     const { person } = useModel('userData')
6
     const { person } = useModel('userData')
7
-    const loading = person && person.personId
7
+    const loading = !person || !person.personId
8
 
8
 
9
-    return loading ? <Loading /> : <Comp>
9
+    return loading ? <Loading /> : <Comp />
10
   }
10
   }
11
 }
11
 }

+ 9
- 2
src/pages/index/components/MenuItem/index.jsx View File

1
 import React, { useMemo } from 'react'
1
 import React, { useMemo } from 'react'
2
+import Taro from '@tarojs/taro'
2
 import { View, Image } from '@tarojs/components'
3
 import { View, Image } from '@tarojs/components'
3
 import RatioItem from '@/components/RatioItem'
4
 import RatioItem from '@/components/RatioItem'
4
 import certificate from '@/assets/certificate.png'
5
 import certificate from '@/assets/certificate.png'
17
 }
18
 }
18
 
19
 
19
 export default (props) => {
20
 export default (props) => {
20
-  const { title, subtitle, icon, ratio = '470:310', iconSize = 100 } = props;
21
+  const { to, title, subtitle, icon, ratio = '470:310', iconSize = 100 } = props;
21
 
22
 
22
   const iconImage = useMemo(() => images[icon], [icon])
23
   const iconImage = useMemo(() => images[icon], [icon])
23
   const iconStyle = useMemo(() => ({
24
   const iconStyle = useMemo(() => ({
25
     height: `${iconSize}rpx`,
26
     height: `${iconSize}rpx`,
26
   }), [iconSize])
27
   }), [iconSize])
27
 
28
 
29
+  const handleClick = () => {
30
+    if (to) {
31
+      Taro.navigateTo({ url: to })
32
+    }
33
+  }
34
+
28
   return (
35
   return (
29
     <RatioItem ratio={ratio}>
36
     <RatioItem ratio={ratio}>
30
-      <View className='index-menu-item'>
37
+      <View className='index-menu-item' onClick={handleClick}>
31
         <View className='index-menu-item-title'>{title}</View>
38
         <View className='index-menu-item-title'>{title}</View>
32
         <View className='index-menu-item-subtitle'>{subtitle}</View>
39
         <View className='index-menu-item-subtitle'>{subtitle}</View>
33
         <View className='index-menu-item-desc'>
40
         <View className='index-menu-item-desc'>

+ 1
- 0
src/pages/index/index.config.js View File

5
   navigationBarTextStyle: "black",
5
   navigationBarTextStyle: "black",
6
   backgroundColor: "#FBD804",
6
   backgroundColor: "#FBD804",
7
   usingComponents: {
7
   usingComponents: {
8
+    "mp-loading": "weui-miniprogram/loading/loading"
8
   }
9
   }
9
 }
10
 }

+ 45
- 33
src/pages/index/index.jsx View File

3
 import Taro from '@tarojs/taro'
3
 import Taro from '@tarojs/taro'
4
 import Banner from '@/components/Banner'
4
 import Banner from '@/components/Banner'
5
 import Notice from '@/components/Notice'
5
 import Notice from '@/components/Notice'
6
+import PageLoading from '@/components/PageLoading'
6
 import { useModel } from '@/store'
7
 import { useModel } from '@/store'
7
 import { getApplicationList } from '@/services/dogAPI'
8
 import { getApplicationList } from '@/services/dogAPI'
9
+import withBasic from '@/layouts/withBasic'
8
 import MenuItem from './components/MenuItem'
10
 import MenuItem from './components/MenuItem'
9
 
11
 
10
 import './style.less'
12
 import './style.less'
17
   marginLeft: '16px'
19
   marginLeft: '16px'
18
 }
20
 }
19
 
21
 
20
-export default (props) => {
21
-
22
+const IndexPage = (props) => {
22
   const { pets, cards } = useModel('userData')
23
   const { pets, cards } = useModel('userData')
23
   const [totalApplyNum, setTotalApplyNum] = useState(0)
24
   const [totalApplyNum, setTotalApplyNum] = useState(0)
24
 
25
 
34
     { text: '我是第3165656565' },
35
     { text: '我是第3165656565' },
35
     { text: '我是第四条通知啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊' }
36
     { text: '我是第四条通知啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊' }
36
   ]
37
   ]
37
-  const goDogLicense = (e) => {
38
-    Taro.navigateTo({
39
-      url: '/pages/setDogLicense/index'
40
-    })
41
-  }
42
-  const goMain = (e) => {
43
-    Taro.navigateTo({
44
-      url: '/pages/main/index'
45
-    })
46
-  }
47
   
38
   
48
   const goNoticeList=()=>{
39
   const goNoticeList=()=>{
49
     Taro.navigateTo({url:'/pages/noticeList/index'})
40
     Taro.navigateTo({url:'/pages/noticeList/index'})
51
   const goDetail=()=>{
42
   const goDetail=()=>{
52
     Taro.navigateTo({url:'/pages/noticeInfo/index'})
43
     Taro.navigateTo({url:'/pages/noticeInfo/index'})
53
   }
44
   }
54
-  const goDogLicenseList = (e) => {
55
-    // Taro.navigateTo({
56
-    //   url: '/pages/dogLicenseList/index'
57
-    // })
58
-    Taro.navigateTo({
59
-      url: '/pages/dogCardDetail/index'
60
-    })
61
-  }
45
+
62
   return (
46
   return (
63
     <ScrollView scrollY style={{
47
     <ScrollView scrollY style={{
64
       height: '100vh'
48
       height: '100vh'
70
         </View>
54
         </View>
71
         <View className='border-card-group'>
55
         <View className='border-card-group'>
72
           <View class='weui-flex'>
56
           <View class='weui-flex'>
73
-            <View class='weui-flex__item' onClick={goDogLicense}>
74
-              <MenuItem title='办证申请' subtitle='Registration application' icon='dog'>
57
+            <View class='weui-flex__item'>
58
+              <MenuItem
59
+                icon='dog'
60
+                title='办证申请'
61
+                subtitle='Registration application'
62
+                to='/pages/setDogLicense/index?type=first'
63
+              >
75
                 <View>您有<Text>{ totalApplyNum }</Text>条办证申请记录</View>
64
                 <View>您有<Text>{ totalApplyNum }</Text>条办证申请记录</View>
76
               </MenuItem>
65
               </MenuItem>
77
             </View>
66
             </View>
78
-            <View class='weui-flex__item' style={ml16} onClick={goDogLicenseList}>
79
-              <MenuItem title='证件查看' subtitle='Certificate check' icon='certificate'>
67
+            <View class='weui-flex__item' style={ml16}>
68
+              <MenuItem
69
+                title='证件查看'
70
+                subtitle='Certificate check'
71
+                icon='certificate'
72
+                to='/pages/dogLicenseList/index'
73
+              >
80
                 <View>您有<Text>{ cards ? cards.length : 0 }</Text>条办证申请记录</View>
74
                 <View>您有<Text>{ cards ? cards.length : 0 }</Text>条办证申请记录</View>
81
               </MenuItem>
75
               </MenuItem>
82
             </View>
76
             </View>
83
           </View>
77
           </View>
84
           <View class='weui-flex' style={pt16}>
78
           <View class='weui-flex' style={pt16}>
85
-            <View class='weui-flex__item' onClick={goMain}>
86
-              <MenuItem title='个人中心' subtitle='Personal center' ratio='470:452' icon='personal' />
79
+            <View class='weui-flex__item'>
80
+              <MenuItem
81
+                title='个人中心'
82
+                subtitle='Personal center'
83
+                ratio='470:452'
84
+                icon='personal'
85
+                to='/pages/main/index'
86
+              />
87
             </View>
87
             </View>
88
-            <View class='weui-flex__item' style={ml16} onClick={goDogLicense}>
89
-              <MenuItem title='证件续期' subtitle='Certificate renewal' ratio='470:206' icon='renewal' iconSize={72} />
88
+            <View class='weui-flex__item' style={ml16}>
89
+              <MenuItem
90
+                title='证件续期'
91
+                subtitle='Certificate renewal'
92
+                ratio='470:206'
93
+                icon='renewal'
94
+                iconSize={72}
95
+                to='/pages/setDogLicense/index?type=renewal'
96
+              />
90
 
97
 
91
-              <View style={pt16} onClick={goDogLicense}>
92
-                <MenuItem title='证件补办' subtitle='Replacement certificate' ratio='470:206' icon='replacement' iconSize={72} />
98
+              <View style={pt16}>
99
+                <MenuItem
100
+                  title='证件补办'
101
+                  subtitle='Replacement certificate'
102
+                  ratio='470:206'
103
+                  icon='replacement'
104
+                  iconSize={72}
105
+                  to='/pages/setDogLicense/index?type=reissue'
106
+                />
93
               </View>
107
               </View>
94
             </View>
108
             </View>
95
           </View>
109
           </View>
103
   )
117
   )
104
 }
118
 }
105
 
119
 
106
-
107
-
108
-
120
+export default withBasic(IndexPage, PageLoading)