李志伟 3 gadus atpakaļ
vecāks
revīzija
b44e607261

+ 41
- 57
src/pages/index/components/User/index.jsx Parādīt failu

@@ -1,4 +1,4 @@
1
-import { useState,useEffect } from "react"
1
+import { useState, useEffect } from "react"
2 2
 import { useModel } from '@/store'
3 3
 import Taro from "@tarojs/taro"
4 4
 import { View, Image, ScrollView } from "@tarojs/components"
@@ -13,85 +13,72 @@ import goto from '@/assets/user/goto.png'
13 13
 import machinery from '@/assets/user/machinery.png'
14 14
 import wallet from '@/assets/user/wallet.png'
15 15
 import bankCard from '@/assets/user/bankCard.png'
16
-import banner1 from '@/assets/banner/1.jpg'
17 16
 import './style.less'
18 17
 
19 18
 export default (props) => {
20
-  const { phone,setPhone } = useModel('phone')
19
+  const { phone, setPhone } = useModel('phone')
21 20
 
22
-  const handleAccount = () => { 
21
+  const handleAccount = () => {
23 22
     Taro.navigateTo({ url: '/pages/userInfo/index' });
24
-   }
25
-  const handleAboutUs = () => { 
23
+  }
24
+  const handleAboutUs = () => {
26 25
     Taro.navigateTo({ url: '/pages/aboutUs/index' });
27 26
   }
28 27
   const handleUpdate = () => {
29 28
     Taro.navigateTo({ url: '/pages/versionUpdate/index' });
30
-   }
31
-  const handleFeedback = () => { 
32
-    Taro.navigateTo({ url: '/pages/feedback/index' });
33 29
   }
34
-  const handleLogin = () => { 
35
-    Taro.navigateTo({ url: '/pages/login/index' });
30
+  const handleFeedback = () => {
31
+    Taro.navigateTo({ url: '/pages/feedback/index' });
36 32
   }
37 33
   const goMachinery = () => {
38 34
     Taro.navigateTo({ url: '/pages/machineryList/index' });
39
-   }
35
+  }
40 36
   const goWallet = () => {
41 37
     Taro.navigateTo({ url: '/pages/wallet/index?balance=2022.56' });
42
-   }
38
+  }
43 39
   const goBank = () => {
44 40
     Taro.navigateTo({ url: '/pages/bankCard/index' });
45
-   }
46
-  const signOut = () => { 
41
+  }
42
+  const signOut = () => {
47 43
     setPhone()
48 44
     Taro.reLaunch({ url: '/pages/index/index?tab=2' });
49 45
   }
50 46
   return (
51 47
     <ScrollView scrollY style={{ height: '100%' }}>
52
-      {
53
-        phone &&
54
-        <View className='personTip'>该账号归张三所属</View>
55
-      }
48
+      <View className='personTip'>该账号归张三所属</View>
56 49
       <View className='userHead'>
57 50
         <Image src={userBgi} className='userBgi' />
58
-        <View className='headcontent' onClick={phone?'':handleLogin}>
59
-          <Image src={phone ? banner1 : avatar} className='avatar' />
60
-          {
61
-            phone ? <View>
62
-              <View>张三</View>
63
-              <View>{phone}</View>
64
-            </View> : <View>点击登录</View>
65
-          }
51
+        <View className='headcontent' >
52
+          <Image src={avatar} className='avatar' />
53
+          <View>
54
+            <View>张三</View>
55
+            <View>{phone}</View>
56
+          </View>
66 57
         </View>
67 58
       </View>
68
-      {
69
-        phone &&
70
-        <View className='userCard'>
71
-          <View
72
-            className='cardItem'
73
-            onClick={() => goMachinery()}
74
-          >
75
-            <Image className='cardImg' src={machinery}></Image>
76
-            <View className='text'>我的农机</View>
77
-          </View>
78
-          <View
79
-            className='cardItem'
80
-            onClick={() => goWallet()}
81
-          >
82
-            <Image className='cardImg' src={wallet}></Image>
83
-            <View className='text'>我的钱包</View>
84
-          </View>
85
-          <View
86
-            className='cardItem'
87
-            onClick={() => goBank()}
88
-          >
89
-            <Image className='cardImg' src={bankCard}></Image>
90
-            <View className='text'>我的银行卡</View>
91
-          </View>
92
-
59
+      <View className='userCard'>
60
+        <View
61
+          className='cardItem'
62
+          onClick={() => goMachinery()}
63
+        >
64
+          <Image className='cardImg' src={machinery}></Image>
65
+          <View className='text'>我的农机</View>
66
+        </View>
67
+        <View
68
+          className='cardItem'
69
+          onClick={() => goWallet()}
70
+        >
71
+          <Image className='cardImg' src={wallet}></Image>
72
+          <View className='text'>我的钱包</View>
93 73
         </View>
94
-      }
74
+        <View
75
+          className='cardItem'
76
+          onClick={() => goBank()}
77
+        >
78
+          <Image className='cardImg' src={bankCard}></Image>
79
+          <View className='text'>我的银行卡</View>
80
+        </View>
81
+      </View>
95 82
       <View className='userContent'>
96 83
         <View className='userBox'>
97 84
           <MyCell icon={account} action={goto} user handleAction={handleAccount} >账号与安全</MyCell>
@@ -105,11 +92,8 @@ export default (props) => {
105 92
         <View className='userBox'>
106 93
           <MyCell icon={feedback} action={goto} user handleAction={handleFeedback}>意见反馈</MyCell>
107 94
         </View>
108
-        {
109
-          phone && <View className='signOut' onClick={signOut}>退出登录</View>
110
-        }
95
+        <View className='signOut' onClick={signOut}>退出登录</View>
111 96
       </View>
112
-
113 97
     </ScrollView>
114 98
   )
115 99
 }

+ 9
- 2
src/pages/index/index.jsx Parādīt failu

@@ -9,6 +9,7 @@ import user from "@/assets/comm/user.png";
9 9
 import userActive from "@/assets/comm/userActive.png";
10 10
 import CustomNav from "@/components/CustomNav";
11 11
 import withLayout from '@/layouts'
12
+import { useModel } from "@/store";
12 13
 import Order from './components/Order'
13 14
 import Job from './components/Job'
14 15
 import User from "./components/User";
@@ -17,15 +18,21 @@ import "./index.less";
17 18
 export default withLayout((props) => {
18 19
   const { router } = props
19 20
   let { tab, isLogin } = router.params
21
+  const { phone } = useModel('phone')
20 22
   const [currentTab, setCurrentTab] = useState(0);
21 23
   const handleClick = (val) => {
22 24
     setCurrentTab(val);
23 25
   };
24
-  useEffect(() => {
25
-    if (tab) {
26
+  useEffect(() => {    
27
+    if (tab) {      
26 28
       setCurrentTab(tab - 0)
27 29
     }
28 30
   }, [tab])
31
+  useEffect(()=>{
32
+    if (currentTab!==0&&!phone) {
33
+      Taro.reLaunch({ url: '/pages/login/index' });
34
+    }
35
+  },[currentTab])
29 36
   return (
30 37
     <View className='page-index'>
31 38
       <View className='index-navbar'>

+ 1
- 1
src/pages/login/index.jsx Parādīt failu

@@ -109,7 +109,7 @@ export default (props) => {
109 109
   return (
110 110
     <View className='page-index'>
111 111
       <View className='index-navbar'>
112
-        <CustomNav title='登录' />
112
+        <CustomNav home title='登录' />
113 113
       </View>
114 114
       <Image src={bgi} className='loginBgi' />
115 115
       <View className='index-container loginContent'>

+ 17
- 0
src/services/machinery.js Parādīt failu

@@ -0,0 +1,17 @@
1
+import request from '@/utils/request'
2
+
3
+/**
4
+ * 农机详情
5
+ * @param {*} id 
6
+ * @returns 
7
+ */
8
+ export const getMachineryDetail = (id, params) => request(`/machinery-sunmmary/${id}`, { params })
9
+
10
+
11
+ /**
12
+  * 农机列表
13
+  * @returns 
14
+  * params 搜索条件放这里
15
+  */
16
+ export const getMachineryList = (params) => request('/machinery', { params })
17
+