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

+ 31
- 25
src/components/LoginModel/index.jsx Parādīt failu

4
 import { View, Image, Input, Text, Button } from "@tarojs/components"
4
 import { View, Image, Input, Text, Button } from "@tarojs/components"
5
 import CustomNav from "@/components/CustomNav"
5
 import CustomNav from "@/components/CustomNav"
6
 import MyButton from "@/components/MyButton"
6
 import MyButton from "@/components/MyButton"
7
-import {updatePhone, setQcode } from '@/services/login'
7
+import { updatePhone, setQcode } from '@/services/login'
8
 import bgi from '@/assets/login/loginImg.png'
8
 import bgi from '@/assets/login/loginImg.png'
9
 import vCode from '@/assets/login/VerificationCode.png'
9
 import vCode from '@/assets/login/VerificationCode.png'
10
 import checkedImg from '@/assets/login/checkedImg.png'
10
 import checkedImg from '@/assets/login/checkedImg.png'
12
 import './style.less'
12
 import './style.less'
13
 
13
 
14
 export default (props) => {
14
 export default (props) => {
15
-  const {tab}=props
16
-  const { person,setPerson } = useModel('person')
17
-  const [agreement,setAgreement]=useState(false)
18
-  const [phone,setPhone]=useState()
19
-  const [qCode,setqCode]=useState()
20
-  const [qCodeBtn,setqCodeBtn]=useState('获取验证码')
21
-  const [dsb,setDsb]=useState(false)
22
-  const handlePhone=(e)=>{
15
+  const { tab } = props
16
+  const { person, setPerson } = useModel('person')
17
+  const [agreement, setAgreement] = useState(false)
18
+  const [phone, setPhone] = useState()
19
+  const [qCode, setqCode] = useState()
20
+  const [qCodeBtn, setqCodeBtn] = useState('获取验证码')
21
+  const [dsb, setDsb] = useState(false)
22
+  const handlePhone = (e) => {
23
     if (e.detail.value) {
23
     if (e.detail.value) {
24
       setPhone(e.detail.value)
24
       setPhone(e.detail.value)
25
     }
25
     }
26
   }
26
   }
27
-  const changeqCode=()=>{
27
+  const changeqCode = () => {
28
     if (rulePhone(phone)) {
28
     if (rulePhone(phone)) {
29
-      setQcode({phone:phone}).then((res)=>{
29
+      setQcode({ phone: phone }).then((res) => {
30
         Taro.showToast({
30
         Taro.showToast({
31
           title: '发送成功,请注意查收',
31
           title: '发送成功,请注意查收',
32
           icon: 'none',
32
           icon: 'none',
39
         })
39
         })
40
       })
40
       })
41
 
41
 
42
-      let time=60
42
+      let time = 60
43
       setDsb(true)
43
       setDsb(true)
44
       // 调接口
44
       // 调接口
45
       let timer = setInterval(() => {
45
       let timer = setInterval(() => {
48
         if (time === 0) {
48
         if (time === 0) {
49
           setDsb(false)
49
           setDsb(false)
50
           setqCodeBtn('重新发送')
50
           setqCodeBtn('重新发送')
51
-          time=60
51
+          time = 60
52
           clearInterval(timer)
52
           clearInterval(timer)
53
         }
53
         }
54
       }, 1000)
54
       }, 1000)
55
 
55
 
56
     }
56
     }
57
   }
57
   }
58
-  const rulePhone=(val)=>{
58
+  const rulePhone = (val) => {
59
     if (!/^1[0-9]{10}$/.test(val)) {
59
     if (!/^1[0-9]{10}$/.test(val)) {
60
       Taro.showToast({
60
       Taro.showToast({
61
         title: '请输入正确的11位手机号',
61
         title: '请输入正确的11位手机号',
65
       return false
65
       return false
66
     } else return true
66
     } else return true
67
   }
67
   }
68
-  const handleqCode=(e)=>{
68
+  const handleqCode = (e) => {
69
     if (e.detail.value) {
69
     if (e.detail.value) {
70
       setqCode(e.detail.value)
70
       setqCode(e.detail.value)
71
     }
71
     }
72
   }
72
   }
73
-  const onLogin = () => { 
74
-    if (rulePhone(phone)&&qCode) {
73
+  const onLogin = () => {
74
+    if (rulePhone(phone) && qCode) {
75
       if (!agreement) {
75
       if (!agreement) {
76
         Taro.showToast({
76
         Taro.showToast({
77
           title: '请确认下方协议',
77
           title: '请确认下方协议',
81
         return false
81
         return false
82
       }
82
       }
83
       // 登录
83
       // 登录
84
-      updatePhone(person.personId,{phone:phone,captcha:qCode}).then((res)=>{
84
+      updatePhone(person.personId, { phone: phone, captcha: qCode }).then((res) => {
85
         setPerson(res.person)
85
         setPerson(res.person)
86
         Taro.showToast({
86
         Taro.showToast({
87
           title: '登录成功',
87
           title: '登录成功',
89
           duration: 1000
89
           duration: 1000
90
         })
90
         })
91
         if (tab) {
91
         if (tab) {
92
-          setTimeout(()=>{
92
+          setTimeout(() => {
93
             Taro.redirectTo({ url: `/pages/index/index?tab=${tab}` });
93
             Taro.redirectTo({ url: `/pages/index/index?tab=${tab}` });
94
-          },1000)
94
+          }, 1000)
95
         }
95
         }
96
       }).catch((e) => {
96
       }).catch((e) => {
97
         Taro.showToast({
97
         Taro.showToast({
108
     }
108
     }
109
   }
109
   }
110
   return (
110
   return (
111
-    <View className='page-index' style={{position:'absolute', zIndex:9999}}>
111
+    <View className='page-index' style={{ position: 'absolute', zIndex: 9999 }}>
112
       <View className='index-navbar'>
112
       <View className='index-navbar'>
113
         <CustomNav home title='登录' />
113
         <CustomNav home title='登录' />
114
       </View>
114
       </View>
119
         <View className='loginCell'>
119
         <View className='loginCell'>
120
           <View className='loginHeader'>+86</View>
120
           <View className='loginHeader'>+86</View>
121
           <Input type='number' maxlength='11' placeholder='请输入手机号' value={phone} onInput={handlePhone} />
121
           <Input type='number' maxlength='11' placeholder='请输入手机号' value={phone} onInput={handlePhone} />
122
-          <Button  className={['loginAction',dsb?'qCodeActive':'']} disabled={dsb} onClick={dsb?'':changeqCode}>{qCodeBtn}</Button>
122
+          <Button className={['loginAction', dsb ? 'qCodeActive' : '']} disabled={dsb} onClick={dsb ? '' : changeqCode}>{qCodeBtn}</Button>
123
         </View>
123
         </View>
124
         <View className='loginCell'>
124
         <View className='loginCell'>
125
           <View className='loginHeader'>
125
           <View className='loginHeader'>
129
         </View>
129
         </View>
130
         <View className='footer'>
130
         <View className='footer'>
131
           <MyButton value='登录' onClick={onLogin} />
131
           <MyButton value='登录' onClick={onLogin} />
132
-          <View className='agreement' onClick={()=>setAgreement(!agreement)}>
133
-              <Image src={agreement?checkedImg:unChecked} className='footerCheckbox' />
134
-              请认真查看<Text>文本协议/隐私政策</Text>,确认之后选择此项!
132
+          <View className='agreement' onClick={() => setAgreement(!agreement)}>
133
+            <Image src={agreement ? checkedImg : unChecked} className='footerCheckbox' />
134
+            请认真查看<Text
135
+              onClick={
136
+                (e) => {
137
+                  e.stopPropagation();
138
+                  Taro.navigateTo({ url: '/pages/versionUpdate/index' });
139
+                }}
140
+            >文本协议/隐私政策</Text>,确认之后选择此项!
135
           </View>
141
           </View>
136
         </View>
142
         </View>
137
       </View>
143
       </View>

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

46
   }
46
   }
47
   return (
47
   return (
48
     <ScrollView scrollY style={{ height: '100%' }}>
48
     <ScrollView scrollY style={{ height: '100%' }}>
49
-      <View className='personTip'>该账号归{person.nickName || '张三'}所属</View>
49
+      <View className='personTip'>该账号归{person.nickName}pc用户名所属</View>
50
       <View className='userHead' onClick={handleAccount}>
50
       <View className='userHead' onClick={handleAccount}>
51
         <Image src={userBgi} className='userBgi' />
51
         <Image src={userBgi} className='userBgi' />
52
         <View className='headcontent' >
52
         <View className='headcontent' >
88
           <MyCell icon={aboutUs} action={goto} user handleAction={handleAboutUs}>关于我们</MyCell>
88
           <MyCell icon={aboutUs} action={goto} user handleAction={handleAboutUs}>关于我们</MyCell>
89
         </View>
89
         </View>
90
         <View className='userBox'>
90
         <View className='userBox'>
91
-          <MyCell icon={update} action={goto} user handleAction={handleUpdate}>版本更新</MyCell>
91
+          <MyCell icon={update} action={goto} user handleAction={handleUpdate}>用户协议及隐私政策</MyCell>
92
         </View>
92
         </View>
93
         <View className='userBox'>
93
         <View className='userBox'>
94
           <MyCell icon={feedback} action={goto} user handleAction={handleFeedback}>意见反馈</MyCell>
94
           <MyCell icon={feedback} action={goto} user handleAction={handleFeedback}>意见反馈</MyCell>

+ 0
- 1
src/pages/index/components/User/style.less Parādīt failu

1
 .personTip{
1
 .personTip{
2
   font-size: 24px;
2
   font-size: 24px;
3
   color: #FFFFFF;
3
   color: #FFFFFF;
4
-  width: 247px;
5
   height: 54px;
4
   height: 54px;
6
   background: #000000;
5
   background: #000000;
7
   opacity: 0.3;
6
   opacity: 0.3;

+ 6
- 0
src/pages/userInfo/index.jsx Parādīt failu

87
           <Image src={avatar} className='avatarImg' />
87
           <Image src={avatar} className='avatarImg' />
88
           <View className='change'>更换头像</View>
88
           <View className='change'>更换头像</View>
89
         </View>
89
         </View>
90
+        <View className='userCell'>
91
+          <View>用户名:</View>
92
+          <View style={{ display: 'flex', opacity: 0.5, alignItems: 'center', height: '54px' }}>
93
+            <Input type='text' value='pc端用户名' disabled className='userName' />
94
+          </View>
95
+        </View>
90
         <View className='userCell'>
96
         <View className='userCell'>
91
           <View>姓名:</View>
97
           <View>姓名:</View>
92
           <View style={{ display: 'flex', alignItems: 'center', height: '54px' }}>
98
           <View style={{ display: 'flex', alignItems: 'center', height: '54px' }}>

+ 9
- 0
src/pages/userInfo/style.less Parādīt failu

21
       right: 0;
21
       right: 0;
22
     }
22
     }
23
   }
23
   }
24
+  .userPcName{
25
+    box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.12);
26
+    font-size: 34px;
27
+    font-weight: bold;
28
+    color: #333333;
29
+    height: 108px;
30
+    line-height: 108px;
31
+    margin-top: 80px;
32
+  }
24
   .userCell{
33
   .userCell{
25
     background: #FFF;
34
     background: #FFF;
26
     box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.12);
35
     box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.12);

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

8
   return (
8
   return (
9
     <View className='page-index'>
9
     <View className='page-index'>
10
       <View className='index-navbar'>
10
       <View className='index-navbar'>
11
-        <CustomNav title='关于我们' />
11
+        <CustomNav title='用户协议' />
12
       </View>
12
       </View>
13
       <View className='index-container version'>
13
       <View className='index-container version'>
14
         <ScrollView scrollY style={{ height: '100%' }}>
14
         <ScrollView scrollY style={{ height: '100%' }}>

+ 18
- 15
src/utils/hooks/useLogin.js Parādīt failu

1
 import Taro, { useRouter } from "@tarojs/taro";
1
 import Taro, { useRouter } from "@tarojs/taro";
2
-import { useModel } from '@/store'
2
+import { useModel } from "@/store";
3
 import { useMemo, useState, useEffect } from "react";
3
 import { useMemo, useState, useEffect } from "react";
4
 
4
 
5
 const whiteList = [
5
 const whiteList = [
6
   "/pages/index/index",
6
   "/pages/index/index",
7
-  "/pages/Login/index"
8
-]
7
+  "/pages/Login/index",
8
+  "/pages/versionUpdate/index",
9
+];
9
 
10
 
10
 export default () => {
11
 export default () => {
11
-  const router = useRouter()
12
-  const { person } = useModel('person')
13
-  const [loginVisible, setLoginVisible] = useState(false)
12
+  const router = useRouter();
13
+  const { person } = useModel("person");
14
+  const [loginVisible, setLoginVisible] = useState(false);
15
+
16
+  const isInWhiteList = useMemo(
17
+    () => whiteList.includes(router.path),
18
+    [router.path]
19
+  );
20
+  const hasPhone = useMemo(() => !!person?.phone, [person?.phone]);
14
 
21
 
15
-  const isInWhiteList = useMemo(() => whiteList.includes(router.path), [router.path])
16
-  const hasPhone = useMemo(() => !!person?.phone, [person?.phone])
17
-  
18
   useEffect(() => {
22
   useEffect(() => {
19
     if (!isInWhiteList && !hasPhone) {
23
     if (!isInWhiteList && !hasPhone) {
20
-      setLoginVisible(true)
24
+      setLoginVisible(true);
21
     } else {
25
     } else {
22
-      setLoginVisible(false)
26
+      setLoginVisible(false);
23
     }
27
     }
24
-  }, [hasPhone, isInWhiteList])
25
-
28
+  }, [hasPhone, isInWhiteList]);
26
 
29
 
27
-  return { loginVisible }
28
-};
30
+  return { loginVisible };
31
+};