李志伟 hace 3 años
padre
commit
1ad59e3fe0

+ 31
- 25
src/components/LoginModel/index.jsx Ver fichero

@@ -4,7 +4,7 @@ import { useModel } from '@/store'
4 4
 import { View, Image, Input, Text, Button } from "@tarojs/components"
5 5
 import CustomNav from "@/components/CustomNav"
6 6
 import MyButton from "@/components/MyButton"
7
-import {updatePhone, setQcode } from '@/services/login'
7
+import { updatePhone, setQcode } from '@/services/login'
8 8
 import bgi from '@/assets/login/loginImg.png'
9 9
 import vCode from '@/assets/login/VerificationCode.png'
10 10
 import checkedImg from '@/assets/login/checkedImg.png'
@@ -12,21 +12,21 @@ import unChecked from '@/assets/login/unChecked.png'
12 12
 import './style.less'
13 13
 
14 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 23
     if (e.detail.value) {
24 24
       setPhone(e.detail.value)
25 25
     }
26 26
   }
27
-  const changeqCode=()=>{
27
+  const changeqCode = () => {
28 28
     if (rulePhone(phone)) {
29
-      setQcode({phone:phone}).then((res)=>{
29
+      setQcode({ phone: phone }).then((res) => {
30 30
         Taro.showToast({
31 31
           title: '发送成功,请注意查收',
32 32
           icon: 'none',
@@ -39,7 +39,7 @@ export default (props) => {
39 39
         })
40 40
       })
41 41
 
42
-      let time=60
42
+      let time = 60
43 43
       setDsb(true)
44 44
       // 调接口
45 45
       let timer = setInterval(() => {
@@ -48,14 +48,14 @@ export default (props) => {
48 48
         if (time === 0) {
49 49
           setDsb(false)
50 50
           setqCodeBtn('重新发送')
51
-          time=60
51
+          time = 60
52 52
           clearInterval(timer)
53 53
         }
54 54
       }, 1000)
55 55
 
56 56
     }
57 57
   }
58
-  const rulePhone=(val)=>{
58
+  const rulePhone = (val) => {
59 59
     if (!/^1[0-9]{10}$/.test(val)) {
60 60
       Taro.showToast({
61 61
         title: '请输入正确的11位手机号',
@@ -65,13 +65,13 @@ export default (props) => {
65 65
       return false
66 66
     } else return true
67 67
   }
68
-  const handleqCode=(e)=>{
68
+  const handleqCode = (e) => {
69 69
     if (e.detail.value) {
70 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 75
       if (!agreement) {
76 76
         Taro.showToast({
77 77
           title: '请确认下方协议',
@@ -81,7 +81,7 @@ export default (props) => {
81 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 85
         setPerson(res.person)
86 86
         Taro.showToast({
87 87
           title: '登录成功',
@@ -89,9 +89,9 @@ export default (props) => {
89 89
           duration: 1000
90 90
         })
91 91
         if (tab) {
92
-          setTimeout(()=>{
92
+          setTimeout(() => {
93 93
             Taro.redirectTo({ url: `/pages/index/index?tab=${tab}` });
94
-          },1000)
94
+          }, 1000)
95 95
         }
96 96
       }).catch((e) => {
97 97
         Taro.showToast({
@@ -108,7 +108,7 @@ export default (props) => {
108 108
     }
109 109
   }
110 110
   return (
111
-    <View className='page-index' style={{position:'absolute', zIndex:9999}}>
111
+    <View className='page-index' style={{ position: 'absolute', zIndex: 9999 }}>
112 112
       <View className='index-navbar'>
113 113
         <CustomNav home title='登录' />
114 114
       </View>
@@ -119,7 +119,7 @@ export default (props) => {
119 119
         <View className='loginCell'>
120 120
           <View className='loginHeader'>+86</View>
121 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 123
         </View>
124 124
         <View className='loginCell'>
125 125
           <View className='loginHeader'>
@@ -129,9 +129,15 @@ export default (props) => {
129 129
         </View>
130 130
         <View className='footer'>
131 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 141
           </View>
136 142
         </View>
137 143
       </View>

+ 2
- 2
src/pages/index/components/User/index.jsx Ver fichero

@@ -46,7 +46,7 @@ export default (props) => {
46 46
   }
47 47
   return (
48 48
     <ScrollView scrollY style={{ height: '100%' }}>
49
-      <View className='personTip'>该账号归{person.nickName || '张三'}所属</View>
49
+      <View className='personTip'>该账号归{person.nickName}pc用户名所属</View>
50 50
       <View className='userHead' onClick={handleAccount}>
51 51
         <Image src={userBgi} className='userBgi' />
52 52
         <View className='headcontent' >
@@ -88,7 +88,7 @@ export default (props) => {
88 88
           <MyCell icon={aboutUs} action={goto} user handleAction={handleAboutUs}>关于我们</MyCell>
89 89
         </View>
90 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 92
         </View>
93 93
         <View className='userBox'>
94 94
           <MyCell icon={feedback} action={goto} user handleAction={handleFeedback}>意见反馈</MyCell>

+ 0
- 1
src/pages/index/components/User/style.less Ver fichero

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

+ 6
- 0
src/pages/userInfo/index.jsx Ver fichero

@@ -87,6 +87,12 @@ export default withLayout((props) => {
87 87
           <Image src={avatar} className='avatarImg' />
88 88
           <View className='change'>更换头像</View>
89 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 96
         <View className='userCell'>
91 97
           <View>姓名:</View>
92 98
           <View style={{ display: 'flex', alignItems: 'center', height: '54px' }}>

+ 9
- 0
src/pages/userInfo/style.less Ver fichero

@@ -21,6 +21,15 @@
21 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 33
   .userCell{
25 34
     background: #FFF;
26 35
     box-shadow: 0px 2px 0px 0px rgba(0, 0, 0, 0.12);

+ 1
- 1
src/pages/versionUpdate/index.jsx Ver fichero

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

+ 18
- 15
src/utils/hooks/useLogin.js Ver fichero

@@ -1,28 +1,31 @@
1 1
 import Taro, { useRouter } from "@tarojs/taro";
2
-import { useModel } from '@/store'
2
+import { useModel } from "@/store";
3 3
 import { useMemo, useState, useEffect } from "react";
4 4
 
5 5
 const whiteList = [
6 6
   "/pages/index/index",
7
-  "/pages/Login/index"
8
-]
7
+  "/pages/Login/index",
8
+  "/pages/versionUpdate/index",
9
+];
9 10
 
10 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 22
   useEffect(() => {
19 23
     if (!isInWhiteList && !hasPhone) {
20
-      setLoginVisible(true)
24
+      setLoginVisible(true);
21 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
+};