Commit 7ad4cee79ade617a13358f7417ce3e1182c1027f

Authored by chen-xt
Committed by GitHub
1 parent 261936b1

feat: add accountSetting page (#85)

mock/demo/account.ts 0 → 100644
  1 +import { MockMethod } from 'vite-plugin-mock';
  2 +import { resultSuccess } from '../_util';
  3 +
  4 +const userInfo = {
  5 + name: 'Serati Ma',
  6 + userid: '00000001',
  7 + email: 'antdesign@alipay.com',
  8 + signature: '海纳百川,有容乃大',
  9 + introduction: '微笑着,努力着,欣赏着',
  10 + title: '交互专家',
  11 + group: '蚂蚁集团-某某某事业群-某某平台部-某某技术部-UED',
  12 + tags: [
  13 + {
  14 + key: '0',
  15 + label: '很有想法的',
  16 + },
  17 + {
  18 + key: '1',
  19 + label: '专注设计',
  20 + },
  21 + {
  22 + key: '2',
  23 + label: '辣~',
  24 + },
  25 + {
  26 + key: '3',
  27 + label: '大长腿',
  28 + },
  29 + {
  30 + key: '4',
  31 + label: '川妹子',
  32 + },
  33 + {
  34 + key: '5',
  35 + label: '海纳百川',
  36 + },
  37 + ],
  38 + notifyCount: 12,
  39 + unreadCount: 11,
  40 + country: 'China',
  41 + province: {
  42 + label: '浙江省',
  43 + value: '330000',
  44 + },
  45 + city: {
  46 + label: '杭州市',
  47 + value: '330100',
  48 + },
  49 + address: '西湖区工专路 77 号',
  50 + phone: '0752-268888888',
  51 +};
  52 +
  53 +export default [
  54 + {
  55 + url: '/api/account/getAccountInfo',
  56 + timeout: 1000,
  57 + method: 'get',
  58 + response: () => {
  59 + return resultSuccess(userInfo);
  60 + },
  61 + },
  62 +] as MockMethod[];
... ...
src/api/demo/account.ts 0 → 100644
  1 +import { defHttp } from '/@/utils/http/axios';
  2 +import { GetAccountInfoModel } from './model/accountModel';
  3 +
  4 +enum Api {
  5 + ACCOUNT_INFO = '/account/getAccountInfo',
  6 + SECURE_LIST = '/account/getSecureList',
  7 +}
  8 +
  9 +// 获取个人中心--基础设置内容
  10 +export function accountInfoApi(params: any) {
  11 + return defHttp.request<GetAccountInfoModel>({
  12 + url: Api.ACCOUNT_INFO,
  13 + method: 'GET',
  14 + params,
  15 + });
  16 +}
... ...
src/api/demo/model/accountModel.ts 0 → 100644
  1 +export interface GetAccountInfoModel {
  2 + email: string;
  3 + name: string;
  4 + introduction: string;
  5 + phone: string;
  6 + address: string;
  7 +}
... ...
src/router/menus/modules/demo/page.ts
... ... @@ -51,6 +51,19 @@ const menu: MenuModule = {
51 51 },
52 52 ],
53 53 },
  54 + {
  55 + path: 'account',
  56 + name: '个人页',
  57 + tag: {
  58 + content: 'new',
  59 + },
  60 + children: [
  61 + {
  62 + path: 'setting',
  63 + name: '个人设置',
  64 + },
  65 + ],
  66 + },
54 67 ],
55 68 },
56 69 };
... ...
src/router/routes/modules/demo/page.ts
... ... @@ -116,6 +116,27 @@ const page: AppRouteModule = {
116 116 ],
117 117 },
118 118 // =============================exception end=============================
  119 +
  120 + // =============================account start=============================
  121 + {
  122 + path: '/account',
  123 + name: 'AccountPage',
  124 + redirect: '/page-demo/account/setting',
  125 + meta: {
  126 + title: '个人页',
  127 + },
  128 + children: [
  129 + {
  130 + path: 'setting',
  131 + name: 'AccountSettingPage',
  132 + component: () => import('/@/views/demo/page/account/setting/index.vue'),
  133 + meta: {
  134 + title: '个人设置',
  135 + },
  136 + },
  137 + ],
  138 + },
  139 + // =============================account end=============================
