From 9c92fd0d3347f96b3c2697ebf50ce79a9534c885 Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Sat, 12 Oct 2019 07:37:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E3=80=8A=E5=AE=9E=E5=90=8D?= =?UTF-8?q?=E8=AE=A4=E8=AF=81=E3=80=8B=E6=A8=A1=E5=9D=97=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E7=BA=A7=E8=AE=A4=E8=AF=81=E9=A1=B5=E9=9D=A2=E3=80=82=E5=B0=9A?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E5=B7=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/en-US.ts | 16 ++++- src/locales/zh-CN.ts | 12 ++++ src/pages/about/index.tsx | 3 +- src/pages/account/index.tsx | 2 +- src/pages/home/profile/index.tsx | 6 ++ src/pages/identity/index.tsx | 109 +++++++++++++++++++++++++++++++ src/pages/identity/model.ts | 52 +++++++++++++++ src/pages/identity/service.ts | 9 +++ src/pages/identity/style.less | 29 ++++++++ src/types/common.ts | 4 ++ 10 files changed, 237 insertions(+), 5 deletions(-) create mode 100644 src/pages/identity/index.tsx create mode 100644 src/pages/identity/model.ts create mode 100644 src/pages/identity/service.ts create mode 100644 src/pages/identity/style.less diff --git a/src/locales/en-US.ts b/src/locales/en-US.ts index ec0965d..af44a4f 100644 --- a/src/locales/en-US.ts +++ b/src/locales/en-US.ts @@ -154,9 +154,9 @@ export default { 'lgpwd.originPrompt': 'Please input your original login password', 'lgpwd.success': 'Login password is changed successfully', - 'profile.account': 'Account Settings', + 'profile.account': 'My Account', 'profile.system': 'System Settings', - 'profile.identity': 'KYC', + 'profile.identity': 'KYC Authentication', 'profile.share': 'Promotion', 'profile.msg': 'Message Center', 'profile.about': 'About VIC', @@ -170,6 +170,18 @@ export default { 'account.factor': '2FA', 'account.logout': 'Logout', 'account.confirm': 'Are you sure to logout?', + 'account.modifyNickname': 'Change nickname', + + 'identity.title': 'KYC 1st Level', + 'identity.realname': 'Real Name', + 'identity.nationality': 'Nationality', + 'identity.idtype': 'ID Type', + 'identity.idcode': 'ID Code', + 'identity.idphoto': 'ID Photo', + 'identity.idtypes': {idcard:'id card', passport:'passport'}, + 'identity.chooseIdtype': 'Type of id cards', + 'identity.real1btn': 'Submit', + 'identity.real2btn': 'Go to 2nd level of KYC', 'system.title': 'Settings', 'system.language': 'Language', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index f3f4914..0b4a918 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -170,6 +170,18 @@ export default { 'account.factor': '双因子验证(2FA)', 'account.logout': '退出登录', 'account.confirm': '是否确认退出登录?', + 'account.modifyNickname': '修改昵称', + + 'identity.title': '一级实名认证', + 'identity.realname': '实名', + 'identity.nationality': '国籍', + 'identity.idtype': '证件类型', + 'identity.idcode': '证件编号', + 'identity.idphoto': '证件照片', + 'identity.idtypes': {idcard:'身份证', passport:'护照'}, + 'identity.chooseIdtype': '选择证件类型', + 'identity.real1btn': '提交', + 'identity.real2btn': '进入二级实名认证', 'system.title': '我的设置', 'system.language': '语言偏好', diff --git a/src/pages/about/index.tsx b/src/pages/about/index.tsx index c8957ee..5291f46 100644 --- a/src/pages/about/index.tsx +++ b/src/pages/about/index.tsx @@ -133,8 +133,7 @@ const AboutPage: React.FC = () => {
{formatMessage({ id: 'about.contact' })} - 邮箱: {config.linkEmail} - 微信号: {config.linkSupport} + {config.linkHomeweb}

diff --git a/src/pages/account/index.tsx b/src/pages/account/index.tsx index 9ec0c4f..6d704b7 100644 --- a/src/pages/account/index.tsx +++ b/src/pages/account/index.tsx @@ -34,7 +34,7 @@ const AccountPage: React.FC = const editNameModal = ( dispatch({ type: 'account/onUpdateState', nameEditable: false })} onOk={() => dispatch({ type: 'account/changeName' })} diff --git a/src/pages/home/profile/index.tsx b/src/pages/home/profile/index.tsx index bf4c028..bc940e1 100644 --- a/src/pages/home/profile/index.tsx +++ b/src/pages/home/profile/index.tsx @@ -43,6 +43,12 @@ const ProfilePage: React.FC = ({ title="profile.account" onClick={() => dispatch(routerRedux.push('/account'))} /> + dispatch(routerRedux.push('/identity'))} + /> = ({ + dispatch, + user, + nameEditable, + nameInput, + nameSubmitting, + real1Submitting +}) => { + + const [idtypesVisible, setIdtypesVisible] = useState(false); + + const onItemSelected = (key: string) => { + setIdtypesVisible(false); +// dispatch({ type: 'user/changeIdtype', payload: key }); + }; + + const idtypeModal = ( + setIdtypesVisible(false)} + title={formatMessage({ id: 'identity.chooseIdtype' })} + /> + ); + + return ( +
+
+ {user &&
+ dispatch({ + type: 'identity/onUpdateState', + nameEditable: true, + nameInput: user.realname, + })} + /> + setNationsVisible(true)} + /> + setIdtypesVisible(true)} + /> + dispatch(routerRedux.push('/chphone'))} + /> + dispatch(routerRedux.push('/lgpwd'))} + /> +// 此处应当加一个label,显示后台驳回理由 + +
} +
+ ); +}; + +export default connect( + ({ user, account }: any) => ({ ...user, ...account }), +)(IdentityPage); diff --git a/src/pages/identity/model.ts b/src/pages/identity/model.ts new file mode 100644 index 0000000..e3ecbc5 --- /dev/null +++ b/src/pages/identity/model.ts @@ -0,0 +1,52 @@ +import { Model } from 'dva'; +import { changeName } from './service'; +import { message } from 'antd'; + +export interface IdentityModelState { + nameEditable: boolean; + nameInput: string; + nameSubmitting: boolean; + real1Submitting: boolean; +} + +const model: Model = { + namespace: 'identity', + + state: { + nameEditable: false, + nameInput: '', + nameSubmitting: false, + real1Submitting: false, + } as IdentityModelState, + + effects: { + *changeName(_, { put, all, call, select }) { + const { nameInput } = yield select((state: any) => state.account); + if (!nameInput) return; + + yield put({ type: 'onUpdateState', nameSubmitting: true }); + try { + yield call(changeName, nameInput); + yield all([ + put({ type: 'onUpdateState', nameInput: '', nameEditable: false }), + put({ type: 'user/updateUser', payload: { nickname: nameInput } }), + ]); + } catch (e) { + message.error(e.message); + } finally { + yield put({ type: 'onUpdateState', nameSubmitting: false }); + } + }, + }, + + reducers: { + onUpdateState(state, payload) { + return { + ...state, + ...payload, + }; + }, + }, +}; + +export default model; diff --git a/src/pages/identity/service.ts b/src/pages/identity/service.ts new file mode 100644 index 0000000..d3b482b --- /dev/null +++ b/src/pages/identity/service.ts @@ -0,0 +1,9 @@ +import http from '@/utils/http'; + +export async function changeName(nickname: string) { + const { ok, msg } = await http.post('/user/chnickname', { nickname }); + if (ok) { + return true; + } + throw Error(msg); +} diff --git a/src/pages/identity/style.less b/src/pages/identity/style.less new file mode 100644 index 0000000..cfe16dd --- /dev/null +++ b/src/pages/identity/style.less @@ -0,0 +1,29 @@ +@import '../../global.less'; + +.container { + height: 100%; + display: flex; + flex-direction: column; +} + +.header { + flex-shrink: 0; +} + +.content { + flex-grow: 1; + overflow: auto; + display: flex; + flex-direction: column; + align-items: stretch; + + :global { + .group { + margin: 8px; + } + } +} + +.logout { + margin: 16px 10px; +} diff --git a/src/types/common.ts b/src/types/common.ts index 0c1db23..5cec592 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -13,6 +13,10 @@ export interface User { token: string; inviteCode: string; inviter: string; + realname: string; + idcode: string; + idtype: string; + nationality: string; } export enum SendCodeType {