Commit 342c9e5f authored by chenqikuai's avatar chenqikuai

fix

parent 605f7a21
<template> <template>
<van-config-provider :theme-vars="themeVars"> <van-config-provider :theme-vars="{ skeletonRowBackgroundColor: '#bfbfbf', }">
<div id="nav" class="bg-app-bg min-h-screen"> <div id="nav" class="bg-app-bg min-h-screen">
<router-view /> <router-view />
</div> </div>
...@@ -124,9 +124,6 @@ export default defineComponent({ ...@@ -124,9 +124,6 @@ export default defineComponent({
connectionState.connection?.disconnect(); connectionState.connection?.disconnect();
}); });
return { return {
themeVars: {
skeletonRowBackgroundColor: '#bfbfbf',
},
} }
} }
}) })
......
import { iUserinfo } from '@/service/UserService/types'
import { MyAppDatabase } from './index'
export default class UserInfoDBService {
static instance: UserInfoDBService
private userInfo: Dexie.Table<iUserinfo, number>
static getInstance() {
if (!UserInfoDBService.instance) {
UserInfoDBService.instance = new UserInfoDBService()
}
return UserInfoDBService.instance
}
constructor() {
const db = new MyAppDatabase()
this.userInfo = db.userInfo
}
save(list: iUserinfo[]) {
return this.userInfo.bulkAdd(list)
}
async findByList(addressList: string[]) {
const list = await this.userInfo
.filter((i) => {
return addressList.includes(i.addr)
})
.toArray()
const notFoundList = addressList.filter(
(i) => list.findIndex((item) => item?.addr === i) === -1,
)
return {
foundList: list,
notFoundList,
}
}
}
import Dexie from 'dexie' import Dexie from 'dexie'
import { DisplayMessage } from '@/store/messagesStore' import { DisplayMessage } from '@/store/messagesStore'
import { iContact } from '@/service/UserService/types' import { iContact, iUserinfo } from '@/service/UserService/types'
export interface iChatMessage extends DisplayMessage { export interface iChatMessage extends DisplayMessage {
masterId: string masterId: string
...@@ -17,19 +17,23 @@ export class MyAppDatabase extends Dexie { ...@@ -17,19 +17,23 @@ export class MyAppDatabase extends Dexie {
chatMessage: Dexie.Table<iChatMessage, number> chatMessage: Dexie.Table<iChatMessage, number>
chatListCard: Dexie.Table<iChatListCard, number> chatListCard: Dexie.Table<iChatListCard, number>
contactPerson: Dexie.Table<iContact, number> contactPerson: Dexie.Table<iContact, number>
userInfo: Dexie.Table<iUserinfo, number>
constructor() { constructor() {
super('MyAppDatabase') super('MyAppDatabase')
this.version(1).stores({ this.version(1.2).stores({
chatMessage: chatMessage:
'++id, content, from, uuid, state, uploadProgress, type, datetime, hideDatetime, logid, masterId, readed', '++id, content, from, uuid, state, uploadProgress, type, datetime, hideDatetime, logid, masterId, readed',
chatListCard: '++id, masterId, targetId, unreadMsgCount, content', chatListCard: '++id, masterId, targetId, unreadMsgCount, content',
contactPerson: '++id, addr, bank, phone, user_name', contactPerson: '++id, addr, bank, phone, user_name',
userInfo: '++id, created_at, phone, remark, user_name, uuid, addr',
}) })
this.chatMessage = this.table('chatMessage') this.chatMessage = this.table('chatMessage')
this.chatListCard = this.table('chatListCard') this.chatListCard = this.table('chatListCard')
this.contactPerson = this.table('contactPerson') this.contactPerson = this.table('contactPerson')
this.userInfo = this.table('userInfo')
} }
} }
import baseAxios from '../index' import baseAxios from '../index'
import { iContact } from './types' import { iContact, iUserinfo } from './types'
class UserService { class UserService {
static instance: UserService static instance: UserService
static getInstance() { static getInstance() {
...@@ -23,7 +23,19 @@ class UserService { ...@@ -23,7 +23,19 @@ class UserService {
method: 'get', method: 'get',
params: data, params: data,
paramsSerializer: (data: { addrs: string[] }) => { paramsSerializer: (data: { addrs: string[] }) => {
console.log(data); console.log(data)
return `addrs=${data.addrs.toString()}`
},
})
}
userInfo(data: { addrs: string[] }) {
return baseAxios<{ total: number; item: iUserinfo[] }>({
url: '/user/user_info',
method: 'get',
params: data,
paramsSerializer: (data: { addrs: string[] }) => {
console.log(data)
return `addrs=${data.addrs.toString()}` return `addrs=${data.addrs.toString()}`
}, },
}) })
......
...@@ -4,3 +4,12 @@ export interface iContact { ...@@ -4,3 +4,12 @@ export interface iContact {
phone: string phone: string
user_name: string user_name: string
} }
export interface iUserinfo {
addr: string
created_at: number
phone: string
remark: string
user_name: string
uuid: string
}
import ContactPersonService from '@/db/ContactPersonService' import ContactPersonService from '@/db/ContactPersonService'
import UserInfoDBService from '@/db/UserInfoService'
import UserService from '@/service/UserService' import UserService from '@/service/UserService'
import { iContact } from '@/service/UserService/types' import { iContact } from '@/service/UserService/types'
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 { let foundList = [] as any[]
foundList, let notFoundList = [] as any[]
notFoundList,
} = await ContactPersonService.getInstance().findByList(addressList)
const fullList = foundList if (user?.role === eRole.user) {
const ret = await ContactPersonService.getInstance().findByList(addressList)
foundList = ret.foundList
notFoundList = ret.notFoundList
} else if (user?.role === eRole.staff) {
const ret = await UserInfoDBService.getInstance().findByList(addressList)
foundList = ret.foundList
notFoundList = ret.notFoundList
}
const fullList = (foundList as unknown) as any
if (notFoundList.length !== 0) { if (notFoundList.length !== 0) {
const ret = await UserService.getInstance().staffInfo({ if (user?.role === eRole.user) {
addrs: notFoundList, const ret = await UserService.getInstance().staffInfo({
}) addrs: notFoundList,
if (ret.code === 200) { })
const theoseNotFoundList = ret.data.item if (ret.code === 200) {
ContactPersonService.getInstance().save(theoseNotFoundList) const theoseNotFoundList = ret.data.item
fullList.push(...theoseNotFoundList) ContactPersonService.getInstance().save(theoseNotFoundList)
fullList.push(...theoseNotFoundList)
}
} else if (user?.role === eRole.staff) {
const ret = await UserService.getInstance().userInfo({
addrs: notFoundList,
})
if (ret.code === 200) {
const theoseNotFoundList = ret.data.item
UserInfoDBService.getInstance().save(theoseNotFoundList)
fullList.push(...theoseNotFoundList)
}
} }
} }
return addressList.map((item) => { return addressList.map((item) => {
return fullList.find((i) => i?.addr === item)?.user_name || '未知用户' const msg = fullList.find((i: any) => i?.addr === item)
return msg?.user_name || msg?.phone
}) })
} }
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