119 140 ],
120 141 };
121 142  
... ...
src/views/demo/page/account/setting/AccountBind.vue 0 → 100644
  1 +<template>
  2 + <CollapseContainer title="账号绑定" :canExpan="false">
  3 + <List>
  4 + <template v-for="item in list" :key="item.key">
  5 + <ListItem>
  6 + <ListItemMeta>
  7 + <template #avatar>
  8 + <Icon v-if="item.avatar" class="avatar" :icon="item.avatar" :color="item.color" />
  9 + </template>
  10 + <template #title>
  11 + {{ item.title }}
  12 + <div v-if="item.extra" class="extra"> {{ item.extra }} </div>
  13 + </template>
  14 + <template #description>
  15 + <div>{{ item.description }} </div>
  16 + </template>
  17 + </ListItemMeta>
  18 + </ListItem>
  19 + </template>
  20 + </List>
  21 + </CollapseContainer>
  22 +</template>
  23 +<script lang="ts">
  24 + import { List } from 'ant-design-vue';
  25 + import { defineComponent, onMounted } from 'vue';
  26 + import { CollapseContainer } from '/@/components/Container/index';
  27 + import Icon from '/@/components/Icon/index';
  28 +
  29 + import { accountBindList } from './data';
  30 +
  31 + export default defineComponent({
  32 + components: {
  33 + CollapseContainer,
  34 + List,
  35 + ListItem: List.Item,
  36 + ListItemMeta: List.Item.Meta,
  37 + Icon,
  38 + },
  39 + setup() {
  40 + return {
  41 + list: accountBindList,
  42 + };
  43 + },
  44 + });
  45 +</script>
  46 +<style lang="less" scoped>
  47 + .avatar {
  48 + font-size: 40px !important;
  49 + }
  50 +
  51 + .extra {
  52 + float: right;
  53 + margin-top: 10px;
  54 + margin-right: 30px;
  55 + font-weight: normal;
  56 + color: #1890ff;
  57 + cursor: pointer;
  58 + }
  59 +</style>
... ...
src/views/demo/page/account/setting/BaseSetting.vue 0 → 100644
  1 +<template>
  2 + <CollapseContainer title="基本设置" :canExpan="false">
  3 + <BasicForm @register="register" />
  4 + <Button type="primary" @click="handleSubmit">更新基本信息</Button>
  5 + </CollapseContainer>
  6 +</template>
  7 +<script lang="ts">
  8 + import { Button } from 'ant-design-vue';
  9 + import { defineComponent, onMounted } from 'vue';
  10 + import { BasicForm, useForm } from '/@/components/Form/index';
  11 + import { CollapseContainer } from '/@/components/Container/index';
  12 +
  13 + import { useMessage } from '/@/hooks/web/useMessage';
  14 +
  15 + import { accountInfoApi } from '/@/api/demo/account';
  16 + import { baseSetschemas } from './data';
  17 +
  18 + export default defineComponent({
  19 + components: { BasicForm, CollapseContainer, Button },
  20 + setup() {
  21 + const { createMessage } = useMessage();
  22 +
  23 + const [register, { setFieldsValue }] = useForm({
  24 + labelWidth: 120,
  25 + schemas: baseSetschemas,
  26 + showActionButtonGroup: false,
  27 + });
  28 +
  29 + onMounted(async () => {
  30 + const data = await accountInfoApi();
  31 + setFieldsValue(data);
  32 + });
  33 +
  34 + return {
  35 + register,
  36 + handleSubmit: () => {
  37 + createMessage.success('更新成功!');
  38 + },
  39 + };
  40 + },
  41 + });
  42 +</script>
... ...
src/views/demo/page/account/setting/MsgNotify.vue 0 → 100644
  1 +<template>
  2 + <CollapseContainer title="新消息通知" :canExpan="false">
  3 + <List>
  4 + <template v-for="item in list" :key="item.key">
  5 + <ListItem>
  6 + <ListItemMeta>
  7 + <template #title>
  8 + {{ item.title }}
  9 + <Switch
  10 + class="extra"
  11 + checked-children="开"
  12 + un-checked-children="关"
  13 + default-checked
  14 + />
  15 + </template>
  16 + <template #description>
  17 + <div>{{ item.description }} </div>
  18 + </template>
  19 + </ListItemMeta>
  20 + </ListItem>
  21 + </template>
  22 + </List>
  23 + </CollapseContainer>
  24 +</template>
  25 +<script lang="ts">
  26 + import { List, Switch } from 'ant-design-vue';
  27 + import { defineComponent, onMounted } from 'vue';
  28 + import { CollapseContainer } from '/@/components/Container/index';
  29 +
  30 + import { msgNotifyList } from './data';
  31 +
  32 + export default defineComponent({
  33 + components: {
  34 + CollapseContainer,
  35 + List,
  36 + ListItem: List.Item,
  37 + ListItemMeta: List.Item.Meta,
  38 + Switch,
  39 + },
  40 + setup() {
  41 + return {
  42 + list: msgNotifyList,
  43 + };
  44 + },
  45 + });
  46 +</script>
  47 +<style lang="less" scoped>
  48 + .extra {
  49 + float: right;
  50 + margin-top: 10px;
  51 + margin-right: 30px;
  52 + }
  53 +</style>
