|
@@ -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>
|