李志伟 před 3 roky
rodič
revize
ec9d008e95

binární
src/assets/login/checkedImg.png Zobrazit soubor


binární
src/assets/login/unChecked.png Zobrazit soubor


+ 8
- 0
src/layouts/index.jsx Zobrazit soubor

1
+
2
+import Taro from '@tarojs/taro'
3
+import useRouter from '@/utils/hooks/useRouter'
4
+
5
+export default (Child) => (props) => {
6
+  const router = useRouter()
7
+  return <Child {...props} router={router} />
8
+}

+ 25
- 0
src/layouts/style.less Zobrazit soubor

1
+
2
+.loading {
3
+  margin: 0 auto;
4
+  margin-top: 30vh;
5
+  position: relative;
6
+
7
+  &-logo {
8
+    box-sizing: border-box;
9
+    padding: 12px;
10
+    position: absolute;
11
+    left: 0;
12
+    transform: scale(.75, .75);
13
+    animation: logo-opacity 2s linear infinite;
14
+  }
15
+}
16
+
17
+@keyframes logo-opacity {
18
+  0%, 100% {
19
+    opacity: 1;
20
+  }
21
+
22
+  50% {
23
+    opacity: .4;
24
+  }
25
+}

+ 9
- 9
src/pages/index/components/User/index.jsx Zobrazit soubor

1
+import { useState,useEffect } from "react"
1
 import Taro from "@tarojs/taro"
2
 import Taro from "@tarojs/taro"
2
 import { View, Image, ScrollView } from "@tarojs/components"
3
 import { View, Image, ScrollView } from "@tarojs/components"
3
 import userBgi from '@/assets/user/userBgi.png'
4
 import userBgi from '@/assets/user/userBgi.png'
13
 import bankCard from '@/assets/user/bankCard.png'
14
 import bankCard from '@/assets/user/bankCard.png'
14
 import banner1 from '@/assets/banner/1.jpg'
15
 import banner1 from '@/assets/banner/1.jpg'
15
 import './style.less'
16
 import './style.less'
16
-import { useState } from "react"
17
 
17
 
