四好公路
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

79 lines
2.4 KiB

import React, { useState } from 'react';
import Taro from '@tarojs/taro';
import { View, Button, Input, Form, Image } from '@tarojs/components';
import { AtDivider } from 'taro-ui';
import { login } from '@/actions/auth';
import { getLoginUrl } from '@/services/api';
import cfg from '../../../config';
import LoginBg from '../../../static/img/login/bg.png';
import PhoneIcon from '../../../static/img/login/phone.png';
import PswdIcon from '../../../static/img/login/pswd.png';
import './login.scss'
const { pcode } = cfg;
const LoginPage = (props) => {
Taro.hideHomeButton()
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const doLogin = () => {
login(getLoginUrl(), { username, password, pcode }).then(res => {
Taro.reLaunch({
url: '/pages/home/index'
});
})
}
const handleUsernameChange = (e) => {
setUsername(e.detail.value)
}
const handlePasswordChange = (e) => {
setPassword(e.detail.value)
}
return (
<View className='page'>
<Image className='bg' src={LoginBg} />
<View className='login'>
<View className='head'>
<View className='title'> </View>
</View>
<View className='form'>
<Form
onSubmit={doLogin}
>
<View className='form-item'>
<View className='form-label'>登录</View>
<View className='form-input'>
<Image className='icon-phone' src={PhoneIcon}></Image>
<Input name='username' value={username} placeholder='请输入账号' onInput={handleUsernameChange} />
</View>
</View>
<View className='form-item'>
<View className='form-input'>
<Image className='icon-pswd' src={PswdIcon}></Image>
<Input name='password' value={password} type='password' placeholder='请输入密码' onInput={handlePasswordChange} />
</View>
</View>
<View style='padding: 40rpx 30rpx' >
<Button type='primary' className='btn' formType='submit'>登录</Button>
</View>
</Form>
<View className='footer'>
<AtDivider content='忘记密码?请联系系统管理员' fontColor='#eee' lineColor='#fff' />
</View>
</View>
</View>
</View>
);
}
export default LoginPage;