|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
* @Author: ch
|
|
|
|
|
* @Date: 2022-03-26 14:32:03
|
|
|
|
|
* @LastEditors: ch
|
|
|
|
|
* @LastEditTime: 2022-05-21 14:19:38
|
|
|
|
|
* @LastEditTime: 2022-05-21 15:43:32
|
|
|
|
|
* @Description: file content
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
|
|
|
@ -47,7 +47,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import {MSG_TYPE} from '@/common/dicts/im';
|
|
|
|
|
import {Im} from '@/common/utils';
|
|
|
|
|
import {Im, ToAsyncAwait} from '@/common/utils';
|
|
|
|
|
import {ApiGetOrderDetail} from '@/common/api/order';
|
|
|
|
|
import {ApiGetGoodsDetail} from '@/common/api/goods';
|
|
|
|
|
import UiButton from '@/components/UiButton.vue';
|
|
|
|
@ -68,7 +68,10 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
computed:{
|
|
|
|
|
curSessionData(){
|
|
|
|
|
const data = this.$store.state.imData.find(i =>i.id == this.$Route.query.sessionId) || {}
|
|
|
|
|
const data = this.$store.state.imData.find(i =>{
|
|
|
|
|
|
|
|
|
|
return i.id == this.sessionId
|
|
|
|
|
}) || {};
|
|
|
|
|
if(data.id){
|
|
|
|
|
Im.setCurSessionId(data.id);
|
|
|
|
|
}
|
|
|
|
@ -130,15 +133,16 @@ export default {
|
|
|
|
|
* 如果是从商品或订单进来,需要创建会话
|
|
|
|
|
*/
|
|
|
|
|
async createSessionMain(){
|
|
|
|
|
const {error, result} = await Im.createSession({
|
|
|
|
|
const {error, result} = await ToAsyncAwait(Im.createSession({
|
|
|
|
|
content : {
|
|
|
|
|
storeId : 1
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}));
|
|
|
|
|
if(error){
|
|
|
|
|
uni.$u.toast(error);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
this.sessionId = result.content.id
|
|
|
|
|
this.getHistoryMsg();
|
|
|
|
|
this.readMsg();
|
|
|
|
|
|
|
|
|
@ -151,7 +155,7 @@ export default {
|
|
|
|
|
const lastMsg = this.msgData?.length ? this.msgData[0] : {};
|
|
|
|
|
await Im.getHistoryMsg({
|
|
|
|
|
content : {
|
|
|
|
|
sessionId : this.$Route.query.sessionId,
|
|
|
|
|
sessionId : this.sessionId,
|
|
|
|
|
topMessageId : lastMsg.id || null
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -163,7 +167,7 @@ export default {
|
|
|
|
|
readMsg(){
|
|
|
|
|
Im.setRead({
|
|
|
|
|
content: {
|
|
|
|
|
sessionId : this.$Route.query.sessionId
|
|
|
|
|
sessionId : this.sessionId
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|