fix: bet options

This commit is contained in:
hiyu 2024-06-19 18:20:08 +07:00
parent 45b06b47c4
commit 01a7f363d4

View File

@ -50,10 +50,10 @@ const gameInfo = reactive({
}); });
const choices = ref([ const choices = ref([
{ id: "1", name: "IDOL 1", active: false }, // { id: "1", name: "IDOL 1", active: false },
{ id: "2", name: "IDOL 2", active: false }, // { id: "2", name: "IDOL 2", active: false },
{ id: "3", name: "IDOL 3", active: false }, // { id: "3", name: "IDOL 3", active: false },
{ id: "4", name: "IDOL 4", active: false }, // { id: "4", name: "IDOL 4", active: false },
]); ]);
const choicesSelected = computed(() => { const choicesSelected = computed(() => {
@ -89,7 +89,7 @@ onUnmounted(() => {
}); });
const toggleChoice = (id) => { const toggleChoice = (id) => {
const idx = choices.value.findIndex(e => e.id === id); const idx = choices.value.findIndex((e) => e.id === id);
if (idx === -1) return; if (idx === -1) return;
choices.value[idx].active = !choices.value[idx].active; choices.value[idx].active = !choices.value[idx].active;
if (!choices.value[idx].active) { if (!choices.value[idx].active) {
@ -108,6 +108,16 @@ const getGameHistory = () => {
); );
}; };
const GameInfo = () => {
handleRequest(axios.get(API.GAME_INFO + "/" + id)).then(
(res) => {
if (res.success) {
choices.value = res.data.info?.betOptions ?? []
}
}
)
};
const confirmOrder = () => { const confirmOrder = () => {
if (choicesSelected.value.length === 0) { if (choicesSelected.value.length === 0) {
return showFailToast("Hãy chọn 1 con số"); return showFailToast("Hãy chọn 1 con số");
@ -122,10 +132,10 @@ const confirmOrder = () => {
const cancelOrder = () => { const cancelOrder = () => {
choices.value.forEach((c) => { choices.value.forEach((c) => {
c.active = false c.active = false;
}); });
amount.value = "" amount.value = "";
} };
const submit = () => { const submit = () => {
const data = { const data = {
@ -193,6 +203,9 @@ const formatResultText2 = (r) => {
}, 0); }, 0);
return s % 2 ? "IDOL 3" : "IDOL 4"; return s % 2 ? "IDOL 3" : "IDOL 4";
}; };
GameInfo();
</script> </script>
<template> <template>
<div class="container page"> <div class="container page">
@ -406,8 +419,21 @@ const formatResultText2 = (r) => {
</li> </li>
</ul> </ul>
<div class="sub-bar"> <div class="sub-bar">
<van-button type="default" class="item cancel-btn" color="#979799" plain @click="cancelOrder">Hủy bình chọn</van-button> <van-button
<van-button type="default" class="item" color='linear-gradient(270deg, #c24491, #775fd9)' @click="submit">Xác nhận</van-button> type="default"
class="item cancel-btn"
color="#979799"
plain
@click="cancelOrder"
>Hủy bình chọn</van-button
>
<van-button
type="default"
class="item"
color="linear-gradient(270deg, #c24491, #775fd9)"
@click="submit"
>Xác nhận</van-button
>
</div> </div>
</div> </div>
</van-popup> </van-popup>
@ -452,5 +478,4 @@ const formatResultText2 = (r) => {
.cancel-btn :deep(.van-button__text) { .cancel-btn :deep(.van-button__text) {
color: currentColor !important; color: currentColor !important;
} }
</style> </style>