添加新通知处理
This commit is contained in:
@@ -37,6 +37,7 @@ export const MESSAGETYPESV2 = {
|
|||||||
ShootResult: 4,
|
ShootResult: 4,
|
||||||
NewRound: 5,
|
NewRound: 5,
|
||||||
BattleEnd: 6,
|
BattleEnd: 6,
|
||||||
|
halfRest: 7,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
export const topThreeColors = ["#FFD947", "#D2D2D2", "#FFA515"];
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ function createWebSocket(token, onMessage) {
|
|||||||
|
|
||||||
switch (envVersion) {
|
switch (envVersion) {
|
||||||
case "develop": // 开发版
|
case "develop": // 开发版
|
||||||
// url = "ws://192.168.1.242:8000/socket";
|
// url = "ws://192.168.1.30:8000/socket";
|
||||||
url = "wss://apitest.shelingxingqiu.com/socket";
|
url = "wss://apitest.shelingxingqiu.com/socket";
|
||||||
break;
|
break;
|
||||||
case "trial": // 体验版
|
case "trial": // 体验版
|
||||||
@@ -45,11 +45,16 @@ function createWebSocket(token, onMessage) {
|
|||||||
|
|
||||||
// 接收消息
|
// 接收消息
|
||||||
uni.onSocketMessage((res) => {
|
uni.onSocketMessage((res) => {
|
||||||
const data = JSON.parse(res.data);
|
const { data, event } = JSON.parse(res.data);
|
||||||
if (data.event === "pong" || !data.data.updates) return;
|
if (event === "pong") return;
|
||||||
if (onMessage) onMessage(data.data.updates);
|
if (data.type && data.data) {
|
||||||
const msg = data.data.updates[0];
|
console.log("收到消息:", getMessageTypeName(data.type), data.data);
|
||||||
if (!msg) return;
|
if (onMessage) onMessage({ ...data.data, type: data.type });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (onMessage && data.updates) onMessage(data.updates);
|
||||||
|
const msg = data.updates[0];
|
||||||
|
if (msg) {
|
||||||
console.log("收到消息:", getMessageTypeName(msg.constructor), msg);
|
console.log("收到消息:", getMessageTypeName(msg.constructor), msg);
|
||||||
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
if (msg.constructor === MESSAGETYPES.BackToGame) {
|
||||||
const pages = getCurrentPages();
|
const pages = getCurrentPages();
|
||||||
@@ -84,6 +89,7 @@ function createWebSocket(token, onMessage) {
|
|||||||
} else if (msg.constructor === MESSAGETYPES.DeviceOffline) {
|
} else if (msg.constructor === MESSAGETYPES.DeviceOffline) {
|
||||||
uni.$emit("update-online");
|
uni.$emit("update-online");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 错误处理
|
// 错误处理
|
||||||
|
|||||||
Reference in New Issue
Block a user