... ...
src/views/demo/page/account/setting/SecureSetting.vue 0 → 100644
  1 +<template>
  2 + <CollapseContainer title="安全设置" :canExpan="false">
  3 + <List>
  4 + <template v-for="item in list" :key="item.key">
  5 + <ListItem>
  6 + <ListItemMeta>
  7 + <template #title>
  8 + {{ item.title }}
  9 + <div class="extra" v-if="item.extra"> {{ item.extra }} </div>
  10 + </template>
  11 + <template #description>
  12 + <div>{{ item.description }} </div>
  13 + </template>
  14 + </ListItemMeta>
  15 + </ListItem>
  16 + </template>
  17 + </List>
  18 + </CollapseContainer>
  19 +</template>
  20 +<script lang="ts">
  21 + import { List } from 'ant-design-vue';
  22 + import { defineComponent, onMounted } from 'vue';
  23 + import { CollapseContainer } from '/@/components/Container/index';
  24 +
  25 + import { secureSettingList } from './data';
  26 +
  27 + export default defineComponent({
  28 + components: { CollapseContainer, List, ListItem: List.Item, ListItemMeta: List.Item.Meta },
  29 + setup() {
  30 + return {
  31 + list: secureSettingList,
  32 + };
  33 + },
  34 + });
  35 +</script>
  36 +<style lang="less" scoped>
  37 + .extra {
  38 + float: right;
  39 + margin-top: 10px;
  40 + margin-right: 30px;
  41 + font-weight: normal;
  42 + color: #1890ff;
  43 + cursor: pointer;
  44 + }
  45 +</style>
