张延森 пре 3 година
родитељ
комит
649994cda3

+ 15
- 0
src/components/PageLoading/index.jsx Прегледај датотеку

@@ -0,0 +1,15 @@
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 Прегледај датотеку

@@ -0,0 +1,14 @@
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 Прегледај датотеку

@@ -4,8 +4,8 @@ import { useModel } from '@/store'
4 4
 export default function withBasic (Comp, Loading) {
5 5
   return (props) => {
6 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 Прегледај датотеку

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

+ 1
- 0
src/pages/index/index.config.js Прегледај датотеку

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

+ 45
- 33
src/pages/index/index.jsx Прегледај датотеку

@@ -3,8 +3,10 @@ import { View, ScrollView, Text } from '@tarojs/components'
3 3
 import Taro from '@tarojs/taro'
4 4
 import Banner from '@/components/Banner'
5 5
 import Notice from '@/components/Notice'
6
+import PageLoading from '@/components/PageLoading'
6 7
 import { useModel } from '@/store'
7 8
 import { getApplicationList } from '@/services/dogAPI'
9
+import withBasic from '@/layouts/withBasic'
8 10
 import MenuItem from './components/MenuItem'
9 11
 
10 12
 import './style.less'
@@ -17,8 +19,7 @@ const ml16 = {
17 19
   marginLeft: '16px'
18 20
 }
19 21
 
20
-export default (props) => {
21
-
22
+const IndexPage = (props) => {
22 23
   const { pets, cards } = useModel('userData')
23 24
   const [totalApplyNum, setTotalApplyNum] = useState(0)
24 25
 
@@ -34,16 +35,6 @@ export default (props) => {
34 35
     { text: '我是第3165656565' },
35 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 39
   const goNoticeList=()=>{
49 40
     Taro.navigateTo({url:'/pages/noticeList/index'})
@@ -51,14 +42,7 @@ export default (props) => {
51 42
   const goDetail=()=>{
52 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 46
   return (
63 47
     <ScrollView scrollY style={{
64 48
       height: '100vh'
@@ -70,26 +54,56 @@ export default (props) => {
70 54
         </View>
71 55
         <View className='border-card-group'>
72 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 64
                 <View>您有<Text>{ totalApplyNum }</Text>条办证申请记录</View>
76 65
               </MenuItem>
77 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 74
                 <View>您有<Text>{ cards ? cards.length : 0 }</Text>条办证申请记录</View>
81 75
               </MenuItem>
82 76
             </View>
83 77
           </View>
84 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 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 107
               </View>
94 108
             </View>
95 109
           </View>
@@ -103,6 +117,4 @@ export default (props) => {
103 117
   )
104 118
 }
105 119
 
106
-
107
-
108
-
120
+export default withBasic(IndexPage, PageLoading)