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

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

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

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

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

Loading…
Cancel
Save