添加设备在线离线处理
This commit is contained in:
@@ -11,7 +11,7 @@ import { getRoomAPI, joinRoomAPI, isGamingAPI, getBattleDataAPI } from "@/apis";
|
||||
import useStore from "@/store";
|
||||
import { storeToRefs } from "pinia";
|
||||
const store = useStore();
|
||||
const { user } = storeToRefs(store);
|
||||
const { user, device, online } = storeToRefs(store);
|
||||
import { debounce } from "@/util";
|
||||
|
||||
const showModal = ref(false);
|
||||
@@ -19,7 +19,33 @@ const warnning = ref("");
|
||||
const roomNumber = ref("");
|
||||
const data = ref({});
|
||||
|
||||
const checkBeforeEnter = async () => {
|
||||
if (!device.value.deviceId) {
|
||||
uni.showToast({
|
||||
title: "请先绑定设备",
|
||||
icon: "none",
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (!online.value) {
|
||||
uni.showToast({
|
||||
title: "智能弓未连接",
|
||||
icon: "none",
|
||||
});
|
||||
return true;
|
||||
}
|
||||
if (!user.value.trio) {
|
||||
uni.showToast({
|
||||
title: "请先完成新手试炼",
|
||||
icon: "none",
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
const enterRoom = debounce(async () => {
|
||||
if (checkBeforeEnter()) return;
|
||||
const isGaming = await isGamingAPI();
|
||||
if (isGaming) {
|
||||
uni.$showHint(1);
|
||||
@@ -54,6 +80,7 @@ const enterRoom = debounce(async () => {
|
||||
}
|
||||
});
|
||||
const onCreateRoom = async () => {
|
||||
if (checkBeforeEnter()) return;
|
||||
const isGaming = await isGamingAPI();
|
||||
if (isGaming) {
|
||||
uni.$showHint(1);
|
||||
|
||||
Reference in New Issue
Block a user