update:对接会员限制次数
This commit is contained in:
@@ -3,12 +3,15 @@ import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||
import Container from "@/components/Container.vue";
|
||||
import Matching from "@/components/Matching.vue";
|
||||
import ModalDialog from "@/components/ModalDialog.vue";
|
||||
import { matchGameAPI, getBattleAPI } from "@/apis";
|
||||
import { MESSAGETYPESV2 } from "@/constants";
|
||||
import { isLimitError } from "@/util";
|
||||
|
||||
const gameType = ref(0);
|
||||
const teamSize = ref(0);
|
||||
const onComplete = ref(null);
|
||||
const showLimitModal = ref(false);
|
||||
|
||||
/** 匹配超时计时器,用于检测 WS 消息丢失或真正超时 */
|
||||
const matchTimeoutTimer = ref(null);
|
||||
@@ -58,6 +61,18 @@ async function stopMatch() {
|
||||
uni.$showHint(3);
|
||||
}
|
||||
|
||||
const closeLimitModal = () => {
|
||||
showLimitModal.value = false;
|
||||
uni.navigateBack();
|
||||
};
|
||||
|
||||
const goVipPage = () => {
|
||||
showLimitModal.value = false;
|
||||
uni.redirectTo({
|
||||
url: "/pages/member/be-vip",
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 取消匹配,带容错处理:
|
||||
* - 取消成功 → 返回大厅
|
||||
@@ -136,10 +151,19 @@ onBeforeUnmount(() => {
|
||||
|
||||
onShow(async () => {
|
||||
if (gameType.value && teamSize.value) {
|
||||
matchGameAPI(true, gameType.value, teamSize.value);
|
||||
// 启动超时计时器,防止 WS 消息丢失或长时间无对手导致用户卡死
|
||||
clearMatchTimeout();
|
||||
matchTimeoutTimer.value = setTimeout(handleMatchTimeout, MATCH_TIMEOUT_MS);
|
||||
try {
|
||||
await matchGameAPI(true, gameType.value, teamSize.value);
|
||||
// 启动超时计时器,防止 WS 消息丢失或长时间无对手导致用户卡死
|
||||
clearMatchTimeout();
|
||||
matchTimeoutTimer.value = setTimeout(handleMatchTimeout, MATCH_TIMEOUT_MS);
|
||||
} catch (error) {
|
||||
clearMatchTimeout();
|
||||
if (isLimitError(error)) {
|
||||
showLimitModal.value = true;
|
||||
return;
|
||||
}
|
||||
uni.navigateBack();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -154,6 +178,14 @@ onHide(() => {
|
||||
<Matching :stopMatch="stopMatch" :onComplete="onComplete" />
|
||||
</view>
|
||||
</Container>
|
||||
<ModalDialog
|
||||
:show="showLimitModal"
|
||||
:content="'今日排位赛次数已经用完\n开通会员可增加次数'"
|
||||
cancelText="知道了"
|
||||
confirmText="去开通"
|
||||
:onCancel="closeLimitModal"
|
||||
:onConfirm="goVipPage"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user