增加分享优惠券功能
This commit is contained in:
@@ -15,9 +15,7 @@ export const useChatStore = defineStore("chat", {
|
||||
socketUrl,
|
||||
isConnect: false,
|
||||
socketTask: null,
|
||||
onReceiveMsg:()=>{
|
||||
|
||||
},
|
||||
onReceiveMsg: () => {},
|
||||
chatList: [],
|
||||
};
|
||||
},
|
||||
@@ -83,20 +81,35 @@ export const useChatStore = defineStore("chat", {
|
||||
this.socketTask.onMessage((res) => {
|
||||
const data = JSON.parse(res.data);
|
||||
console.log("收到服务器消息", data);
|
||||
if(data.msg){
|
||||
if (data.msg) {
|
||||
uni.showToast({
|
||||
title: data.msg,
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
|
||||
if(data&&data.operate_type=="sendMsg"){
|
||||
|
||||
if (data && data.operate_type == "sendMsg") {
|
||||
this.chatList.unshift(data.data);
|
||||
this.onReceiveMsg(data.data);
|
||||
console.log(this.chatList);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
this.socketTask.onError((res) => {
|
||||
this.isConnect = false;
|
||||
console.log("连接错误", res);
|
||||
});
|
||||
|
||||
this.socketTask.onClose(() => {
|
||||
this.isConnect = false;
|
||||
console.log("连接已关闭");
|
||||
this.connectSocket();
|
||||
});
|
||||
},
|
||||
|
||||
closeSocket() {
|
||||
this.socketTask.close();
|
||||
this.isConnect = false;
|
||||
},
|
||||
},
|
||||
unistorage: false, // 开启后对 state 的数据读写都将持久化
|
||||
|
||||
Reference in New Issue
Block a user