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