18
 export default (props) => {
18
 export default (props) => {
19
   const { isLogin } = props
19
   const { isLogin } = props
20
-  const [islogin, setIsLogin] = useState(false)
21
   const handleAccount = () => { console.log(5555) }
20
   const handleAccount = () => { console.log(5555) }
22
   const handleAboutUs = () => { }
21
   const handleAboutUs = () => { }
23
   const handleUpdate = () => { }
22
   const handleUpdate = () => { }
24
   const handleFeedback = () => { }
23
   const handleFeedback = () => { }
25
   const handleLogin = () => { 
24
   const handleLogin = () => { 
26
     Taro.navigateTo({ url: '/pages/login/index' });
25
     Taro.navigateTo({ url: '/pages/login/index' });
27
-    // setIsLogin(true) 
28
   }
26
   }
29
   const goMachinery = () => { }
27
   const goMachinery = () => { }
30
   const goWallet = () => { }
28
   const goWallet = () => { }
31
   const goBank = () => { }
29
   const goBank = () => { }
32
-  const signOut = () => { setIsLogin(false) }
30
+  const signOut = () => { 
31
+    Taro.reLaunch({ url: '/pages/index/index?tab=2' });
32
+  }
33
   return (
33
   return (
34
     <ScrollView scrollY style={{ height: '100%' }}>
34
     <ScrollView scrollY style={{ height: '100%' }}>
35
       {
35
       {
36
-        islogin &&
36
+        isLogin &&
37
         <View className='personTip'>该账号归张三所属</View>
37
         <View className='personTip'>该账号归张三所属</View>
38
       }
38
       }
39
       <View className='userHead'>
39
       <View className='userHead'>
40
         <Image src={userBgi} className='userBgi' />
40
         <Image src={userBgi} className='userBgi' />
41
         <View className='headcontent' onClick={handleLogin}>
41
         <View className='headcontent' onClick={handleLogin}>
42
-          <Image src={islogin ? banner1 : avatar} className='avatar' />
42
+          <Image src={isLogin ? banner1 : avatar} className='avatar' />
43
           {
43
           {
44
-            islogin ? <View>
44
+            isLogin ? <View>
45
               <View>张三</View>
45
               <View>张三</View>
46
               <View>13612345678</View>
46
               <View>13612345678</View>
47
             </View> : <View>点击登录</View>
47
             </View> : <View>点击登录</View>
49
         </View>
49
         </View>
50
       </View>
50
       </View>
51
       {
51
       {
52
-        islogin &&
52
+        isLogin &&
53
         <View className='userCard'>
53
         <View className='userCard'>
54
           <View
54
           <View
55
             className='cardItem'
55
             className='cardItem'
89
           <MyCell icon={feedback} action={goto} user handleAction={handleFeedback}>意见反馈</MyCell>
89
           <MyCell icon={feedback} action={goto} user handleAction={handleFeedback}>意见反馈</MyCell>
90
         </View>
90
         </View>
91
         {
91
         {
92
-          islogin && <View className='signOut' onClick={signOut}>退出登录</View>
92
+          isLogin && <View className='signOut' onClick={signOut}>退出登录</View>
93
         }
93
         }
94
       </View>
94
       </View>
95
 
95
 

+ 13
- 6
src/pages/index/index.jsx Zobrazit soubor

1
 import Taro from "@tarojs/taro";
1
 import Taro from "@tarojs/taro";
2
-import { useState,useEffect } from "react";
2
+import { useState, useEffect } from "react";
3
 import { View, Image } from "@tarojs/components"
3
 import { View, Image } from "@tarojs/components"
4
 import indexImg from "@/assets/comm/index.png";
4
 import indexImg from "@/assets/comm/index.png";
5
 import indexActive from "@/assets/comm/indexActive.png";
5
 import indexActive from "@/assets/comm/indexActive.png";
8
 import user from "@/assets/comm/user.png";
8
 import user from "@/assets/comm/user.png";
9
 import userActive from "@/assets/comm/userActive.png";
9
 import userActive from "@/assets/comm/userActive.png";
10
 import CustomNav from "@/components/CustomNav";
10
 import CustomNav from "@/components/CustomNav";
11
+import withLayout from '@/layouts'
11
 import Order from './components/Order'
12
 import Order from './components/Order'
12
 import Job from './components/Job'
13
 import Job from './components/Job'
13
 import User from "./components/User";
14
 import User from "./components/User";
14
 import "./index.less";
15
 import "./index.less";
15
 
16
 
16
-export default (props) => {
17
+export default withLayout((props) => {
18
+  const { router } = props
19
+  let { tab, isLogin } = router.params
17
   const [currentTab, setCurrentTab] = useState(0);
20
   const [currentTab, setCurrentTab] = useState(0);
18
   const handleClick = (val) => {
21
   const handleClick = (val) => {
19
     setCurrentTab(val);
22
     setCurrentTab(val);
20
   };
23
   };
21
-  
24
+  useEffect(() => {
25
+    if (tab) {
26
+      setCurrentTab(tab - 0)
27
+    }
28
+  }, [tab])
22
   return (
29
   return (
23
     <View className='page-index'>
30
     <View className='page-index'>
24
       <View className='index-navbar'>
31
       <View className='index-navbar'>
25
-        <CustomNav home title={currentTab === 0?'首页':currentTab === 1?'作业管理':'我的'} />
32
+        <CustomNav home title={currentTab === 0 ? '首页' : currentTab === 1 ? '作业管理' : '我的'} />
26
       </View>
33
       </View>
27
       <View className='index-container'>
34
       <View className='index-container'>
28
         {currentTab === 0 && <Order />}
35
         {currentTab === 0 && <Order />}
29
         {currentTab === 1 && <Job />}
36
         {currentTab === 1 && <Job />}
30
-        {currentTab === 2 && <User />}
37
+        {currentTab === 2 && <User isLogin={isLogin} />}
31
       </View>
38
       </View>
32
       <View className='index-tabbar'>
39
       <View className='index-tabbar'>
33
         <View
40
         <View
54
       </View>
61
       </View>
55
     </View>
62
     </View>
56
   );
63
   );
57
-};
64
+});

+ 95
- 1
src/pages/login/index.jsx Zobrazit soubor

1
-import { View, Image } from "@tarojs/components"
1
+import Taro from "@tarojs/taro"
2
+import { useState } from "react"
3
+import { View, Image, Input, Text, Checkbox, Label } from "@tarojs/components"
2
 import CustomNav from "@/components/CustomNav"
4
 import CustomNav from "@/components/CustomNav"
5
+import MyButton from "@/components/MyButton"
3
 import bgi from '@/assets/login/loginImg.png'
6
 import bgi from '@/assets/login/loginImg.png'
7
+import vCode from '@/assets/login/VerificationCode.png'
8
+import checkedImg from '@/assets/login/checkedImg.png'
9
+import unChecked from '@/assets/login/unChecked.png'
4
 import './style.less'
10
 import './style.less'
5
 
11
 
6
 export default (props) => {
12
 export default (props) => {
13
+  const [agreement,setAgreement]=useState(false)
14
+  const [phone,setPhone]=useState()
15
+  const [qCode,setqCode]=useState()
16
+  const [qCodeBtn,setqCodeBtn]=useState('获取验证码')
17
+  const [dsb,setDsb]=useState(false)
18
+  const handlePhone=(e)=>{
19
+    if (e.detail.value) {
20
+      setPhone(e.detail.value)
21
+    }
22
+  }
23
+  const changeqCode=()=>{
24
+    if (rulePhone(phone)) {
25
+      console.log(666)
26
+
27
+      let time=10
28
+      setDsb(true)
29
+      // 调接口
30
+      let timer = setInterval(() => {
31
+        time-- //倒计时递减
32
+        setqCodeBtn(`${time}s后重新发送`)
33
+        if (time === 0) {
34
+          setDsb(false)
35
+          setqCodeBtn('重新发送')
36
+          time=60
37
+          clearInterval(timer)
38
+        }
39
+      }, 1000)
40
+
41
+    }
42
+  }
43
+  const rulePhone=(val)=>{
44
+    if (!/^1[0-9]{10}$/.test(val)) {
45
+      Taro.showToast({
46
+        title: '请输入正确的11位手机号',
47
+        icon: 'none',
48
+        duration: 2000
49
+      })
50
+      return false
51
+    } else return true
52
+  }
53
+  const handleqCode=(e)=>{
54
+    if (e.detail.value) {
55
+      setqCode(e.detail.value)
56
+    }
57
+  }
58
+  const onLogin = () => { 
59
+    if (rulePhone(phone)&&qCode) {
60
+      if (!agreement) {
61
+        Taro.showToast({
62
+          title: '请确认下方协议',
63
+          icon: 'none',
64
+          duration: 2000
65
+        })
66
+        return false
67
+      }
68
+      Taro.showToast({
69
+        title: '登录成功',
70
+        icon: 'none',
71
+        duration: 1000
72
+      })
73
+      Taro.reLaunch({ url: '/pages/index/index?tab=2&&isLogin=true' });
74
+
75
+    } else {
76
+      Taro.showToast({
77
+        title: '请输入正确的手机号和验证码',
78
+        icon: 'none',
79
+        duration: 2000
80
+      })
81
+    }
82
+  }
7
   return (
83
   return (
8
     <View className='page-index'>
84
     <View className='page-index'>
9
       <View className='index-navbar'>
85
       <View className='index-navbar'>
13
       <View className='index-container loginContent'>
89
       <View className='index-container loginContent'>
14
         <View className='title1'>您好!</View>
90
         <View className='title1'>您好!</View>
15
         <View className='title2'>欢迎进入农机手端小程序!</View>
91
         <View className='title2'>欢迎进入农机手端小程序!</View>
92
+        <View className='loginCell'>
93
+          <View className='loginHeader'>+86</View>
94
+          <Input type='number' maxlength='11' placeholder='请输入手机号' value={phone} onBlur={handlePhone} />
95
+          <View  className={['loginAction',dsb?'qCodeActive':'']} onClick={dsb?'':changeqCode}>{qCodeBtn}</View>
96
+        </View>
97
+        <View className='loginCell'>
98
+          <View className='loginHeader'>
99
+            <Image src={vCode} className='headerImg' />
100
+          </View>
101
+          <Input type='text' value={qCode} onInput={handleqCode} placeholder='请输入验证码' />
102
+        </View>
103
+        <View className='footer'>
104
+          <MyButton value='登录' onClick={onLogin} />
105
+          <View className='agreement' onClick={()=>setAgreement(!agreement)}>
106
+              <Image src={agreement?checkedImg:unChecked} className='footerCheckbox' />
107
+              请认真查看<Text>文本协议/隐私政策</Text>,确认之后选择此项!
108
+          </View>
109
+        </View>
16
       </View>
110
       </View>
17
     </View>
111
     </View>
18
   )
112
   )

+ 60
- 0
src/pages/login/style.less Zobrazit soubor

17
     font-size: 54px;
17
     font-size: 54px;
18
     letter-spacing: 10px;
18
     letter-spacing: 10px;
19
   }
19
   }
20
+  .loginCell{
21
+    display: flex;
22
+    align-items: center;
23
+    height: 108px;
24
+    box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.12);
25
+    .loginHeader,.loginAction{
26
+      flex: none;
27
+    }
28
+    .loginHeader{
29
+      font-size: 38px;
30
+      font-weight: 500;
31
+      color: #333333;
32
+      width: 106px;
33
+      border-right: 1px solid #333;
34
+      display: flex;
35
+      .headerImg{
36
+        width: 32px;
37
+        height: 40px;
38
+        margin-left: 19px;
39
+      }
40
+    }
41
+    .loginAction{
42
+      width: 8em;
43
+      height: 68px;
44
+      background: linear-gradient(0deg, #00AE39,#A0E067);
45
+      border-radius: 20px;
46
+      line-height: 68px;
47
+      text-align: center;
48
+      color: #fff;
49
+      font-size: 30px;
50
+      font-weight: bold
51
+    }
52
+    .qCodeActive{
53
+      opacity: 0.5;
54
+    }
55
+    input{
56
+      flex: 1;
57
+      padding: 0 0 0 31px;
58
+    }
59
+  }
60
+  .footer{
61
+    position: absolute;
62
+    bottom: 60px;
63
+    .agreement{
64
+      font-size: 26px;
65
+      font-weight: 400;
66
+      color: #999;
67
+      margin-top: 42px;
68
+      display: flex;
69
+      align-items: center;
70
+      .footerCheckbox{
71
+        width: 28px;
72
+        height: 28px;
73
+        margin-right: 11px;
74
+      }
75
+      Text{
76
+        color: #02902E
77
+      }
78
+    }
79
+  }
20
 }
80
 }

+ 4
- 3
src/pages/moreOrder/index.jsx Zobrazit soubor

1
+import { useState } from "react";
1
 import { View, Input, Image, Text, ScrollView } from "@tarojs/components"
2
 import { View, Input, Image, Text, ScrollView } from "@tarojs/components"
2
 import CustomNav from "@/components/CustomNav";
3
 import CustomNav from "@/components/CustomNav";
3
 import searchImg from '@/assets/comm/search.png'
4
 import searchImg from '@/assets/comm/search.png'
4
-import { useState } from "react";
5
+import withLayout from '@/layouts'
5
 import MyCard from "@/components/MyCard";
6
 import MyCard from "@/components/MyCard";
6
 import Footer from "@/components/Footer";
7
 import Footer from "@/components/Footer";
7
 import './style.less'
8
 import './style.less'
8
 
9
 
9
-export default () => {
10
+export default withLayout(() => {
10
   const [imageShow, setImageShow] = useState(true)
11
   const [imageShow, setImageShow] = useState(true)
11
   const [currentTab, setCurrentTab] = useState(0);
12
   const [currentTab, setCurrentTab] = useState(0);
12
   const handleSearch = (e) => {
13
   const handleSearch = (e) => {
85
       </View>
86
       </View>
86
     </View>
87
     </View>
87
   )
88
   )
88
-}
89
+})

+ 3
- 2
src/pages/orderDetail/index.jsx Zobrazit soubor

1
 import { View } from "@tarojs/components"
1
 import { View } from "@tarojs/components"
2
 import CustomNav from "@/components/CustomNav"
2
 import CustomNav from "@/components/CustomNav"
3
 import MyCard from "@/components/MyCard"
3
 import MyCard from "@/components/MyCard"
4
+import withLayout from '@/layouts'
4
 
5
 
5
-export default () => {
6
+export default withLayout(() => {
6
   return (
7
   return (
7
     <View className='page-index'>
8
     <View className='page-index'>
8
       <View className='index-navbar'>
9
       <View className='index-navbar'>
13
       </View>
14
       </View>
14
     </View>
15
     </View>
15
   )
16
   )
16
-}
17
+})

+ 12
- 0
src/utils/hooks/useRouter.js Zobrazit soubor

1
+import Taro, { useRouter } from '@tarojs/taro'
2
+import {  useRef  } from 'react'
3
+
4
+export default () => {
5
+  const router = useRouter()
6
+  const routerRef = useRef()
7
+
8
+
9
+  routerRef.current = router
10
+
11
+  return routerRef.current
12
+}