|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
* @Author: ch
|
|
|
|
|
* @Date: 2022-03-26 14:32:03
|
|
|
|
|
* @LastEditors: ch
|
|
|
|
|
* @LastEditTime: 2022-06-10 19:09:45
|
|
|
|
|
* @LastEditTime: 2022-06-14 11:10:03
|
|
|
|
|
* @Description: file content
|
|
|
|
|
-->
|
|
|
|
|
<template>
|
|
|
|
@ -109,14 +109,7 @@ export default {
|
|
|
|
|
this.orderId = this.$Route.query.orderId;
|
|
|
|
|
this.sessionId = this.$Route.query.sessionId;
|
|
|
|
|
|
|
|
|
|
if(this.sessionId){
|
|
|
|
|
if(!this.msgData?.length){
|
|
|
|
|
this.getHistoryMsg();
|
|
|
|
|
}
|
|
|
|
|
this.readMsg();
|
|
|
|
|
}else{
|
|
|
|
|
this.createSessionMain();
|
|
|
|
|
}
|
|
|
|
|
this.socketInit();
|
|
|
|
|
if(this.goodsId){
|
|
|
|
|
this.getGoodsInfo();
|
|
|
|
|
}
|
|
|
|
@ -132,6 +125,23 @@ export default {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
|
|
|
|
socketInit(){
|
|
|
|
|
if(!Im.isOpen){
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.socketInit();
|
|
|
|
|
}, 100)
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(this.sessionId){
|
|
|
|
|
if(!this.msgData?.length){
|
|
|
|
|
this.getHistoryMsg();
|
|
|
|
|
}
|
|
|
|
|
this.readMsg();
|
|
|
|
|
}else{
|
|
|
|
|
this.createSessionMain();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 创建会话主体
|
|
|
|
|
* 如果是从商品或订单进来,需要创建会话
|
|
|
|
@ -161,6 +171,12 @@ export default {
|
|
|
|
|
* 获取历史消息
|
|
|
|
|
*/
|
|
|
|
|
async getHistoryMsg(){
|
|
|
|
|
if(!this.curSessionData.id){
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.getHistoryMsg();
|
|
|
|
|
}, 500)
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
this.loading = true;
|
|
|
|
|
const {error, result} = await ToAsyncAwait(Im.getHistoryMsg());
|
|
|
|
|
if(error){
|
|
|
|
@ -180,6 +196,7 @@ export default {
|
|
|
|
|
}));
|
|
|
|
|
if(error){
|
|
|
|
|
uni.$u.toast(error.errMsg || error.message);
|
|
|
|
|
console.log(error);
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|