Browse Source

添加修改密码、邮箱、名称

main
mac 4 months ago
parent
commit
c3735ef525
  1. 6
      src/api/index.ts
  2. 92
      src/components/Header/index.tsx
  3. 13
      src/pages/vip-manage/proxy-list.tsx

6
src/api/index.ts

@ -194,4 +194,10 @@ export default {
set_adminPermissionList(data: object) {
return $axios.post('/admin/setPermissions', data)
},
change_loginPwd(data: object) {
return $axios.post('/admin/revisePassword', data)
},
change_emailAndName(data: object) {
return $axios.post('/admin/userEmailAndName', data)
}
}

92
src/components/Header/index.tsx

@ -1,11 +1,12 @@
import React, { useEffect, FC } from 'react'
import React, { useEffect, FC, useState } from 'react'
import { useHistory } from 'react-router-dom'
import { Menu, Dropdown, Layout } from 'antd'
import { Menu, Dropdown, Layout, Modal, Form, Input, Button, notification } from 'antd'
import { MenuUnfoldOutlined, MenuFoldOutlined } from '@ant-design/icons'
import Breadcrumb from '@/components/BreadCrumb'
import { connect } from 'react-redux'
import * as actions from '@/store/actions'
import style from './Header.module.less'
import api from '@/api'
interface Props extends ReduxProps { }
@ -13,6 +14,9 @@ const Header: FC<Props> = ({
storeData: { collapsed, theme, userInfo },
setStoreData
}) => {
const [form] = Form.useForm()
const [visible, setVisible] = useState(false)
const history = useHistory()
const { userName = '-' } = userInfo
const firstWord = userName.slice(0, 1)
@ -26,8 +30,25 @@ const Header: FC<Props> = ({
setStoreData('SET_THEME', themes)
}
const onFinish = async (values) => {
const res: any = await api.change_loginPwd(values)
if (res.code === 0) {
form.resetFields()
setVisible(false)
notification.success({
message: '修改成功,请重新登录'
})
await setStoreData('SET_USERINFO', {})
localStorage.setItem('permissions', '')
history.replace({ pathname: '/login' })
}
}
const menu = (
<Menu>
<Menu.Item onClick={() => setVisible(true)}>
<span></span>
</Menu.Item>
<Menu.Item onClick={logout}>
<span>退</span>
</Menu.Item>
@ -71,25 +92,54 @@ const Header: FC<Props> = ({
}, [theme])
return (
<Layout.Header className={style.header}>
<div className={style.toggleMenu} onClick={toggle}>
{collapsed ? (
<MenuUnfoldOutlined className={style.trigger} />
) : (
<MenuFoldOutlined className={style.trigger} />
)}
</div>
<Breadcrumb />
<Dropdown className={`fr ${style.content}`} overlay={menu}>
<span className={style.user}>
<span className="avart">{firstWord}</span>
<span>{userName}</span>
</span>
</Dropdown>
<Dropdown overlay={changeMenu}>
<div title="更换主题" className="fr webTheme" />
</Dropdown>
</Layout.Header>
<>
<Layout.Header className={style.header}>
<div className={style.toggleMenu} onClick={toggle}>
{collapsed ? (
<MenuUnfoldOutlined className={style.trigger} />
) : (
<MenuFoldOutlined className={style.trigger} />
)}
</div>
<Breadcrumb />
<Dropdown className={`fr ${style.content}`} overlay={menu}>
<span className={style.user}>
<span className="avart">{firstWord}</span>
<span>{userName}</span>
</span>
</Dropdown>
<Dropdown overlay={changeMenu}>
<div title="更换主题" className="fr webTheme" />
</Dropdown>
</Layout.Header>
<Modal visible={visible} onCancel={() => setVisible(false)} title="修改密码" footer={() => null}>
<Form form={form} onFinish={onFinish}>
<Form.Item label="旧密码" rules={[{ required: true, message: '请输入旧密码' }]} name="old_password">
<Input.Password placeholder='请输入旧密码' />
</Form.Item>
<Form.Item label="新密码" rules={[{ required: true, message: '请输入新密码' }]} name="new_password">
<Input.Password placeholder='请输入新密码' />
</Form.Item>
<Form.Item label="确认密码" rules={[{ required: true, message: '确认新密码' }, ({ getFieldValue }) => ({
validator(_, value) {
if (!value || getFieldValue('new_password') === value) {
return Promise.resolve();
}
return Promise.reject(new Error('两个密码不匹配!'));
},
}),]} name="confrim_password">
<Input.Password placeholder='确认新密码' />
</Form.Item>
<Form.Item label='操作' style={{ display: 'flex' }}>
<Button onClick={() => {
setVisible(false)
form.resetFields()
}}></Button>
<Button htmlType='submit' type='primary' style={{ marginLeft: 20 }}></Button>
</Form.Item>
</Form>
</Modal>
</>
)
}
export default connect(

13
src/pages/vip-manage/proxy-list.tsx

@ -2,7 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
import api from "@/api";
import MyTable from "@/components/MyTable";
import { DeleteFilled, EditOutlined, RightCircleFilled, SolutionOutlined, StopTwoTone } from "@ant-design/icons";
import { Button, Form, Input, Modal, Popconfirm, Radio, Select, Switch, notification } from "antd";
import { Button, Form, Input, Modal, Popconfirm, Radio, Select, Switch, message, notification } from "antd";
import { getBaseUrl, getOriginUrl } from "@/utils/axios";
const ProxyList = () => {
@ -71,7 +71,6 @@ const ProxyList = () => {
items: [
{ label: "当前余额", component: <Input value={currentAccount.current.balance || ''} disabled /> },
{ label: "加减金额", name: "balance", rules: [{ required: true, message: '请输入加减金额' }] },
{ label: "邮箱通知", name: "email_flag", initialValue: true, valuePropName: "checked", component: <Switch /> }
]
},
assets: {
@ -91,14 +90,19 @@ const ProxyList = () => {
onFinish: (values) => onFinish(values, api.set_loginPwd, '重置成功'),
items: [
{ label: "登录密码", name: "password", rules: [{ required: true, message: '请输入要修改的登录密码' }] },
{ label: "邮箱通知", name: "email_flag", initialValue: true, valuePropName: "checked", component: <Switch /> }
]
},
txPwd: {
onFinish: (values) => onFinish(values, api.set_txPwd, '重置成功'),
items: [
{ label: "交易密码", name: "account_password", rules: [{ required: true, message: '请输入要修改的交易密码' }] },
{ label: "邮箱通知", name: "email_flag", initialValue: true, valuePropName: "checked", component: <Switch /> }
]
},
email: {
onFinish: (values) => onFinish(values, api.change_emailAndName, '修改成功'),
items: [
{ label: "名称", name: "name", rules: [{ required: true, message: '请输入名称' }], initialValue: currentAccount.current.name || '' },
{ label: "邮箱", name: "email", rules: [{ required: true, message: '请输入邮箱', }, { type: 'email', message: '邮箱格式错误' }], initialValue: currentAccount.current.email || '' },
]
}
};
@ -246,6 +250,7 @@ const ProxyList = () => {
<Radio.Button value="lv"></Radio.Button>
<Radio.Button value="pwd"></Radio.Button>
<Radio.Button value="txPwd"></Radio.Button>
<Radio.Button value="email"></Radio.Button>
</Radio.Group>
<div style={{ marginTop: 20 }}>
{renderForm(path)}

Loading…
Cancel
Save