Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fns_front_2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenqikuai
fns_front_2
Commits
342c9e5f
Commit
342c9e5f
authored
Sep 27, 2021
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
605f7a21
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
105 additions
and
21 deletions
+105
-21
App.vue
src/App.vue
+1
-4
UserInfoService.ts
src/db/UserInfoService.ts
+38
-0
index.ts
src/db/index.ts
+6
-2
index.ts
src/service/UserService/index.ts
+14
-2
types.ts
src/service/UserService/types.ts
+9
-0
displayName.ts
src/utils/displayName.ts
+37
-13
No files found.
src/App.vue
View file @
342c9e5f
<
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'
,
},
}
}
}
}
})
})
...
...
src/db/UserInfoService.ts
0 → 100644
View file @
342c9e5f
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
,
}
}
}
src/db/index.ts
View file @
342c9e5f
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'
)
}
}
}
}
src/service/UserService/index.ts
View file @
342c9e5f
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
()}
`
},
},
})
})
...
...
src/service/UserService/types.ts
View file @
342c9e5f
...
@@ -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
}
src/utils/displayName.ts
View file @
342c9e5f
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
})
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment