change stuid&passwd login to scan QR Code
parent
7b62c5e473
commit
8a60d4c48f
|
|
@ -72,7 +72,8 @@ export default class DetailFramework extends Component<
|
|||
content={pt.get().actIndicator.loading}
|
||||
></AtActivityIndicator>
|
||||
);
|
||||
} else if (!this.state.rs.success) {
|
||||
}
|
||||
if (!this.state.rs.success) {
|
||||
return (
|
||||
<AtToast
|
||||
isOpened
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, ReactNode } from 'react';
|
||||
import { AtForm, AtInput, AtButton, AtMessage } from 'taro-ui';
|
||||
import { AtButton, AtMessage } from 'taro-ui';
|
||||
import Taro from '@tarojs/taro';
|
||||
import pt from '@/plain-text';
|
||||
import { memberLogin, memberLogout } from '@/service/memberLogin';
|
||||
|
|
@ -11,8 +11,6 @@ const logInterval = 5000;
|
|||
|
||||
export default class UserMemberPage extends Component {
|
||||
state = {
|
||||
stuid: '',
|
||||
passwd: '',
|
||||
isLoading: false,
|
||||
isDisable: false,
|
||||
};
|
||||
|
|
@ -21,34 +19,11 @@ export default class UserMemberPage extends Component {
|
|||
title: pt.get().navBar.user.memberLogin,
|
||||
});
|
||||
}
|
||||
handleChangeStuid(stuid: string) {
|
||||
this.setState({
|
||||
stuid: stuid,
|
||||
});
|
||||
return stuid;
|
||||
}
|
||||
handleChangePasswd(passwd: string) {
|
||||
this.setState({
|
||||
passwd: passwd,
|
||||
});
|
||||
return passwd;
|
||||
}
|
||||
onSubmit() {
|
||||
|
||||
onLogin() {
|
||||
this.setState({
|
||||
isDisable: true,
|
||||
});
|
||||
if (this.state.stuid == '' || this.state.passwd == '') {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.submitText.blank,
|
||||
type: 'error',
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
isDisable: false,
|
||||
});
|
||||
}, logInterval);
|
||||
return;
|
||||
}
|
||||
memberLogin(this);
|
||||
setTimeout(() => {
|
||||
this.setState({
|
||||
|
|
@ -72,37 +47,15 @@ export default class UserMemberPage extends Component {
|
|||
render(): ReactNode {
|
||||
return !wechatUser.getAccess() ? (
|
||||
<View style={{ marginTop: '30rpx', width: '94%', marginLeft: '3%' }}>
|
||||
<AtForm onSubmit={this.onSubmit.bind(this)}>
|
||||
<AtMessage />
|
||||
<AtInput
|
||||
required
|
||||
name='stuid'
|
||||
title={pt.get().memberPage.stuidText.title}
|
||||
type='number'
|
||||
clear
|
||||
placeholder={pt.get().memberPage.stuidText.placeholder}
|
||||
value={this.state.stuid}
|
||||
onChange={this.handleChangeStuid.bind(this)}
|
||||
/>
|
||||
<AtInput
|
||||
clear
|
||||
required
|
||||
name='name'
|
||||
title={pt.get().memberPage.passwdText.title}
|
||||
type='password'
|
||||
placeholder={pt.get().memberPage.passwdText.placeholder}
|
||||
value={this.state.passwd}
|
||||
onChange={this.handleChangePasswd.bind(this)}
|
||||
/>
|
||||
<AtButton
|
||||
loading={this.state.isLoading}
|
||||
formType='submit'
|
||||
type='primary'
|
||||
disabled={this.state.isDisable}
|
||||
>
|
||||
{pt.get().button.buttonText.login}
|
||||
</AtButton>
|
||||
</AtForm>
|
||||
<AtMessage />
|
||||
<AtButton
|
||||
loading={this.state.isLoading}
|
||||
type='primary'
|
||||
disabled={this.state.isDisable}
|
||||
onClick={this.onLogin.bind(this)}
|
||||
>
|
||||
{pt.get().button.memberText.auth}
|
||||
</AtButton>
|
||||
</View>
|
||||
) : (
|
||||
<View style={{ marginTop: '30rpx', width: '94%', marginLeft: '3%' }}>
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ export default class UserPage extends Component {
|
|||
className='at-row at-row__justify--center at-row__align--center'
|
||||
style='height:120rpx;color:#696969;'
|
||||
>
|
||||
<Text style={{ fontSize: '32rpx' }}> EVA Notify v1.0.0</Text>
|
||||
<Text style={{ fontSize: '32rpx' }}> EVA Eta v1.0.0</Text>
|
||||
</View>
|
||||
<AtList>
|
||||
<AtListItem
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ export interface ButtonText {
|
|||
error: string;
|
||||
blank: string;
|
||||
};
|
||||
memberText: {
|
||||
auth: string;
|
||||
};
|
||||
loginText: {
|
||||
success: string;
|
||||
error: string;
|
||||
|
|
@ -33,6 +36,9 @@ export const buttonZhCn: ButtonText = {
|
|||
error: '提交失败:',
|
||||
blank: '请填写完整!',
|
||||
},
|
||||
memberText: {
|
||||
auth: '协会统一身份认证登录',
|
||||
},
|
||||
loginText: {
|
||||
success: '登录成功',
|
||||
error: '登录失败',
|
||||
|
|
@ -56,6 +62,9 @@ export const buttonEnUs: ButtonText = {
|
|||
error: 'Error: ',
|
||||
blank: 'Please fill in the blanks!',
|
||||
},
|
||||
memberText: {
|
||||
auth: 'EVA Auth Login Entry',
|
||||
},
|
||||
loginText: {
|
||||
success: 'Login Success',
|
||||
error: 'Login Failed',
|
||||
|
|
|
|||
|
|
@ -8,39 +8,50 @@ export function memberLogin(that: UserMemberPage) {
|
|||
that.setState({
|
||||
isLoading: true,
|
||||
});
|
||||
Taro.request({
|
||||
url: getUrl('/member/login'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: wechatUser.getToken(),
|
||||
name: that.state.stuid,
|
||||
phone: that.state.passwd,
|
||||
Taro.scanCode({
|
||||
onlyFromCamera: true,
|
||||
success: () => {
|
||||
Taro.request({
|
||||
url: getUrl('/member/login'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: wechatUser.getToken(),
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
that.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
if (res.data.success) {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.loginText.success,
|
||||
type: 'success',
|
||||
});
|
||||
wechatUser.setInfo(res.data.data as UserInfo);
|
||||
wechatUser.setAccess(true);
|
||||
Taro.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
} else {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.loginText.fail,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
that.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.loginText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
});
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res.data);
|
||||
that.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
if (res.data.success) {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.loginText.success,
|
||||
type: 'success',
|
||||
});
|
||||
wechatUser.setInfo(res.data.data as UserInfo);
|
||||
wechatUser.setAccess(true);
|
||||
Taro.reLaunch({
|
||||
url: '/pages/index/index',
|
||||
});
|
||||
} else {
|
||||
Taro.atMessage({
|
||||
message: pt.get().button.loginText.fail,
|
||||
type: 'error',
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
fail: (err) => {
|
||||
that.setState({
|
||||
isLoading: false,
|
||||
});
|
||||
|
|
@ -48,7 +59,8 @@ export function memberLogin(that: UserMemberPage) {
|
|||
message: pt.get().button.loginText.error + err.toString(),
|
||||
type: 'error',
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function memberLogout(that: UserMemberPage) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue