Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
foreign
/
customer-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9b9fd218
authored
Dec 02, 2021
by
杨铁龙
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://gitlab.corp.qinqinxiaobao.com:9880/uniplat/customer-service
parents
caa8e5f5
0894faf2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
11 deletions
components/message-item/audio-message.vue
database/index.ts
model/order.ts
store/index.ts
store/model.ts
components/message-item/audio-message.vue
View file @
9b9fd218
...
...
@@ -20,6 +20,8 @@
v-else-if=
"fileFailed2Load"
title=
"[语音加载失败]"
></i>
<text-message
v-model=
"value"
v-if=
"backend"
/>
</div>
</
template
>
...
...
@@ -27,12 +29,16 @@
import
{
Component
,
Ref
}
from
"vue-property-decorator"
;
import
BaseMessage
from
"./index"
;
import
VoiceIcon
from
"./voice.vue"
;
import
TextMessage
from
"./text-message.vue"
;
import
Chat
from
"@/customer-service/xim"
;
@
Component
({
components
:
{
VoiceIcon
}
})
@
Component
({
components
:
{
VoiceIcon
,
TextMessage
}
})
export
default
class
Index
extends
BaseMessage
{
@
Ref
(
"audio"
)
private
readonly
audioRef
!
:
HTMLAudioElement
;
private
readonly
backend
=
Chat
.
isBackend
();
private
playing
=
false
;
private
get
duration
()
{
...
...
@@ -95,6 +101,13 @@
font-size
:
16px
;
}
}
.inline-text
{
position
:
absolute
;
bottom
:
0
;
left
:
40px
;
}
.my-message
{
.voice-message
{
>
div
{
...
...
database/index.ts
View file @
9b9fd218
...
...
@@ -57,17 +57,17 @@ class ChatCacheDatabaseController {
}
resolve
();
};
r
.
onsuccess
=
function
(
e
)
{
r
.
onsuccess
=
function
(
e
)
{
that
.
db
=
(
e
.
target
as
any
).
result
;
console
.
log
(
`index database init comepleted`
);
setupDb
();
};
r
.
onupgradeneeded
=
function
(
e
)
{
r
.
onupgradeneeded
=
function
(
e
)
{
that
.
db
=
(
e
.
target
as
any
).
result
;
console
.
log
(
`upgrade database comepleted`
);
setupDb
();
};
r
.
onerror
=
function
(
e
)
{
r
.
onerror
=
function
(
e
)
{
console
.
log
(
`index database init failed,
${
e
}
`
);
};
}
else
{
...
...
@@ -94,17 +94,17 @@ class ChatCacheDatabaseController {
}
setTimeout
(()
=>
resolve
(),
200
);
};
r
.
onsuccess
=
function
(
e
)
{
r
.
onsuccess
=
function
(
e
)
{
const
db
=
(
e
.
target
as
any
).
result
;
that
.
messageDatabases
.
set
(
k
,
db
);
setupDb
();
};
r
.
onupgradeneeded
=
function
(
e
)
{
r
.
onupgradeneeded
=
function
(
e
)
{
const
db
=
(
e
.
target
as
any
).
result
;
that
.
messageDatabases
.
set
(
k
,
db
);
setupDb
();
};
r
.
onerror
=
function
(
e
)
{
r
.
onerror
=
function
(
e
)
{
console
.
log
(
`chat message index database init failed,
${
e
}
`
);
...
...
@@ -173,6 +173,29 @@ class ChatCacheDatabaseController {
});
}
public
updateChat4UnreadCount
(
chat
:
number
,
unread
:
number
)
{
return
new
Promise
<
void
>
((
resolve
)
=>
{
if
(
this
.
db
)
{
const
store
=
this
.
buildStore
(
this
.
chatListKey
);
const
t
=
store
.
get
(
chat
);
t
.
onsuccess
=
(
r
)
=>
{
const
chat
=
(
r
.
target
as
any
).
result
as
Chat
;
if
(
chat
)
{
chat
.
unread_msg_count
=
unread
;
const
u
=
store
.
put
(
chat
,
chat
.
id
);
u
.
onsuccess
=
()
=>
resolve
();
u
.
onerror
=
()
=>
resolve
();
}
else
{
resolve
();
}
};
t
.
onerror
=
()
=>
resolve
();
}
else
{
resolve
();
}
});
}
public
setRead
(
chat
:
number
)
{
return
new
Promise
<
void
>
((
resolve
)
=>
{
if
(
this
.
db
)
{
...
...
@@ -351,6 +374,7 @@ class ChatCacheDatabaseController {
for
(
const
item
of
source2
)
{
const
t
=
source1
.
find
((
i
)
=>
i
.
id
===
item
.
id
);
if
(
t
)
{
item
.
unread_msg_count
=
Math
.
max
(
item
.
unread_msg_count
,
t
.
unread_msg_count
);
const
index
=
source1
.
indexOf
(
t
);
source1
[
index
]
=
item
;
}
else
{
...
...
model/order.ts
View file @
9b9fd218
...
...
@@ -34,6 +34,8 @@ export interface OrderTableListItem {
time
:
string
;
chat
:
number
;
status
:
OrderStatus
;
status_label
:
string
;
remark
:
string
;
/**
* 待支付金额
*/
...
...
@@ -59,7 +61,8 @@ export const orderPredict = {
v
:
"uniplat_version"
,
no
:
"OrderDocNo"
,
title
:
"ProductId#product.OuterName"
,
status
:
"Status"
,
status
:
"Status_label"
,
remark
:
"Remark"
,
time
:
"CreatedDate"
,
createTime
:
"CreatedDate"
,
PayAmount
:
"PayAmount"
,
...
...
store/index.ts
View file @
9b9fd218
...
...
@@ -31,7 +31,7 @@ function uniqueMessages(
messages
:
NonNullable
<
ChatStore
.
STATE_CHAT_MSG_HISTORY
>
)
{
const
arr
=
[...
messages
];
return
unique
(
arr
,
function
(
item
,
all
)
{
return
unique
(
arr
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
id
===
item
.
id
);
});
}
...
...
@@ -335,7 +335,7 @@ export default {
state
[
ChatStore
.
STATE_CHAT_SENDING_MESSAGES
]
=
[...
current
];
}
},
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
]:
(
function
()
{
[
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_INPUTING
]:
(
function
()
{
const
setTimeoutId
:
{
[
key
:
string
]:
number
}
=
{};
return
(
state
:
ChatStoreState
,
...
...
@@ -483,6 +483,11 @@ export default {
items
.
forEach
((
i
)
=>
(
sum
+=
i
.
unread_msg_count
));
state
[
ChatStore
.
STATE_CURRENT_UNREAD_MESSAGE_COUNT
]
=
sum
;
},
async
[
ChatStore
.
ACTION_UPDATE_CHAT_UNREAD_MESSAGE_COUNT
]({
dispatch
},
p
:
{
chat
:
number
;
unread
:
number
})
{
dbController
.
updateChat4UnreadCount
(
p
.
chat
,
p
.
unread
)
.
then
(()
=>
dispatch
(
ChatStore
.
ACTION_REBUILD_UNREAD_MESSAGE_COUNT
))
},
async
[
ChatStore
.
ACTION_GET_CHAT_MESSAGES
]({
state
,
commit
,
getters
})
{
const
chatId
=
state
[
ChatStore
.
STATE_CHAT_CURRENT_CHAT_ID
];
const
chat
=
getters
[
...
...
@@ -840,7 +845,7 @@ export default {
}
commit
(
ChatStore
.
MUTATION_SAVE_CURRENT_CHAT_MEMBERS
,
unique
(
newChatMembers
,
function
(
item
,
all
)
{
unique
(
newChatMembers
,
function
(
item
,
all
)
{
return
all
.
findIndex
((
k
)
=>
k
.
eid
===
item
.
eid
);
})
);
...
...
store/model.ts
View file @
9b9fd218
...
...
@@ -378,6 +378,9 @@ export namespace ChatStore {
export
const
ACTION_UPDATE_CHAT
=
"更新会话信息"
;
export
type
ACTION_UPDATE_CHAT
=
(
p
:
ChatUpdateParameter
)
=>
void
;
export
const
ACTION_UPDATE_CHAT_UNREAD_MESSAGE_COUNT
=
"更新Chat会话未读消息并重新计数总数"
;
export
type
ACTION_UPDATE_CHAT_UNREAD_MESSAGE_COUNT
=
(
p
:
{
chat
:
number
;
unread
:
number
})
=>
void
;
}
export
interface
ChatStoreState
{
...
...
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