李志伟 vor 3 Jahren
Ursprung
Commit
cf510c6099

+ 34
- 22
src/app.js Datei anzeigen

@@ -1,29 +1,45 @@
1
-import { Component } from 'react'
2
-import Taro from '@tarojs/taro'
1
+import { Component } from "react";
2
+import Taro from "@tarojs/taro";
3 3
 // import preFetchData from '@/utils/preFetchData'
4
-import store, { StoreRoot } from './store'
5
-import './app.less'
4
+// import { useModel } from "@/store";
5
+import store, { StoreRoot } from "./store";
6
+import "./app.less";
6 7
 
7 8
 class App extends Component {
8
-
9 9
   // componentDidShow(options) {
10 10
   //   if (options.path === 'pages/index/index' && options.query?.tab === '1') {
11 11
   //   }
12 12
   // }
13 13
 
14 14
   onLaunch(options) {
15
-    console.group('APP Launch')
16
-    console.debug(options)
17
-    console.groupEnd()
18
-    
19
-
20
-    const { login } = store.getModel('person').getState()
21
-      Taro.login({
22
-        success: (res) => {
23
-          const { code } = res;
24
-          login({ code })
15
+    console.group("APP Launch");
16
+    console.debug(options);
17
+    console.groupEnd();
18
+    const { setTpls } = store.getModel("tpls").getState();
19
+
20
+    Taro.getBackgroundFetchData({
21
+      fetchType: "pre",
22
+      success(res) {
23
+        const { code, data } = JSON.parse(res.fetchedData) || {};
24
+        if (code === 1000) {
25
+          const { tpls } = data;
26
+          let Tpls=tpls.map(item=>item.appTplId)
27
+          Tpls=[...new Set(Tpls)]
28
+          setTpls(Tpls);          
25 29
         }
26
-      })
30
+      },
31
+      fail: (errMessage) => {
32
+        console.log("预拉取数据失败" + errMessage);
33
+      },
34
+    });
35
+
36
+    const { login } = store.getModel("person").getState();
37
+    Taro.login({
38
+      success: (res) => {
39
+        const { code } = res;
40
+        login({ code });
41
+      },
42
+    });
27 43
 
28 44
     // const { login } = store.getModel('person').getState()
29 45
 
@@ -49,12 +65,8 @@ class App extends Component {
49 65
 
50 66
   // this.props.children 是将要会渲染的页面
51 67
   render() {
52
-    return (
53
-      <StoreRoot>
54
-        {this.props.children}
55
-      </StoreRoot>
56
-    )
68
+    return <StoreRoot>{this.props.children}</StoreRoot>;
57 69
   }
58 70
 }
59 71
 
60
-export default App
72
+export default App;

+ 3
- 9
src/components/NullCard/style.less Datei anzeigen

@@ -1,17 +1,11 @@
1
-.noDataCard{
2
-  margin: 30px;
3
-  box-shadow: 0px 0px 44px 0px rgba(0, 0, 0, 0.08);
4
-  border-radius: 40px;
5
-  position: relative;
6
-  overflow: hidden;
1
+.noDataCard{  
7 2
   padding: 78px;
8 3
   font-size: 34px;
9
-  font-weight: bold;
10 4
   color: #B4B4B4;
11 5
   text-align: center;
12 6
   .NullImg{
13
-    width: 220px;
14
-    height: 264px;
7
+    width: 45vw;
8
+    height: 54vw;
15 9
     margin-bottom: 44px;
16 10
   }
17 11
 }

+ 1
- 1
src/pages/index/components/order/index.jsx Datei anzeigen

@@ -171,7 +171,7 @@ export default (props) => {
171 171
               })
172 172
           }
173 173
           {
174
-            isMore && <Footer />
174
+            jobList.length === 0 ||isMore && <Footer />
175 175
           }
176 176
         </View>
177 177
         <Popup

+ 10
- 5
src/pages/index/index.jsx Datei anzeigen

@@ -24,9 +24,14 @@ export default withLayout((props) => {
24 24
   let { tab } = router.params
25 25
   const { location, setLocation, setAddress } = useModel('location')
26 26
   const { person } = useModel('person')
27
+  const { tpls } = useModel('tpls')
27 28
   const handleClick = (val) => {
29
+    Taro.requestSubscribeMessage({
30
+      tmplIds: tpls
31
+    });
32
+
28 33
     if (!person.phone && val != 0) {
29
-      Taro.navigateTo({url:`/pages/Login/index?tab=${val}`})
34
+      Taro.navigateTo({ url: `/pages/Login/index?tab=${val}` })
30 35
     } else {
31 36
       Taro.redirectTo({ url: `/pages/index/index?tab=${val}` });
32 37
     }
@@ -53,19 +58,19 @@ export default withLayout((props) => {
53 58
   return (
54 59
     <View className='page-index'>
55 60
       <View className='index-navbar'>
56
-        <CustomNav home title={(!tab||tab==0) ? '首页' : tab == 1 ? '订单列表' : '我的'} />
61
+        <CustomNav home title={(!tab || tab == 0) ? '首页' : tab == 1 ? '订单列表' : '我的'} />
57 62
       </View>
58 63
       <View className='index-container'>
59
-        {(!tab||tab==0) && <Order />}
64
+        {(!tab || tab == 0) && <Order />}
60 65
         {tab == 1 && <Job />}
61 66
         {tab == 2 && <User />}
62 67
       </View>
63 68
       <View className='index-tabbar'>
64 69
         <View
65
-          className={['tabberItem', (!tab||tab==0) ? "activeTabber" : '']}
70
+          className={['tabberItem', (!tab || tab == 0) ? "activeTabber" : '']}
66 71
           onClick={() => handleClick(0)}
67 72
         >
68
-          <Image className='tabberImg' src={(!tab||tab==0) ? indexActive : indexImg}></Image>
73
+          <Image className='tabberImg' src={(!tab || tab == 0) ? indexActive : indexImg}></Image>
69 74
           <View className='text'>首页</View>
70 75
         </View>
71 76
         <View

+ 2
- 0
src/pages/machineryList/index.jsx Datei anzeigen

@@ -2,6 +2,7 @@ import { useEffect, useState } from "react"
2 2
 import Taro from "@tarojs/taro"
3 3
 import { View, ScrollView } from "@tarojs/components"
4 4
 import CustomNav from "@/components/CustomNav"
5
+import NullCard from "@/components/NullCard";
5 6
 import withLayout from '@/layouts'
6 7
 import { getMachineryList } from '@/services/machinery'
7 8
 import { useModel } from "@/store"
@@ -30,6 +31,7 @@ export default withLayout((props) => {
30 31
       <View className='index-container machineryListContent'>
31 32
         <ScrollView scrollY style={{ height: '100%' }}>
32 33
           {
34
+            machinery.length === 0 ? <NullCard value='您还没有农机!' /> :
33 35
             machinery?.map((item) => {
34 36
               return <MachineryCard value={item} key={item.machineryId} onClick={() => goDetail(item.machineryId)} goMap={() => goMap(item.machineryId)} />
35 37
             })

+ 24
- 22
src/pages/wallet/index.jsx Datei anzeigen

@@ -3,6 +3,7 @@ import { View, ScrollView } from "@tarojs/components"
3 3
 import { useEffect, useState } from "react"
4 4
 import withLayout from '@/layouts'
5 5
 import CustomNav from "@/components/CustomNav"
6
+import NullCard from "@/components/NullCard";
6 7
 import WalletCard from "@/components/walletCard"
7 8
 import ListTitle from "@/components/ListTitle"
8 9
 import { getAccount, getLogList } from '@/services/account'
@@ -55,30 +56,31 @@ export default withLayout((props) => {
55 56
           <WalletCard onClick={goWithdrawal} value={balance} />
56 57
           <ListTitle value='零钱明细' />
57 58
           {
58
-            logList && logList.map(item => {
59
-              return <View key={item.accountId} className='walletCell'>
60
-                <View className='flexTop'>
61
-                  <View className='content'>
62
-                    {
63
-                      item.chargeType == 'order_pay' ?
64
-                        '订单收入' :
65
-                        item.chargeType == 'order_refund' ?
66
-                          '用户退款' :
67
-                          item.chargeType == 'withdraw' ?
68
-                            '提现' : ''
69
-                    }
70
-                  </View>
71
-                  <View className={['money', item.chargeType == 'order_pay' ? '' : 'revenue']}>
72
-                    {
73
-                      item.chargeType == 'order_pay' ?
74
-                        '+' + item.money / 100 :
75
-                        '-' + item.money / 100
76
-                    }
59
+            logList.length === 0 ? <NullCard value='暂无明细!' /> :
60
+              logList.map(item => {
61
+                return <View key={item.accountId} className='walletCell'>
62
+                  <View className='flexTop'>
63
+                    <View className='content'>
64
+                      {
65
+                        item.chargeType == 'order_pay' ?
66
+                          '订单收入' :
67
+                          item.chargeType == 'order_refund' ?
68
+                            '用户退款' :
69
+                            item.chargeType == 'withdraw' ?
70
+                              '提现' : ''
71
+                      }
72
+                    </View>
73
+                    <View className={['money', item.chargeType == 'order_pay' ? '' : 'revenue']}>
74
+                      {
75
+                        item.chargeType == 'order_pay' ?
76
+                          '+' + item.money / 100 :
77
+                          '-' + item.money / 100
78
+                      }
79
+                    </View>
77 80
                   </View>
81
+                  <View className='withDrawalDetail'>{item.createDate.substr(0, 16)}</View>
78 82
                 </View>
79
-                <View className='withDrawalDetail'>{item.createDate.substr(0, 16)}</View>
80
-              </View>
81
-            })
83
+              })
82 84
           }
83 85
         </ScrollView>
84 86
       </View>

+ 3
- 1
src/store/index.js Datei anzeigen

@@ -2,12 +2,14 @@ import { createStore, createStoreRoot, createModelHook } from '@zjxpcyc/react-ti
2 2
 import phone from './models/phone'
3 3
 import person from './models/person'
4 4
 import location from './models/location'
5
+import tpls from './models/tpls'
5 6
 
6 7
 const store = createStore()
7 8
 const models = {
8 9
   phone,
9 10
   person,
10
-  location
11
+  location,
12
+  tpls
11 13
 }
12 14
 
13 15
 const useModel = createModelHook(store)

+ 10
- 0
src/store/models/tpls.js Datei anzeigen

@@ -0,0 +1,10 @@
1
+import { useState } from "react";
2
+
3
+export default function usePhone() {
4
+  const [tpls, setTpls] = useState()
5
+
6
+  return {
7
+    tpls,
8
+    setTpls,
9
+  }
10
+}