diff --git a/src/components/Matching.vue b/src/components/Matching.vue
new file mode 100644
index 0000000..3ed1ac3
--- /dev/null
+++ b/src/components/Matching.vue
@@ -0,0 +1,190 @@
+
+
+
+
+
+
+
+
+ {{ name }}
+
+
+
+
+ {{ name }}
+
+
+
+
+
+
+
+
diff --git a/src/components/Timer.vue b/src/components/Timer.vue
index 039eeb1..3c85f4d 100644
--- a/src/components/Timer.vue
+++ b/src/components/Timer.vue
@@ -21,7 +21,7 @@ watch(
() => props.seq,
() => {
if (props.seq > 0) {
- if(show.value) return;
+ if (show.value) return;
if (timer.value) clearInterval(timer.value);
count.value = props.countdown;
show.value = true;
@@ -38,6 +38,9 @@ watch(
if (timer.value) clearInterval(timer.value);
show.value = false;
}
+ },
+ {
+ immediate: true,
}
);
diff --git a/src/pages/melee-match.vue b/src/pages/melee-match.vue
index 9960ac6..eb1c089 100644
--- a/src/pages/melee-match.vue
+++ b/src/pages/melee-match.vue
@@ -11,6 +11,7 @@ import PlayerScore from "@/components/PlayerScore.vue";
import SButton from "@/components/SButton.vue";
import Avatar from "@/components/Avatar.vue";
import ScreenHint from "@/components/ScreenHint.vue";
+import Matching from "@/components/Matching.vue";
import { matchGameAPI, readyGameAPI } from "@/apis";
import { MESSAGETYPES, getMessageTypeName } from "@/constants";
import useStore from "@/store";
@@ -19,7 +20,6 @@ const store = useStore();
const { user } = storeToRefs(store);
const gameType = ref(0);
const teamSize = ref(0);
-const matching = ref(false);
const start = ref(false);
const startCount = ref(false);
const battleId = ref("");
@@ -33,18 +33,17 @@ const timerSeq = ref(0);
const players = ref([]);
const playersScores = ref({});
const halfTimeTip = ref(false);
+const onComplete = ref(null);
-onLoad((options) => {
+onLoad(async (options) => {
gameType.value = options.gameType;
teamSize.value = options.teamSize;
+ if (gameType.value && teamSize.value) {
+ await matchGameAPI(true, gameType.value, teamSize.value);
+ }
});
-async function startMatch() {
- await matchGameAPI(true, gameType.value, teamSize.value);
- matching.value = true;
-}
async function stopMatch() {
- await matchGameAPI(false, gameType.value, teamSize.value);
- matching.value = false;
+ uni.navigateBack();
}
async function readyToGo() {
if (battleId.value) {
@@ -65,16 +64,18 @@ async function onReceiveMessage(messages = []) {
console.log("收到消息:", getMessageTypeName(msg.constructor), msg);
}
if (msg.constructor === MESSAGETYPES.WaitForAllReady) {
- // 这里会掉多次;
- timerSeq.value += 1;
- battleId.value = msg.id;
- players.value = [
- ...msg.groupUserStatus.redTeam,
- ...msg.groupUserStatus.blueTeam,
- ];
- players.value.forEach((p) => {
- playersScores.value[p.id] = [];
- });
+ onComplete.value = () => {
+ // 这里会掉多次;
+ timerSeq.value += 1;
+ battleId.value = msg.id;
+ players.value = [
+ ...msg.groupUserStatus.redTeam,
+ ...msg.groupUserStatus.blueTeam,
+ ];
+ players.value.forEach((p) => {
+ playersScores.value[p.id] = [];
+ });
+ };
}
if (!start.value && msg.constructor === MESSAGETYPES.ShootSyncMeArrowID) {
scores.value.push(msg.target);
@@ -113,62 +114,73 @@ onMounted(() => {
});
onUnmounted(() => {
uni.$off("socket-inbox", onReceiveMessage);
- if (startMatch.value) {
- matchGameAPI(false, gameType.value, teamSize.value);
+ if (gameType.value && teamSize.value) {
+ matchGameAPI(true, gameType.value, teamSize.value);
}
});
-
+
-
-
-
-
- 请预先射几箭测试
- 请确保射击距离只有5米
+
+
+
+
+
+ 请预先射几箭测试
+ 请确保射击距离只有5米
+
+
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
- 上半场结束,休息一下吧:)
- 20秒后开始下半场
-
-
+
+
+
+
+
+ 上半场结束,休息一下吧:)
+ 20秒后开始下半场
+
+
+
+
+
+
- {{
- matching ? "取消匹配" : "开始匹配"
- }}
准备完毕
@@ -177,6 +189,7 @@ onUnmounted(() => {
diff --git a/src/static/matching-bg.png b/src/static/matching-bg.png
new file mode 100644
index 0000000..da0d887
Binary files /dev/null and b/src/static/matching-bg.png differ
diff --git a/src/static/practise-one-title.png b/src/static/practise-one-title.png
index 43ea0ae..a566c67 100644
Binary files a/src/static/practise-one-title.png and b/src/static/practise-one-title.png differ
diff --git a/src/static/practise-two-title.png b/src/static/practise-two-title.png
index 5c935d2..ca96c76 100644
Binary files a/src/static/practise-two-title.png and b/src/static/practise-two-title.png differ