Commit 4d72e4b0 authored by chenqikuai's avatar chenqikuai

feat: 通讯录

parent c07cc217
import { eRole } from '@/types/roleType' import { eRole } from "@/types/roleType";
import { chatAuthCheck } from '@/utils/authCheck' import { chatAuthCheck } from "@/utils/authCheck";
import { getUserMsg } from '@/utils/userMsg' import { getUserMsg } from "@/utils/userMsg";
import { Toast } from 'vant' import { Toast } from "vant";
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router' import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
const routes: Array<RouteRecordRaw> = [ const routes: Array<RouteRecordRaw> = [
{ {
path: '/', path: "/",
redirect: { name: 'Home' }, redirect: { name: "Home" },
component: () => component: () =>
import(/* webpackChunkName: "withMenu" */ '@/views/withMenu/index.vue'), import(/* webpackChunkName: "withMenu" */ "@/views/withMenu/index.vue"),
children: [ children: [
{ {
path: '/home', path: "/home",
name: 'Home', name: "Home",
meta: {
activeTab: "Home",
},
component: () => component: () =>
import( import(
/* webpackChunkName: "Home" */ '@/views/withMenu/Home/index.vue' /* webpackChunkName: "Home" */ "@/views/withMenu/Home/index.vue"
), ),
}, },
{ {
path: '/mine', path: "/mine",
name: 'Mine', name: "Mine",
meta: {
activeTab: "Mine",
},
component: () => component: () =>
import( import(
/* webpackChunkName: "mine" */ '@/views/withMenu/Mine/index.vue' /* webpackChunkName: "mine" */ "@/views/withMenu/Mine/index.vue"
), ),
}, },
{ {
path: '/loan', path: "/loan",
name: 'Loan', name: "Loan",
meta: {
activeTab: "Loan",
},
component: () => component: () =>
import( import(
/* webpackChunkName: "mine" */ '@/views/withMenu/Loan/index.vue' /* webpackChunkName: "mine" */ "@/views/withMenu/Loan/index.vue"
), ),
}, },
{ {
path: '/chatList', path: "/chatList",
name: 'ChatList', name: "ChatList",
meta: { meta: {
needAuth: true, needAuth: true,
activeTab: "ChatList",
}, },
component: () => component: () =>
import( import(
/* webpackChunkName: "chatList" */ '@/views/withMenu/ChatList/index.vue' /* webpackChunkName: "chatList" */ "@/views/withMenu/ChatList/index.vue"
),
},
{
path: "/addressBook",
name: "AddressBook",
meta: {
activeTab: "ChatList",
},
component: () =>
import(
/* webpackChunkName: "addressBook" */ "@/views/withMenu/AddressBook/index.vue"
), ),
}, },
], ],
}, },
{ {
path: '/loanList/:mode', path: "/loanList/:mode",
name: 'LoanList', name: "LoanList",
component: () => component: () =>
import(/* webpackChunkName: "LoanList" */ '@/views/LoanList/index.vue'), import(/* webpackChunkName: "LoanList" */ "@/views/LoanList/index.vue"),
}, },
{ {
path: '/loanDetail/:uuid', path: "/loanDetail/:uuid",
name: 'LoanDetail', name: "LoanDetail",
component: () => component: () =>
import( import(
/* webpackChunkName: "LoanDetail" */ '@/views/LoanDetail/index.vue' /* webpackChunkName: "LoanDetail" */ "@/views/LoanDetail/index.vue"
), ),
}, },
{ {
path: '/activityList', path: "/activityList",
name: 'ActivityList', name: "ActivityList",
component: () => component: () =>
import( import(
/* webpackChunkName: "ActivityList" */ '@/views/ActivityList/index.vue' /* webpackChunkName: "ActivityList" */ "@/views/ActivityList/index.vue"
), ),
}, },
{ {
path: '/activityDetail/:uuid', path: "/activityDetail/:uuid",
name: 'ActivityDetail', name: "ActivityDetail",
component: () => component: () =>
import( import(
/* webpackChunkName: "ActivityDetail" */ '@/views/ActivityDetail/index.vue' /* webpackChunkName: "ActivityDetail" */ "@/views/ActivityDetail/index.vue"
), ),
}, },
{ {
path: '/policySupport', path: "/policySupport",
name: 'PolicySupport', name: "PolicySupport",
component: () => component: () =>
import( import(
/* webpackChunkName: "PolicySupport" */ '@/views/PolicySupport/index.vue' /* webpackChunkName: "PolicySupport" */ "@/views/PolicySupport/index.vue"
), ),
}, },
{ {
path: '/news', path: "/news",
name: 'News', name: "News",
component: () => component: () =>
import(/* webpackChunkName: "News" */ '@/views/News/index.vue'), import(/* webpackChunkName: "News" */ "@/views/News/index.vue"),
}, },
{ {
path: '/newsDetail', path: "/newsDetail",
name: 'NewsDetail', name: "NewsDetail",
component: () => component: () =>
import( import(
/* webpackChunkName: "NewsDetail" */ '@/views/NewsDetail/index.vue' /* webpackChunkName: "NewsDetail" */ "@/views/NewsDetail/index.vue"
), ),
}, },
{ {
path: '/search', path: "/search",
name: 'Search', name: "Search",
component: () => component: () =>
import(/* webpackChunkName: "Search" */ '@/views/Search/index.vue'), import(/* webpackChunkName: "Search" */ "@/views/Search/index.vue"),
}, },
{ {
path: '/auth', path: "/auth",
component: () => component: () =>
import(/* webpackChunkName: "auth" */ '@/views/Auth/index.vue'), import(/* webpackChunkName: "auth" */ "@/views/Auth/index.vue"),
redirect: { redirect: {
name: 'Login', name: "Login",
}, },
children: [ children: [
{ {
path: '/auth/Login', path: "/auth/Login",
name: 'Login', name: "Login",
component: () => component: () =>
import( import(
/* webpackChunkName: "Login" */ '@/views/Auth/Login/index.vue' /* webpackChunkName: "Login" */ "@/views/Auth/Login/index.vue"
), ),
}, },
{ {
path: '/auth/UserAgreement', path: "/auth/UserAgreement",
name: 'UserAgreement', name: "UserAgreement",
component: () => component: () =>
import( import(
/* webpackChunkName: "UserAgreement" */ '@/views/Auth/UserAgreement/index.vue' /* webpackChunkName: "UserAgreement" */ "@/views/Auth/UserAgreement/index.vue"
), ),
}, },
{ {
path: '/auth/PwdSetting', path: "/auth/PwdSetting",
name: 'PwdSetting', name: "PwdSetting",
component: () => component: () =>
import( import(
/* webpackChunkName: "PwdSetting" */ '@/views/Auth/PwdSetting/index.vue' /* webpackChunkName: "PwdSetting" */ "@/views/Auth/PwdSetting/index.vue"
), ),
}, },
{ {
path: '/auth/PwdFind', path: "/auth/PwdFind",
name: 'PwdFind', name: "PwdFind",
component: () => component: () =>
import( import(
/* webpackChunkName: "PwdFind" */ '@/views/Auth/PwdFind/index.vue' /* webpackChunkName: "PwdFind" */ "@/views/Auth/PwdFind/index.vue"
), ),
}, },
{ {
path: '/auth/PwdModify', path: "/auth/PwdModify",
name: 'PwdModify', name: "PwdModify",
component: () => component: () =>
import( import(
/* webpackChunkName: "PwdModify" */ '@/views/Auth/PwdModify/index.vue' /* webpackChunkName: "PwdModify" */ "@/views/Auth/PwdModify/index.vue"
), ),
}, },
], ],
}, },
{ {
path: '/setting', path: "/setting",
name: 'Setting', name: "Setting",
component: () => component: () =>
import( import(
/* webpackChunkName: "Setting" */ '@/views/withMenu/Mine/setting.vue' /* webpackChunkName: "Setting" */ "@/views/withMenu/Mine/setting.vue"
), ),
meta: { meta: {
needAuth: true, needAuth: true,
}, },
}, },
{ {
path: '/aboutUs', path: "/aboutUs",
name: 'AboutUs', name: "AboutUs",
component: () => component: () =>
import( import(
/* webpackChunkName: "AboutUs" */ '@/views/withMenu/Mine/aboutUs.vue' /* webpackChunkName: "AboutUs" */ "@/views/withMenu/Mine/aboutUs.vue"
), ),
}, },
{ {
path: '/msgManage', path: "/msgManage",
name: 'MsgManage', name: "MsgManage",
component: () => component: () =>
import( import(
/* webpackChunkName: "MsgManage" */ '@/views/withMenu/Mine/msg.vue' /* webpackChunkName: "MsgManage" */ "@/views/withMenu/Mine/msg.vue"
), ),
}, },
{ {
path: '/msgDetail', path: "/msgDetail",
name: 'MsgDetail', name: "MsgDetail",
component: () => component: () =>
import( import(
/* webpackChunkName: "MsgDetail" */ '@/views/withMenu/Mine/msgDetail.vue' /* webpackChunkName: "MsgDetail" */ "@/views/withMenu/Mine/msgDetail.vue"
), ),
}, },
{ {
path: '/branch', path: "/branch",
name: 'Branch', name: "Branch",
component: () => component: () =>
import( import(
/* webpackChunkName: "Branch" */ '@/views/withMenu/Mine/branch.vue' /* webpackChunkName: "Branch" */ "@/views/withMenu/Mine/branch.vue"
), ),
}, },
{ {
path: '/chat', path: "/chat",
name: 'Chat', name: "Chat",
component: () => component: () =>
import(/* webpackChunkName: "Chat" */ '@/views/Chat/Chat.vue'), import(/* webpackChunkName: "Chat" */ "@/views/Chat/Chat.vue"),
}, },
{ {
path: '/chatDetailMsg', path: "/chatDetailMsg",
name: 'ChatDetailMsg', name: "ChatDetailMsg",
component: () => component: () =>
import( import(
/* webpackChunkName: "ChatDetailMsg" */ '@/views/Chat/DetailMsg.vue' /* webpackChunkName: "ChatDetailMsg" */ "@/views/Chat/DetailMsg.vue"
), ),
}, },
{ {
path: '/crop', path: "/crop",
name: 'Crop', name: "Crop",
component: () => component: () =>
import(/* webpackChunkName: "Crop" */ '@/views/Crop/index.vue'), import(/* webpackChunkName: "Crop" */ "@/views/Crop/index.vue"),
}, },
{ {
path: '/:pathMatch(.*)*', path: "/:pathMatch(.*)*",
redirect: { redirect: {
name: 'Home', name: "Home",
}, },
}, },
] ];
const router = createRouter({ const router = createRouter({
history: createWebHistory(process.env.BASE_URL), history: createWebHistory(process.env.BASE_URL),
routes, routes,
}) });
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
const userMsg = getUserMsg() const userMsg = getUserMsg();
if (to.meta.needAuth) { if (to.meta.needAuth) {
if (!!userMsg) { if (!!userMsg) {
if (userMsg.role === eRole.user) next() if (userMsg.role === eRole.user) next();
else if (userMsg.role === eRole.staff) { else if (userMsg.role === eRole.staff) {
if (to.name === 'ChatList') { if (to.name === "ChatList") {
chatAuthCheck( chatAuthCheck(
() => { () => {
next() next();
}, },
(mark: boolean | undefined) => { (mark: boolean | undefined) => {
/* 如果有mark为false,则表示检查聊天权限的逻辑走到了调用接口,但是返回auth为false */ /* 如果有mark为false,则表示检查聊天权限的逻辑走到了调用接口,但是返回auth为false */
mark === false && mark === false &&
Toast('由于您现在是不在岗状态所以无法进入聊天!') Toast("由于您现在是不在岗状态所以无法进入聊天!");
}, }
) );
} else { } else {
next() next();
} }
} }
} else { } else {
next({ name: 'Login' }) next({ name: "Login" });
} }
} else { } else {
next() next();
} }
}) });
export default router export default router;
import baseAxios from '../index' import baseAxios from "../index";
import { iContactPerson } from "@/types/chat/index";
export function getStaffOnDutyStatus() { export function getStaffOnDutyStatus() {
return baseAxios<boolean>({ return baseAxios<boolean>({
url: '/staff/on_duty', url: "/staff/on_duty",
method: 'get', method: "get",
}) });
} }
export function enableLive() { export function enableLive() {
return baseAxios({ return baseAxios({
url: '/staff/enable_live', url: "/staff/enable_live",
method: 'get' method: "get",
}) });
}
export function staffGetUsers(data: {
is_desc: boolean;
order_by: string;
page: number;
page_size: number;
}) {
return baseAxios<{ item: iContactPerson[]; total: number }>({
url: "/staff/myUsers",
method: "get",
params: data,
});
} }
import baseAxios from "../index"; import baseAxios from "../index";
import { iContact, iUserinfo } from "./types"; import { iContact, iUserinfo } from "./types";
import { iContactPerson } from "@/types/chat/index";
class UserService { class UserService {
static instance: UserService; static instance: UserService;
static getInstance() { static getInstance() {
...@@ -49,6 +50,22 @@ class UserService { ...@@ -49,6 +50,22 @@ class UserService {
url: "/chat_info", url: "/chat_info",
}); });
} }
userGetAccountManager() {
return baseAxios<Omit<iContactPerson, "address"> & { addr: string }>({
url: "/user/myAccountManager",
method: "get",
}).then((ret) => {
const { addr, ...otherValues } = ret.data;
return {
...ret,
data: {
...otherValues,
address: addr,
},
};
});
}
} }
export default UserService; export default UserService;
export interface iNotifyMsg { export interface iNotifyMsg {
staffMsg: string staffMsg: string;
userMsg: string userMsg: string;
}
export interface iContactPerson {
address: string;
phone: string;
token: string;
user_name: string;
uuid: string;
} }
...@@ -2,8 +2,8 @@ import { eRole } from "./roleType"; ...@@ -2,8 +2,8 @@ import { eRole } from "./roleType";
export interface iUserMsg { export interface iUserMsg {
token: string; token: string;
role: eRole; role: eRole.staff | eRole.user; //role把所有类型用户分成员工和客户
role2: eRole; role2: eRole; // role2把用户分成 客户经理 管理员 客户
userInfo: { userInfo: {
phone?: string; phone?: string;
addr?: string; addr?: string;
......
import { iChatListCard } from '@/db' import ContactPersonService from "@/db/ContactPersonService";
import ContactPersonService from '@/db/ContactPersonService' import OutletDBService from "@/db/OutletDBService";
import OutletDBService from '@/db/OutletDBService' import UserInfoDBService from "@/db/UserInfoService";
import UserInfoDBService from '@/db/UserInfoService' import AddressService from "@/service/AddressService";
import AddressService from '@/service/AddressService' import UserService from "@/service/UserService";
import UserService from '@/service/UserService' import { eRole } from "@/types/roleType";
import { iContact } from '@/service/UserService/types' import { getUserMsg } from "./userMsg";
import { eRole } from '@/types/roleType'
import { getUserMsg } from './userMsg'
/* 拿到地址对应的用户昵称 */ /* 拿到地址对应的用户昵称 */
export const getDisplayNamesFromAddress = async ( export const getDisplayNamesFromAddress = async (
addressList: string[], addressList: string[]
): Promise<string[]> => { ): Promise<string[]> => {
/* 数据库查 有结果拿 没结果网上查且存 */ /* 数据库查 有结果拿 没结果网上查且存 */
const user = getUserMsg() const user = getUserMsg();
let foundList = [] as any[] let foundList = [] as any[];
let notFoundList = [] as any[] let notFoundList = [] as any[];
if (user?.role === eRole.user) { if (user?.role === eRole.user) {
const ret = await ContactPersonService.getInstance().findByList(addressList) const ret = await ContactPersonService.getInstance().findByList(
foundList = ret.foundList addressList
notFoundList = ret.notFoundList );
foundList = ret.foundList;
notFoundList = ret.notFoundList;
} else if (user?.role === eRole.staff) { } else if (user?.role === eRole.staff) {
const ret = await UserInfoDBService.getInstance().findByList(addressList) const ret = await UserInfoDBService.getInstance().findByList(addressList);
foundList = ret.foundList foundList = ret.foundList;
notFoundList = ret.notFoundList notFoundList = ret.notFoundList;
} }
const fullList = (foundList as unknown) as any const fullList = foundList as unknown as any;
if (notFoundList.length !== 0) { if (notFoundList.length !== 0) {
if (user?.role === eRole.user) { if (user?.role === eRole.user) {
const ret = await UserService.getInstance().staffInfo({ const ret = await UserService.getInstance().staffInfo({
addrs: notFoundList, addrs: notFoundList,
}) });
if (ret.code === 200) { if (ret.code === 200) {
const theoseNotFoundList = ret.data.item const theoseNotFoundList = ret.data.item;
ContactPersonService.getInstance().save(theoseNotFoundList) ContactPersonService.getInstance().save(theoseNotFoundList);
fullList.push(...theoseNotFoundList) fullList.push(...theoseNotFoundList);
} }
} else if (user?.role === eRole.staff) { } else if (user?.role === eRole.staff) {
const ret = await UserService.getInstance().userInfo({ const ret = await UserService.getInstance().userInfo({
addrs: notFoundList, addrs: notFoundList,
}) });
if (ret.code === 200) { if (ret.code === 200) {
const theoseNotFoundList = ret.data const theoseNotFoundList = ret.data;
UserInfoDBService.getInstance().save(theoseNotFoundList) UserInfoDBService.getInstance().save(theoseNotFoundList);
fullList.push(...theoseNotFoundList) fullList.push(...theoseNotFoundList);
} }
} }
} }
return addressList.map((item) => { return addressList.map((item) => {
const msg = fullList.find((i: any) => i?.addr === item) const msg = fullList.find((i: any) => i?.addr === item);
if (msg?.out_let_name) { if (msg?.out_let_name) {
return msg?.out_let_name + msg.user_name return msg?.out_let_name + msg.user_name;
} else { } else {
return msg?.phone return msg?.phone;
} }
}) });
} };
/* 获取网点名称 */ /* 获取网点名称 */
export const getDisplayNamesFromOutletId = async (outletids: number[]) => { export const getDisplayNamesFromOutletId = async (outletids: number[]) => {
const promiseList = outletids.map(async (id) => { const promiseList = outletids.map(async (id) => {
const outlet = await OutletDBService.getInstance().get(id) const outlet = await OutletDBService.getInstance().get(id);
if (!outlet) { if (!outlet) {
const ret = await AddressService.getInstance().getOutlet({ const ret = await AddressService.getInstance().getOutlet({
id, id,
}) });
if (ret.code === 200) { if (ret.code === 200) {
await OutletDBService.getInstance().add({ await OutletDBService.getInstance().add({
name: ret.data.outlet_name, name: ret.data.outlet_name,
id: ret.data.id, id: ret.data.id,
}) });
return ret.data.outlet_name return ret.data.outlet_name;
} }
} else { } else {
!outlet.isDeleted && !outlet.isDeleted &&
...@@ -88,80 +88,82 @@ export const getDisplayNamesFromOutletId = async (outletids: number[]) => { ...@@ -88,80 +88,82 @@ export const getDisplayNamesFromOutletId = async (outletids: number[]) => {
OutletDBService.getInstance().update({ OutletDBService.getInstance().update({
name: ret.data.outlet_name, name: ret.data.outlet_name,
id: ret.data.id, id: ret.data.id,
}) });
} else { } else {
OutletDBService.getInstance().update({ OutletDBService.getInstance().update({
id, id,
isDeleted: true, isDeleted: true,
}) });
} }
}) });
return `${outlet.name}${outlet.isDeleted ? '(已停止营业)' : ''}` return `${outlet.name}${outlet.isDeleted ? "(已停止营业)" : ""}`;
} }
}) });
const list = await Promise.all(promiseList) const list = await Promise.all(promiseList);
return list return list;
} };
export const getDisplayNames = async ( export const getDisplayNames = async (
list: { outletId?: number; address?: string }[], list: { outletId?: number; address?: string }[]
) => { ) => {
const promiseList = list.map((i) => { const promiseList = list.map((i) => {
if (i.outletId !== undefined) { if (i.outletId !== undefined) {
return getDisplayNamesFromOutletId([i.outletId]).then((ret) => ret[0]) return getDisplayNamesFromOutletId([i.outletId]).then((ret) => ret[0]);
} else if (i.address !== undefined) { } else if (i.address !== undefined) {
return getDisplayNamesFromAddress([i.address]).then((ret) => ret[0]) return getDisplayNamesFromAddress([i.address]).then((ret) => ret[0]);
} else return '' } else return "";
}) });
return Promise.all(promiseList) return Promise.all(promiseList);
} };
export const getMsgFromAddress = async ( export const getMsgFromAddress = async (
addressList: string[], addressList: string[]
): Promise<any[]> => { ): Promise<any[]> => {
/* 数据库查 有结果拿 没结果网上查且存 */ /* 数据库查 有结果拿 没结果网上查且存 */
const user = getUserMsg() const user = getUserMsg();
let foundList = [] as any[] let foundList = [] as any[];
let notFoundList = [] as any[] let notFoundList = [] as any[];
if (user?.role === eRole.user) { if (user?.role === eRole.user) {
const ret = await ContactPersonService.getInstance().findByList(addressList) const ret = await ContactPersonService.getInstance().findByList(
foundList = ret.foundList addressList
notFoundList = ret.notFoundList );
foundList = ret.foundList;
notFoundList = ret.notFoundList;
} else if (user?.role === eRole.staff) { } else if (user?.role === eRole.staff) {
const ret = await UserInfoDBService.getInstance().findByList(addressList) const ret = await UserInfoDBService.getInstance().findByList(addressList);
foundList = ret.foundList foundList = ret.foundList;
notFoundList = ret.notFoundList notFoundList = ret.notFoundList;
} }
const fullList = (foundList as unknown) as any const fullList = foundList as unknown as any;
if (notFoundList.length !== 0) { if (notFoundList.length !== 0) {
if (user?.role === eRole.user) { if (user?.role === eRole.user) {
const ret = await UserService.getInstance().staffInfo({ const ret = await UserService.getInstance().staffInfo({
addrs: notFoundList, addrs: notFoundList,
}) });
if (ret.code === 200) { if (ret.code === 200) {
const theoseNotFoundList = ret.data.item const theoseNotFoundList = ret.data.item;
ContactPersonService.getInstance().save(theoseNotFoundList) ContactPersonService.getInstance().save(theoseNotFoundList);
fullList.push(...theoseNotFoundList) fullList.push(...theoseNotFoundList);
} }
} else if (user?.role === eRole.staff) { } else if (user?.role === eRole.staff) {
const ret = await UserService.getInstance().userInfo({ const ret = await UserService.getInstance().userInfo({
addrs: notFoundList, addrs: notFoundList,
}) });
if (ret.code === 200) { if (ret.code === 200) {
const theoseNotFoundList = ret.data const theoseNotFoundList = ret.data;
UserInfoDBService.getInstance().save(theoseNotFoundList) UserInfoDBService.getInstance().save(theoseNotFoundList);
fullList.push(...theoseNotFoundList) fullList.push(...theoseNotFoundList);
} }
} }
} }
return addressList.map((item) => { return addressList.map((item) => {
const msg = fullList.find((i: any) => i?.addr === item) const msg = fullList.find((i: any) => i?.addr === item);
return msg return msg;
}) });
} };
<template>
<div
class="flex chatlistitem relative -mr-1 py-2 border-b"
@click="$emit('chat')"
>
<div class="self-center mr-4 flex-shrink-0">
<img
v-if="isStaff"
class="w-10 h-10 rounded-md object-cover"
src="@/assets/icons/avatar.png"
alt="avatar"
/>
<img
v-else
class="w-10 h-10 rounded-md object-contain"
src="@/assets/icons/staff.png"
alt="avatar"
/>
</div>
<div class="flex-grow overflow-hidden pr-1 flex items-center">
{{ displayName }}
</div>
</div>
</template>
<script setup lang="ts">
defineEmits(["chat"]);
defineProps({
displayName: String,
isStaff: Boolean,
});
</script>
<template>
<List @load="onLoad" v-model:loading="loading" :finished="finished">
<AddressBookItem
v-for="target in list"
:display-name="target.displayName"
@chat="
$router.push({
name: 'Chat',
query: {
targetId: target.address,
},
})
"
></AddressBookItem>
</List>
</template>
<script setup lang="ts">
import { staffGetUsers } from "@/service/StaffService";
import UserService from "@/service/UserService";
import { eRole } from "@/types/roleType";
import { getUserMsg } from "@/utils/userMsg";
import { ref } from "@vue/reactivity";
import { List } from "vant";
import { iContactPerson } from "@/types/chat/index";
import { getDisplayNamesFromAddress } from "@/utils/displayName";
import AddressBookItem from "./AddressBookItem.vue";
const list = ref<(iContactPerson & { displayName: string })[]>([]);
const loading = ref(false);
const finished = ref(false);
const page = ref(1);
const pageSize = ref(10);
const total = ref(0);
const userMsg = getUserMsg();
const isStaff = userMsg?.role === eRole.staff;
const isUser = userMsg?.role === eRole.user;
async function staffLoadCustoms() {
const ret = await staffGetUsers({
is_desc: true,
order_by: "phone",
page: page.value,
page_size: pageSize.value,
});
if (ret.code === 200) {
const displayNames = ret.data.item.map((i) => i.phone);
list.value.push(
...ret.data.item.map((item, index) => {
return {
...item,
displayName: displayNames[index],
};
})
);
total.value = ret.data.total;
page.value++;
if (list.value.length === total.value) {
finished.value = true;
}
} else {
finished.value = true;
}
}
async function userLoadAccountManager() {
const ret = await UserService.getInstance().userGetAccountManager();
if (ret.code === 200) {
const displayNames = await getDisplayNamesFromAddress([ret.data.address]);
list.value.push({ ...ret.data, displayName: displayNames[0] });
finished.value = true;
}
}
async function onLoad() {
if (isStaff) {
staffLoadCustoms();
} else if (isUser) {
userLoadAccountManager();
}
loading.value = false;
}
</script>
<template>
<NavBar title="通讯录"></NavBar>
<div class="mx-5">
<AddressBookList />
</div>
</template>
<script setup lang="ts">
import NavBar from "@/components/NavBar/index.vue";
import AddressBookList from "./AddressBookList.vue";
</script>
<template> <template>
<Navbar :title="navBarTitle" :showBackIcon="false"> <Navbar :title="navBarTitle" :showBackIcon="false">
<template #right> <template #right>
<Icon name="icon-tongxunlu2" size="17" color="#4e61c9"></Icon> <Icon
name="icon-tongxunlu2"
size="17"
color="#4e61c9"
@click="$router.push({ name: 'AddressBook' })"
></Icon>
</template> </template>
</Navbar> </Navbar>
<div class="mx-5"> <div class="mx-5">
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
iconName="icon-tongxunlu" iconName="icon-tongxunlu"
iconSize="19" iconSize="19"
label="通讯录" label="通讯录"
@click="$router.push({ name: 'AddressBook' })"
/> />
</div> </div>
<!-- 我的网点 --> <!-- 我的网点 -->
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<div <div
class="flex-grow ml-7 mr-2.5 border-b border-app-gray opacity-50" class="flex-grow ml-7 mr-2.5 border-b border-app-gray opacity-50"
></div> ></div>
<a class=" text-app-gray text-xs">浙ICP备2021029429号-1</a> <a class="text-app-gray text-xs">浙ICP备2021029429号-1</a>
<div <div
class="flex-grow ml-2.5 mr-7 border-b border-app-gray opacity-50" class="flex-grow ml-2.5 mr-7 border-b border-app-gray opacity-50"
></div> ></div>
...@@ -43,7 +43,7 @@ export default defineComponent({ ...@@ -43,7 +43,7 @@ export default defineComponent({
}, },
computed: { computed: {
activeTabRouteName() { activeTabRouteName() {
return this.$route.name; return this.$route.meta.activeTab;
}, },
tabList() { tabList() {
const theTabList = tabList.filter((i) => { const theTabList = tabList.filter((i) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment