解决重商品跳进来没历史消息的问题,创建会话后SessionID没辅助导致

feature/1.0.1-im-ch
ch 3 years ago
parent 188e746404
commit 9750bd2740

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-05-18 14:54:47
* @LastEditors: ch
* @LastEditTime: 2022-05-21 14:22:13
* @LastEditTime: 2022-05-21 15:27:05
* @Description: file content
*/
import { CreateUUID, FormatDate, ToAsyncAwait } from "@/common/utils";
@ -235,8 +235,6 @@ export default class MsbIm {
newData[hisIdx].messageList = newData[hisIdx].messageList.concat(content);
this.setSessionData(newData);
}
return Promise.resolve(result);
}

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-05-20 11:00:07
* @LastEditors: ch
* @LastEditTime: 2022-05-21 14:27:58
* @LastEditTime: 2022-05-21 15:44:06
* @Description: file content
*/

@ -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
}
})

Loading…
Cancel
Save