forked from gxwebsoft/mp-10550
- 新增 CMS 文章查询接口 getCmsArticleByCode - 调整 UserCard 组件界面样式和逻辑-优化 BestSellers 商品展示组件 - 更新 IsDealer 组件支持网站字段配置 - 移除用户页面部分冗余代码和样式 - 增加主题样式支持和背景装饰元素 - 调整用户相关组件层级和定位样式
103 lines
2.8 KiB
TypeScript
103 lines
2.8 KiB
TypeScript
import {loginBySms} from "@/api/passport/login";
|
||
import {useState} from "react";
|
||
import Taro from '@tarojs/taro'
|
||
import {Popup} from '@nutui/nutui-react-taro'
|
||
import {UserParam} from "@/api/system/user/model";
|
||
import {Button} from '@nutui/nutui-react-taro'
|
||
import {Form, Input} from '@nutui/nutui-react-taro'
|
||
import {Copyright, Version} from "@/config/app";
|
||
const UserFooter = () => {
|
||
const [openLoginByPhone, setOpenLoginByPhone] = useState(false)
|
||
const [clickNum, setClickNum] = useState<number>(0)
|
||
const [FormData, setFormData] = useState<UserParam>(
|
||
{
|
||
phone: undefined,
|
||
password: undefined
|
||
}
|
||
)
|
||
|
||
const onLoginByPhone = () => {
|
||
setFormData({})
|
||
setClickNum(clickNum + 1);
|
||
if (clickNum > 10) {
|
||
setOpenLoginByPhone(true);
|
||
}
|
||
}
|
||
|
||
const closeLoginByPhone = () => {
|
||
setClickNum(0)
|
||
setOpenLoginByPhone(false)
|
||
}
|
||
|
||
// 提交表单
|
||
const submitByPhone = (values: any) => {
|
||
loginBySms({
|
||
phone: values.phone,
|
||
code: values.code
|
||
}).then(() => {
|
||
setOpenLoginByPhone(false);
|
||
setTimeout(() => {
|
||
Taro.reLaunch({
|
||
url: '/pages/index/index'
|
||
})
|
||
},1000)
|
||
})
|
||
}
|
||
|
||
return (
|
||
<>
|
||
<div className={'text-center py-4 w-full text-gray-300'} onClick={onLoginByPhone}>
|
||
<div className={'text-xs text-gray-400 py-1'}>当前版本:{Version}</div>
|
||
<div className={'text-xs text-gray-400 py-1'}>Copyright © { new Date().getFullYear() } {Copyright}</div>
|
||
</div>
|
||
|
||
<Popup
|
||
style={{width: '350px', padding: '10px'}}
|
||
visible={openLoginByPhone}
|
||
closeOnOverlayClick={false}
|
||
closeable={true}
|
||
onClose={closeLoginByPhone}
|
||
>
|
||
<Form
|
||
style={{width: '350px',padding: '10px'}}
|
||
divider
|
||
initialValues={FormData}
|
||
labelPosition="left"
|
||
onFinish={(values) => submitByPhone(values)}
|
||
footer={
|
||
<div
|
||
style={{
|
||
display: 'flex',
|
||
justifyContent: 'center',
|
||
width: '100%'
|
||
}}
|
||
>
|
||
<Button nativeType="submit" block style={{backgroundColor: '#000000',color: '#ffffff'}}>
|
||
提交
|
||
</Button>
|
||
</div>
|
||
}
|
||
>
|
||
<Form.Item
|
||
label={'手机号码'}
|
||
name="phone"
|
||
required
|
||
rules={[{message: '手机号码'}]}
|
||
>
|
||
<Input placeholder="请输入手机号码" maxLength={11} type="text"/>
|
||
</Form.Item>
|
||
<Form.Item
|
||
label={'短信验证码'}
|
||
name="code"
|
||
required
|
||
rules={[{message: '短信验证码'}]}
|
||
>
|
||
<Input placeholder="请输入短信验证码" maxLength={6} type="text"/>
|
||
</Form.Item>
|
||
</Form>
|
||
</Popup>
|
||
</>
|
||
)
|
||
}
|
||
export default UserFooter
|