diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index 0bb8ecb..8bf61a8 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -124,6 +124,14 @@ export default { 'invite.step2': '注册', 'invite.step3': '领取奖金', + 'fundpwd.title': '修改资金密码', + 'fundpwd.origin': '验证原资金密码', + 'fundpwd.new': '设置新的资金密码', + 'fundpwd.confirm': '确认新的资金密码', + 'fundpwd.btn': '设置', + 'fundpwd.originPrompt': '请输入原始资金密码', + 'fundpwd.success': '资金密码修改成功', + 'profile.account': 'Account Settings', 'profile.system': 'System Settings', 'profile.identity': '实名认证', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index dc06f17..876679f 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -124,6 +124,14 @@ export default { 'invite.step2': '注册', 'invite.step3': '领取奖金', + 'fundpwd.title': '修改资金密码', + 'fundpwd.origin': '验证原资金密码', + 'fundpwd.new': '设置新的资金密码', + 'fundpwd.confirm': '确认新的资金密码', + 'fundpwd.btn': '设置', + 'fundpwd.originPrompt': '请输入原始资金密码', + 'fundpwd.success': '资金密码修改成功', + 'profile.account': '账户管理', 'profile.system': '系统设置', 'profile.identity': '实名认证', diff --git a/src/pages/account/index.tsx b/src/pages/account/index.tsx index 9577206..90e86c6 100644 --- a/src/pages/account/index.tsx +++ b/src/pages/account/index.tsx @@ -4,7 +4,7 @@ * - ./src/pages/routes */ import React from 'react'; -import { connect, DispatchProp } from 'dva'; +import { connect, DispatchProp, routerRedux } from 'dva'; import { formatMessage } from 'umi-plugin-locale'; import { Button, Modal, Input } from 'antd'; import Header from '@/components/Header'; @@ -76,12 +76,12 @@ const AccountPage: React.FC = /> dispatch(routerRedux.push('/fundpwd'))} /> + + ); + } + + return ( +
+
+ +
+ {body} +
+
+ ); +}; + +export default connect( + ({ fundpwd }: any) => ({ ...fundpwd }), +)(FundpwdPage); diff --git a/src/pages/fundpwd/model.ts b/src/pages/fundpwd/model.ts new file mode 100644 index 0000000..2b2bc67 --- /dev/null +++ b/src/pages/fundpwd/model.ts @@ -0,0 +1,92 @@ +import { Model, routerRedux } from "dva"; +import _ from 'lodash'; +import { PageState } from '@/types/common'; +import { checkFundPwd } from '@/services/common'; +import { message } from 'antd'; +import { formatMessage } from 'umi-plugin-locale'; +import { validPwd } from '@/utils/validate'; +import { changeFundPwd } from './service'; + +export interface FundpwdModelState { + pageState: PageState; + originVisible: boolean; + + origin: string; + newPwd: string; + confirm: string; + submitting: boolean; +} + +const initState: FundpwdModelState = { + pageState: PageState.Pending, + originVisible: false, + + origin: '', + newPwd: '', + confirm: '', + submitting: false, +}; + +const model: Model = { + namespace: 'fundpwd', + + state: initState, + + effects: { + *load(_, { put, call }) { + yield put({ type: 'onUpdateState', pageState: PageState.Pending }); + try { + const settled = yield call(checkFundPwd); + yield put({ + type: 'onUpdateState', + pageState: PageState.Success, + originVisible: settled, + origin: '', + newPwd: '', + confirm: '', + submitting: false, + }); + } catch (e) { + yield put({ + type: 'onUpdateState', + pageState: PageState.Failure, + }); + } + }, + + *submit(_, { put, call, select }) { + const { + originVisible, + origin, + newPwd, + confirm, + submitting, + } = (yield select((state: any) => state.fundpwd)) as FundpwdModelState; + if (submitting) return; + if (originVisible && !origin) return message.warn(formatMessage({ id: 'fundpwd.originPrompt' })); + if (!validPwd(newPwd)) return message.warn(formatMessage({ id: 'check.msgPwd' })); + if (confirm !== newPwd) return message.warn(formatMessage({ id: 'check.msgConfirm' })); + yield put({ type: 'onUpdateState', submitting: true }); + try { + yield call(changeFundPwd, newPwd, origin); + yield put(routerRedux.goBack()); + message.success(formatMessage({ id: 'fundpwd.success' })); + } catch (e) { + message.error(e.message); + } finally { + yield put({ type: 'onUpdateState', submitting: false }) + } + }, + }, + + reducers: { + onUpdateState(state, payload) { + return { + ...state, + ...payload, + }; + }, + }, +}; + +export default model; diff --git a/src/pages/fundpwd/service.ts b/src/pages/fundpwd/service.ts new file mode 100644 index 0000000..b5d4a5d --- /dev/null +++ b/src/pages/fundpwd/service.ts @@ -0,0 +1,10 @@ +import http from '@/utils/http'; + +export async function changeFundPwd(newPassword: string, password?: string) { + const { ok, msg } = await http.post('/user/chFundPwd', { + password, + newPassword, + }); + if (ok) return; + throw Error(msg); +} diff --git a/src/pages/fundpwd/style.less b/src/pages/fundpwd/style.less new file mode 100644 index 0000000..219bd25 --- /dev/null +++ b/src/pages/fundpwd/style.less @@ -0,0 +1,30 @@ + +@import '../../global.less'; + +.container { + height: 100%; + background: white; + position: relative; + display: flex; + flex-direction: column; +} + +.body { + flex-grow: 1; + overflow-x: hidden; + overflow-y: auto; + display: flex; + flex-direction: column; + align-items: stretch; +} + +.none { + text-align: center; + width: 100%; + padding-top: 40%; +} + +.input { + margin: 10px 20px; + width: auto; +} diff --git a/src/pages/home/fund/model.ts b/src/pages/home/fund/model.ts index b94aca4..a92ac98 100644 --- a/src/pages/home/fund/model.ts +++ b/src/pages/home/fund/model.ts @@ -4,6 +4,7 @@ import { Journal, FundBasic } from '@/types/common'; import { getFundList } from './service'; import { checkFundPwd, getFundBasic } from '@/services/common'; import { formatMessage } from 'umi-plugin-locale'; +import { dispatch } from '@/utils/utils'; export interface HomeFundModelState { refreshingList: boolean; @@ -118,7 +119,7 @@ const FundModel: Model = { cancelText: formatMessage({ id: 'common.cancel' }), title: formatMessage({ id: 'common.prompt' }), content: formatMessage({ id: 'home.fund.prompt' }), - onOk: () => { message.warn('暂未完成,请再次点击'); }, + onOk: () => dispatch(routerRedux.push('/fundpwd')), }); } } catch (e) { diff --git a/src/pages/mine/style.less b/src/pages/mine/style.less index 23cb7fa..b9117a2 100644 --- a/src/pages/mine/style.less +++ b/src/pages/mine/style.less @@ -18,7 +18,8 @@ .body { flex-grow: 1; - overflow: auto; + overflow-x: hidden; + overflow-y: auto; } .none {