... ...
src/views/demo/page/account/setting/data.ts 0 → 100644
  1 +import { FormSchema } from '/@/components/Form/index';
  2 +
  3 +export interface ListItem {
  4 + key: string;
  5 + title: string;
  6 + description: string;
  7 + extra?: string;
  8 + avatar?: string;
  9 + color?: string;
  10 +}
  11 +
  12 +// tab的list
  13 +export const settingList = [
  14 + {
  15 + key: '1',
  16 + name: '基本设置',
  17 + component: 'BaseSetting',
  18 + },
  19 + {
  20 + key: '2',
  21 + name: '安全设置',
  22 + component: 'SecureSetting',
  23 + },
  24 + {
  25 + key: '3',
  26 + name: '账号绑定',
  27 + component: 'AccountBind',
  28 + },
  29 + {
  30 + key: '4',
  31 + name: '新消息通知',
  32 + component: 'MsgNotify',
  33 + },
  34 +];
  35 +
  36 +// 基础设置 form
  37 +export const baseSetschemas: FormSchema[] = [
  38 + {
  39 + field: 'email',
  40 + component: 'Input',
  41 + label: '邮箱',
  42 + colProps: { span: 18 },
  43 + },
  44 + {
  45 + field: 'name',
  46 + component: 'Input',
  47 + label: '昵称',
  48 + colProps: { span: 18 },
  49 + },
  50 + {
  51 + field: 'introduction',
  52 + component: 'InputTextArea',
  53 + label: '个人简介',
  54 + colProps: { span: 18 },
  55 + },
  56 + {
  57 + field: 'phone',
  58 + component: 'Input',
  59 + label: '联系电话',
  60 + colProps: { span: 18 },
  61 + },
  62 + {
  63 + field: 'address',
  64 + component: 'Input',
  65 + label: '所在地区',
  66 + colProps: { span: 18 },
  67 + },
  68 +];
  69 +
  70 +// 安全设置 list
  71 +export const secureSettingList: ListItem[] = [
  72 + {
  73 + key: '1',
  74 + title: '账户密码',
  75 + description: '当前密码强度::强',
  76 + extra: '修改',
  77 + },
  78 + {
  79 + key: '2',
  80 + title: '密保手机',
  81 + description: '已绑定手机::138****8293',
  82 + extra: '修改',
  83 + },
  84 + {
  85 + key: '3',
  86 + title: '密保问题',
  87 + description: '未设置密保问题,密保问题可有效保护账户安全',
  88 + extra: '修改',
  89 + },
  90 + {
  91 + key: '4',
  92 + title: '备用邮箱',
  93 + description: '已绑定邮箱::ant***sign.com',
  94 + extra: '修改',
  95 + },
  96 + {
  97 + key: '5',
  98 + title: 'MFA 设备',
  99 + description: '未绑定 MFA 设备,绑定后,可以进行二次确认',
  100 + extra: '修改',
  101 + },
  102 +];
  103 +
  104 +// 账号绑定 list
  105 +export const accountBindList: ListItem[] = [
  106 + {
  107 + key: '1',
  108 + title: '绑定淘宝',
  109 + description: '当前未绑定淘宝账号',
  110 + extra: '绑定',
  111 + avatar: 'ant-design:taobao-outlined',
  112 + color: '#ff4000',
  113 + },
  114 + {
  115 + key: '2',
  116 + title: '绑定支付宝',
  117 + description: '当前未绑定支付宝账号',
  118 + extra: '绑定',
  119 + avatar: 'ant-design:alipay-outlined',
  120 + color: '#2eabff',
  121 + },
  122 + {
  123 + key: '3',
  124 + title: '绑定钉钉',
  125 + description: '当前未绑定钉钉账号',
  126 + extra: '绑定',
  127 + avatar: 'ri:dingding-fill',
  128 + color: '#2eabff',
  129 + },
  130 +];
  131 +
  132 +// 新消息通知 list
  133 +export const msgNotifyList: ListItem[] = [
  134 + {
  135 + key: '1',
  136 + title: '账户密码',
  137 + description: '其他用户的消息将以站内信的形式通知',
  138 + },
  139 + {
  140 + key: '2',
  141 + title: '系统消息',
  142 + description: '系统消息将以站内信的形式通知',
  143 + },
  144 + {
  145 + key: '3',
  146 + title: '待办任务',
  147 + description: '待办任务将以站内信的形式通知',
  148 + },
  149 +];
... ...
src/views/demo/page/account/setting/index.vue 0 → 100644
  1 +<template>
  2 + <ScrollContainer>
  3 + <div ref="wrapperRef" class="m-4 account">
  4 + <Tabs tab-position="left">
  5 + <template v-for="item in settingList" :key="item.key">
  6 + <TabPane :tab="item.name">
  7 + <component :is="item.component" />
  8 + </TabPane>
  9 + </template>
  10 + </Tabs>
  11 + </div>
  12 + </ScrollContainer>
  13 +</template>
  14 +
  15 +<script lang="ts">
  16 + import { defineComponent } from 'vue';
  17 + import { Tabs } from 'ant-design-vue';
  18 +
  19 + import { ScrollContainer } from '/@/components/Container/index';
  20 + import { settingList } from './data';
  21 +
  22 + import BaseSetting from './BaseSetting.vue';
  23 + import SecureSetting from './SecureSetting.vue';
  24 + import AccountBind from './AccountBind.vue';
  25 + import MsgNotify from './MsgNotify.vue';
  26 +
  27 + export default defineComponent({
  28 + components: {
  29 + ScrollContainer,
  30 + Tabs,
  31 + TabPane: Tabs.TabPane,
  32 + BaseSetting,
  33 + SecureSetting,
  34 + AccountBind,
  35 + MsgNotify,
  36 + },
  37 + setup() {
  38 + return { settingList };
  39 + },
  40 + });
  41 +</script>
  42 +<style lang="less" scoped>
  43 + .account {
  44 + background: #fff;
  45 +
  46 + /deep/ .base-title {
  47 + padding-left: 0;
  48 + }
  49 +
  50 + /deep/ .ant-tabs {
  51 + padding: 16px 0;
  52 + }
  53 +
  54 + /deep/ .ant-tabs-tab-active {
  55 + background-color: #e6f7ff;
  56 + }
  57 + }
  58 +</style>
... ...