1 line
16 KiB
JSON
1 line
16 KiB
JSON
{"ast":null,"code":"import \"core-js/modules/es.array.push.js\";\nimport { baccaratData, nnData, toningData, diceData, rouletteData } from \"@/utils/common\";\nimport { ref, computed, reactive, watch, onUnmounted } from \"vue\";\nimport { useStore } from \"vuex\";\nimport { useRouter, useRoute } from \"vue-router\";\nimport TableBaccarat from \"./TableBaccarat.vue\";\nimport TableLonghu from \"./TableLonghu.vue\";\nimport TableBullbull from \"./TableBullbull.vue\";\nimport TableToning from \"./TableToning.vue\";\nimport TableDice from \"./TableDice.vue\";\nimport TableRouletteFrench from \"./TableRouletteFrench.vue\";\nimport TableRouletteEuropean from \"./TableRouletteEuropean.vue\";\nimport { showToast } from \"vant\";\nimport { audioMp3 } from \"@/assets/js/sound.js\";\nexport default {\n name: \"PlayTable\",\n components: {\n TableBaccarat,\n TableLonghu,\n TableBullbull,\n TableToning,\n TableDice,\n TableRouletteFrench,\n TableRouletteEuropean\n },\n props: {\n game_id: {\n type: [String, Number],\n default: 1\n },\n table_id: {\n type: [String, Number],\n default: null\n },\n number_tab_id: {\n type: [String, Number],\n default: null\n },\n sendMode: {\n type: String,\n default: \"\"\n },\n is_scavenging: {\n type: [String, Number],\n default: 0\n },\n winArray: {\n type: Array,\n default: () => []\n },\n bet_amount_msg: {\n type: Object,\n default: () => ({\n // 百家乐&龙虎\n ...baccaratData.amount,\n // 牛牛\n ...nnData.amount,\n // 色碟\n ...toningData.amount,\n // 骰宝\n ...diceData.amount,\n // 轮盘\n ...rouletteData.amount\n })\n },\n can_bet_big_small: {\n type: [String, Number],\n default: 1\n },\n can_bet_luck_six: {\n type: [String, Number],\n default: 1\n },\n limit_money: {\n type: [String, Number],\n default: null\n },\n limit_money_pair: {\n type: [String, Number],\n default: null\n },\n limit_money_tie: {\n type: [String, Number],\n default: null\n },\n tableData: {\n type: [Object],\n default: () => {}\n }\n },\n setup(props) {\n let virtuallyTimer = null; //虚假下注定循环时器\n const store = useStore();\n const route = useRoute();\n const router = useRouter();\n const touch = ref(null);\n const openGameTimes = ref(0);\n const Type = computed(() => store.state.config.$Type);\n const Lang = computed(() => store.state.config.$lang);\n const online = computed(() => store.state.config.online);\n const betInfo = computed(() => store.state.socket.betInfo);\n const chooseChip = computed(() => store.state.app.chooseChip);\n const chipArry = computed(() => store.state.config.chipArry);\n const userInfo = computed(() => store.state.app.userInfo);\n const showOtherChip = computed(() => store.state.config.showOtherChip);\n const baccarat_type = computed(() => store.state.config.baccaratType);\n const rouletteType = computed(() => store.state.config.roulette_type);\n const breakOff = data => {\n let new_data;\n try {\n new_data = JSON.parse(JSON.stringify(data));\n } catch (err) {\n new_data = data;\n console.log(err);\n }\n return new_data;\n };\n const downChip = reactive({\n // 百家乐&龙虎\n ...breakOff(baccaratData.amount),\n // 牛牛\n ...breakOff(nnData.amount),\n // 色碟\n ...breakOff(toningData.amount),\n // 骰宝\n ...breakOff(diceData.amount),\n // 轮盘\n ...breakOff(rouletteData.amount)\n });\n const sendChip = reactive({\n // 百家乐&龙虎\n ...breakOff(baccaratData.amount),\n // 牛牛\n ...breakOff(nnData.amount),\n // 色碟\n ...breakOff(toningData.amount),\n // 骰宝\n ...breakOff(diceData.amount),\n // 轮盘\n ...breakOff(rouletteData.amount)\n });\n const chipArray = reactive({\n // 百家乐&龙虎\n ...breakOff(baccaratData.array),\n // 牛牛\n ...breakOff(nnData.array),\n // 色碟\n ...breakOff(toningData.array),\n // 骰宝\n ...breakOff(diceData.array),\n // 轮盘\n ...breakOff(rouletteData.array)\n });\n // 随机数生成\n const getRndInteger = (min, max) => {\n return Math.floor(Math.random() * (max - min)) + min;\n };\n const downBet = (e, type) => {\n store.commit(\"app/standbyTime\");\n const {\n value: chip,\n key\n } = chooseChip.value;\n if (props.sendMode == \"startBetCountDown\") {\n if (type == \"luck_six_amount\" && props.can_bet_luck_six != 1) {\n showToast(Lang.value[Type.value].to_bet_fail_7);\n } else if ((type == \"big_amount\" || type == \"small_amount\") && props.can_bet_big_small != 1) {\n showToast(Lang.value[Type.value].to_bet_fail_8);\n } else {\n touch.value = type;\n let chipVal = chip;\n // 轮盘法式四大特殊下注\n if (type == \"theThird\") {\n chipVal = chipVal * 6;\n } else if (type == \"orphans\") {\n chipVal = chipVal * 5;\n } else if (type == \"neighborsOfZero\") {\n chipVal = chipVal * 9;\n } else if (type == \"zeroGame\") {\n chipVal = chipVal * 4;\n }\n sendChip[type] = chipVal + (sendChip[type] || 0);\n downChip[type] = chipVal + (downChip[type] || 0);\n chipArray[type].push({\n x: `calc(${getRndInteger(30, 90)}% - 0.69rem)`,\n y: `calc(${getRndInteger(50, 90)}% - 0.55rem)`,\n key: `chip_${key}`,\n type: \"self\",\n uid: userInfo.value.id,\n value: chipVal\n });\n audioMp3([\"push\"]).Play();\n }\n }\n };\n const nameArray = [\n // 百家乐&龙虎\n ...baccaratData.key,\n // 牛牛\n ...nnData.key,\n // 色碟\n ...toningData.key,\n // 骰宝\n ...diceData.key,\n // 轮盘\n ...rouletteData.key];\n\n // 取消下注\n const cancelChip = () => {\n nameArray.forEach(key => {\n chipArray[key] = chipArray[key].filter(v => v.type != \"self\");\n downChip[key] = 0;\n sendChip[key] = 0;\n const socketChipArray = chipArray[key].filter(v => v.type == \"socket\");\n if (socketChipArray.length > 0) {\n socketChipArray.forEach(v => {\n downChip[key] = downChip[key] + v.value;\n });\n }\n touch.value = null;\n });\n };\n\n // 确认下注\n const confirmChip = () => {\n if (props.sendMode == \"startBetCountDown\") {\n touch.value = null;\n const betName = nameArray.filter(key => downChip[key] > 0);\n const downBet = {};\n if (betName.length > 0) {\n betName.forEach(v => {\n downBet[v] = sendChip[v];\n });\n }\n const sendData = {\n mode: \"toBet\",\n table_id: props.table_id,\n number_tab_id: props.number_tab_id\n };\n // 是否免佣\n if (props.game_id == 1) {\n sendData.baccarat_type = baccarat_type.value;\n }\n // 骰宝\n if (props.game_id == 7) {\n sendData.amount = downBet;\n }\n // 轮盘\n if (props.game_id == 8) {\n sendData.roulette_type = rouletteType.value;\n sendData.amount = downBet;\n }\n store.dispatch(\"socket/sendMsg\", {\n ...sendData,\n ...downBet\n });\n nameArray.forEach(key => {\n sendChip[key] = 0;\n });\n } else {\n showToast(Lang.value[Type.value].msg_game_not_start);\n cancelChip();\n audioMp3([\"alert\"]).Play();\n }\n };\n // 清空下注区筹码\n const resetChip = state => {\n let isHave = false;\n nameArray.forEach(key => {\n if (downChip[key] > 0) {\n isHave = true;\n }\n chipArray[key] = [];\n downChip[key] = 0;\n sendChip[key] = 0;\n touch.value = null;\n });\n if (isHave && !state) {\n audioMp3([\"push\"]).Play();\n }\n };\n // 洗牌排序\n const disorder = arr => {\n let clonrArr = arr.concat(),\n len = clonrArr.length,\n index = null;\n for (let i = 0; i < len; i++) {\n index = Math.floor(Math.random() * clonrArr.length);\n [clonrArr[index], clonrArr[i]] = [clonrArr[i], clonrArr[index]];\n }\n // 返回结果\n return clonrArr;\n };\n // 虚拟下注\n const virtuallyDownBet = () => {\n let typeArray = [];\n if (props.game_id == 1) {\n typeArray = [\"banker_amount\", \"player_amount\", \"tie_amount\", \"banker_pair_amount\", \"player_pair_amount\"];\n if (props.can_bet_luck_six == 1) {\n typeArray = [...typeArray, \"luck_six_amount\"];\n }\n if (props.can_bet_big_small == 1) {\n typeArray = [...typeArray, \"big_amount\", \"small_amount\"];\n }\n } else if (props.game_id == 2) {\n typeArray = [\"banker_amount\", \"player_amount\", \"tie_amount\"];\n } else if (props.game_id == 4 || props.game_id == 5) {\n typeArray = [...nnData.key];\n } else if (props.game_id == 6) {\n typeArray = [...toningData.key];\n } else if (props.game_id == 7) {\n typeArray = [...diceData.key];\n } else if (props.game_id == 8) {\n typeArray = [...rouletteData.key];\n }\n const cut = getRndInteger(1, 9);\n const virtuallyChipArry = disorder(chipArry.value.slice(0, cut));\n typeArray = disorder(typeArray);\n const people = getRndInteger(1, 8);\n // 限红限制\n // limit_money: \"10-10000\"\n // limit_money_pair: \"20-10000\"\n // limit_money_tie: \"20-10000\"\n let normalLimit = 10000,\n // pairLimit = 10000,\n tieLimit = 10000;\n try {\n if (props.limit_money) {\n normalLimit = props.limit_money.split(\"-\")[1];\n }\n if (props.limit_money_tie) {\n tieLimit = props.limit_money_tie.split(\"-\")[1];\n }\n // if (props.limit_money_pair) {\n // pairLimit = props.limit_money_pair.split(\"-\")[1]\n // }\n } catch (err) {\n console.log(err);\n }\n for (let i = people; i--; i > 0) {\n let {\n value: chip,\n key\n } = virtuallyChipArry[getRndInteger(0, virtuallyChipArry.length - 1)];\n const type = typeArray[getRndInteger(0, typeArray.length)];\n if ([\"banker_pair_amount\", \"player_pair_amount\"].includes(type)) {\n // 对子限红\n if (chip > tieLimit * 0.5) {\n chip = chipArry.value[0].chip;\n key = chipArry.value[0].key;\n }\n } else if ([\"tie_amount\"].includes(type)) {\n // 和限红\n if (chip > tieLimit * 0.5) {\n chip = chipArry.value[0].chip;\n key = chipArry.value[0].key;\n }\n } else if ([\"big_amount\", \"small_amount\", \"luck_six_amount\"].includes(type)) {\n if (chip > normalLimit * 0.3) {\n chip = chipArry.value[0].chip;\n key = chipArry.value[0].key;\n }\n } else {\n // 其他限红\n if (chip > normalLimit * 0.5) {\n chip = chipArry.value[0].chip;\n key = chipArry.value[0].key;\n }\n }\n\n // console.log(type, chip, props)\n chipArray[type].push({\n x: `calc(${getRndInteger(30, 90)}% - 0.69rem)`,\n y: `calc(${getRndInteger(50, 90)}% - 0.55rem)`,\n key: `chip_${key}`,\n type: \"virtually\",\n uid: 0,\n value: chip\n });\n const virtuallyData = {\n table_id: props.table_id,\n sendMode: \"toBet\",\n betAmountMsg: {\n [type]: chip\n }\n };\n store.dispatch(\"socket/updateVirtually\", virtuallyData);\n }\n };\n // 离开销毁\n onUnmounted(() => {\n // console.log(\"离开页面\", virtuallyTimer)\n store.commit(\"socket/updateBetInfo\", []);\n clearInterval(virtuallyTimer);\n virtuallyTimer = null;\n nameArray.forEach(key => {\n downChip[key] = 0;\n });\n });\n // 监听路由切换\n watch(() => [route.query], () => {\n openGameTimes.value = 0;\n resetChip();\n clearInterval(virtuallyTimer);\n virtuallyTimer = null;\n }, {\n immediate: true,\n deep: true\n });\n // 过滤虚拟下注筹码\n watch(() => [showOtherChip.value], ([val]) => {\n if (val) {\n nameArray.forEach(key => {\n chipArray[key] = chipArray[key].filter(v => v.type != \"virtually\");\n downChip[key] = 0;\n sendChip[key] = 0;\n const socketChipArray = chipArray[key].filter(v => v.type == \"socket\");\n if (socketChipArray.length > 0) {\n socketChipArray.forEach(v => {\n downChip[key] = downChip[key] + v.value;\n });\n }\n });\n }\n }, {\n immediate: true,\n deep: true\n });\n watch(() => [props.sendMode], ([mode]) => {\n if (mode == \"startBetCountDown\") {\n if (showOtherChip.value) {\n if (virtuallyTimer == null) {\n virtuallyTimer = setInterval(() => {\n virtuallyDownBet();\n }, 1000);\n }\n } else {\n clearInterval(virtuallyTimer);\n }\n } else if (mode == \"toBet\") {\n openGameTimes.value = 0;\n nameArray.forEach(key => {\n chipArray[key].forEach(v => {\n if (v.type == \"self\") {\n v.type = \"socket\";\n }\n });\n });\n } else if (mode == \"endBet\") {\n cancelChip();\n clearInterval(virtuallyTimer);\n virtuallyTimer = null;\n } else if (mode == \"startBet\") {\n const outRoomTimes = store.state.config.outRoomTimes;\n // 记录开局次数 操过N次不下注退出房间\n if (openGameTimes.value >= outRoomTimes) {\n router.replace({\n name: store.state.app.routerStack\n });\n } else {\n openGameTimes.value += 1;\n }\n }\n });\n watch(() => [online.value, betInfo.value], ([onlineValue, betInfoValue]) => {\n if (onlineValue) {\n if (betInfoValue.length > 0) {\n // console.log(betInfoValue)\n betInfoValue.forEach(v => {\n if (v.table_id == props.table_id) {\n nameArray.forEach(key => {\n if (v.game_id == 6) {\n downChip[key] = parseInt(v.toning_amount[key] || 0);\n } else if (v.game_id == 7) {\n downChip[key] = parseInt(v.dice_amount[key] || 0);\n } else if (v.game_id == 8) {\n store.commit(\"config/rouletteLockTable\", true);\n store.commit(\"config/switchRouletteType\", v.roulette_type);\n downChip[key] = parseInt(v.roulette_amount[key] || 0);\n } else {\n downChip[key] = parseInt(v[key] || 0);\n }\n });\n }\n });\n }\n }\n }, {\n immediate: true,\n deep: true\n });\n return {\n Type,\n Lang,\n downChip,\n touch,\n chipArray,\n baccarat_type,\n rouletteType,\n downBet,\n resetChip,\n cancelChip,\n confirmChip\n };\n }\n};","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]} |