GamePortrait/node_modules/.cache/babel-loader/ba74e7c2e8e857dd82621b74693ecd17c0f8d65da1f0d1724ffc39065dd1c84b.json

1 line
18 KiB
JSON

{"ast":null,"code":"import \"core-js/modules/es.array.push.js\";\nimport VueSocketIO from \"vue-socket.io\";\nimport SocketIO from \"socket.io-client\";\nimport router from \"@/router/index\";\nimport $store from \"@/store\";\nimport { getSingletable, getGoodRoad } from \"@/utils/api\";\nimport { sendScanResult, updateBetAmount, resetCardInfo, baccaratData, nnData, toningData, diceData, rouletteData } from \"@/utils/common\";\nimport { showToast, showLoadingToast, closeToast, showDialog } from \"vant\";\nlet socket = null;\nconst state = {\n io: null,\n betInfo: [],\n goodRoadList: []\n};\nconst mutations = {\n link(state, {\n id,\n username,\n login_token\n }) {\n const sockUrl = $store.state.config.sockUrl;\n socket = new VueSocketIO({\n debug: false,\n connection: SocketIO(`${sockUrl}/?connect=user&userid=${id}&account=${username}&login_token=${login_token} `, {\n transports: [\"websocket\"]\n }),\n vuex: {\n store: $store,\n actionPrefix: \"socket_\",\n mutationPrefix: \"socket_\"\n }\n });\n state.io = socket.io;\n },\n // 重连成功回调\n socket_reconnect_failed() {\n console.log(\"重连失败\");\n showLoadingToast({\n forbidClick: true,\n message: $store.state.config.$lang[$store.state.config.$Type].reconnection_failed\n });\n },\n socket_reconnect(socket) {\n state.io = socket.io;\n showLoadingToast({\n forbidClick: true,\n message: $store.state.config.$lang[$store.state.config.$Type].reconnected_success\n });\n },\n socket_disconnect(socket) {\n state.io = socket.io;\n showLoadingToast({\n duration: 0,\n forbidClick: true,\n message: $store.state.config.$lang[$store.state.config.$Type].reconnecting\n });\n },\n // 链接登录回调 更新钱\n socket_onlineLogin(state, data) {\n closeToast();\n const {\n status,\n money\n } = data;\n if (status) {\n $store.commit(\"app/updateUserInfo\", {\n money\n });\n }\n },\n // 获取所有座子状态\n socket_getState(state, data) {\n const {\n table_id,\n status,\n round = null\n } = data;\n if (status && round) {\n const sendMode = \"getState\";\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 开始抢庄\n socket_startRob(state, data) {\n const {\n table_id,\n status,\n round\n } = data;\n if (status) {\n const sendMode = \"startRob\";\n const rob_status = round.number_tab_status.rob_status;\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n sendMode,\n rob_status\n });\n }\n },\n // 开始游戏\n socket_startBet(state, data) {\n const {\n table_id,\n status\n } = data;\n if (status) {\n const sendMode = \"startBet\";\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n sendMode\n });\n }\n },\n // 抢庄倒计时\n socket_startRobCountDown(state, data) {\n const {\n table_id,\n count_down,\n status\n } = data;\n if (status) {\n const sendMode = \"startRobCountDown\";\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n count_down,\n sendMode\n });\n }\n },\n // 停止抢庄\n socket_endRob(state, data) {\n const {\n table_id,\n status,\n round\n } = data;\n if (status) {\n const sendMode = \"endRob\";\n const rob_status = round.number_tab_status.rob_status;\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n sendMode,\n rob_status\n });\n }\n },\n // 抢庄结果\n socket_toRob(state, data) {\n const {\n table_id,\n RobMsg,\n status\n } = data;\n if (status) {\n const sendMode = \"toRob\";\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n RobMsg,\n sendMode\n });\n } else {\n showToast(\"抢庄失败\");\n }\n },\n //下注倒计时\n socket_startBetCountDown(state, data) {\n const {\n table_id,\n count_down,\n status\n } = data;\n if (status) {\n const sendMode = \"startBetCountDown\";\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n count_down,\n sendMode\n });\n }\n },\n // 下注成功回调\n socket_toBet(state, data) {\n const {\n status,\n money,\n table_id,\n betAmountMsg\n } = data;\n if (status) {\n const sendMode = \"toBet\";\n $store.commit(\"app/updateUserInfo\", {\n money\n });\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n sendMode,\n betAmountMsg\n });\n } else {\n const sendMode = \"toBetFlase\";\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n sendMode\n });\n showToast($store.state.config.$lang[$store.state.config.$Type][data.msg]);\n }\n },\n // 下注取消下注回调\n socket_cancelBet(state, data) {\n const {\n status,\n money,\n table_id\n } = data;\n if (status) {\n const sendMode = \"cancelBet\";\n $store.commit(\"app/updateUserInfo\", {\n money\n });\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n sendMode\n });\n }\n },\n //停止下注\n socket_endBet(state, data) {\n const {\n status,\n table_id\n } = data;\n if (status) {\n const sendMode = \"endBet\";\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n sendMode\n });\n }\n },\n // 百家乐结果\n socket_openingBaccaratResult(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"openingBaccaratResult\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 龙虎结果\n socket_openingDtResult(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"openingDtResult\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 牛牛结果\n socket_openingNnResult(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"openingNnResult\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 三卡NN结果\n socket_openingTcResult(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"openingTcResult\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 色碟结果\n socket_openingToningResult(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"openingToningResult\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 骰宝结果\n socket_openingDiceResult(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"openingDiceResult\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 轮盘结果\n socket_openingRouletteResult(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"openingRouletteResult\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 换靴\n socket_changeBoot(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"changeBoot\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n // 更新余额\n socket_opening(state, data) {\n const {\n status,\n round\n } = data;\n if (status) {\n $store.commit(\"app/updateUserInfo\", {\n money: round.money\n });\n }\n },\n // 重置靴\n socket_resetBoot(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"resetBoot\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n socket_resetNumberTab(state, data) {\n const {\n status,\n table_id,\n round\n } = data;\n if (status) {\n const sendMode = \"resetNumberTab\";\n $store.dispatch(\"socket/updateSingletable\", {\n table_id,\n sendMode,\n round\n });\n }\n },\n //扫牌\n socket_sendScanResult(state, data) {\n const {\n table_id,\n round,\n status\n } = data;\n if (status) {\n const sendMode = \"sendScanResult\";\n const flopTime = $store.state.config.flopTime;\n setTimeout(() => {\n $store.dispatch(\"socket/updateTable\", {\n table_id,\n round,\n sendMode\n });\n }, flopTime);\n }\n },\n // 顶下线\n socket_RepeatedEntry(state, data) {\n const {\n status\n } = data;\n if (status) {\n showDialog({\n title: $store.state.config.$lang[$store.state.config.$Type].tips,\n message: $store.state.config.$lang[$store.state.config.$Type].offline\n }).then(() => {\n $store.commit(\"app/removeUserInfo\");\n });\n }\n },\n updateBetInfo(state, data) {\n state.betInfo = data;\n }\n};\nconst actions = {\n // 发送socket\n sendMsg(store, data) {\n // console.log(data)\n const {\n id: uid\n } = $store.state.app.userInfo;\n socket.io.emit(data.mode, {\n user_id: uid,\n ...data\n });\n },\n // 更新单桌信息\n updateTable(store, data) {\n const tableData = $store.getters.getTableById(data.table_id);\n if (tableData && tableData.id) {\n tableData.sendMode = data.sendMode;\n switch (data.sendMode) {\n case \"getState\":\n // 恢复下注\n if (data.round && data.round.bet && data.round.bet.length > 0) {\n const {\n id\n } = $store.state.app.userInfo;\n const info = data.round.bet.filter(v => v.user_id == id);\n if (info.length > 0) {\n store.commit(\"updateBetInfo\", info);\n }\n } else {\n store.commit(\"updateBetInfo\", []);\n }\n\n //恢复翻牌\n tableData.bet_status = data.round.bet_status;\n if (data.round && data.round.show_card && data.round.show_card.length > 0) {\n data.round.show_card.forEach(v => {\n const cardInfo = {\n round: v\n };\n sendScanResult(tableData, cardInfo);\n });\n }\n $store.commit(\"config/updateOnline\", true);\n break;\n case \"startBet\":\n //开始游戏\n tableData.round = {};\n break;\n case \"startRob\":\n //开始抢庄\n tableData.rob_status = data.rob_status || 0;\n break;\n case \"toRob\":\n //抢庄结果\n tableData.rob_banker_id = data.RobMsg.rob_banker_id;\n tableData.rob_banker_username = data.RobMsg.rob_banker_username;\n break;\n case \"endRob\":\n tableData.rob_status = data.rob_status || 2;\n break;\n case \"startRobCountDown\":\n tableData.rob_count_down = data.count_down;\n break;\n case \"startBetCountDown\":\n tableData.count_down = data.count_down;\n break;\n case \"toBet\":\n //下注\n updateBetAmount(tableData, data);\n break;\n case \"cancelBet\":\n //撤销下注\n break;\n case \"endBet\":\n //结束游戏\n tableData.count_down = 0;\n if (tableData.is_scavenging == 1) {\n tableData.bet_status = 2;\n }\n break;\n case \"sendScanResult\":\n //扫牌\n sendScanResult(tableData, data);\n tableData.round = data.round;\n break;\n }\n Object.apply(tableData, {\n ...data\n });\n }\n },\n // 更新虚假金额\n updateVirtually(store, data) {\n if (data && data.table_id) {\n const tableData = $store.getters.getTableById(data.table_id);\n if (tableData.id) {\n updateBetAmount(tableData, data);\n }\n }\n },\n // getResult\n updateSingletable(store, socketData) {\n const {\n type = null,\n table_id,\n sendMode,\n round = {}\n } = socketData;\n const tableData = $store.getters.getTableById(table_id);\n const {\n id: uid,\n api_token\n } = $store.state.app.userInfo;\n if (tableData && tableData.id) {\n if (type == \"update\") {\n showLoadingToast({\n message: `${$store.state.config.$lang[$store.state.config.$Type].loading}...`,\n forbidClick: true\n });\n }\n getSingletable({\n table_id: tableData.id,\n user_id: uid,\n api_token\n }).then(res => {\n if (res.Success == 1) {\n const revertData = res.Data;\n // console.log(revertData)\n // 处理幸运6 大小规则\n if (tableData.game_id == 1) {\n tableData.can_bet_big_small = revertData.can_bet_big_small;\n tableData.can_bet_luck_six = revertData.can_bet_luck_six;\n }\n if (type != \"update\") {\n tableData.previous_number_tab_id = round.previous_number_tab_id;\n } else {\n tableData.sendMode = \"\";\n }\n tableData.boot_id = revertData.boot_id;\n tableData.boot_num = revertData.boot_num;\n tableData.number_tab_id = revertData.number_tab_id;\n tableData.number_tab_number = revertData.number_tab_number;\n tableData.ludan = revertData.ludan;\n if (type != \"update\") {\n // 处理牛牛逻辑\n if (tableData.game_id == 4 || tableData.game_id == 5) {\n tableData.rob_status = 0;\n tableData.rob_banker_id = 0;\n tableData.rob_banker_username = null;\n }\n let gameAmountKey = [];\n if (tableData.game_id == 1) {\n store.dispatch(\"getGoodTabData\");\n tableData.banker_pair_Count = revertData.banker_pair_Count;\n tableData.player_pair_Count = revertData.player_pair_Count;\n tableData.bankerCount = revertData.bankerCount;\n tableData.playerCount = revertData.playerCount;\n tableData.tieCount = revertData.tieCount;\n tableData.ludan_banker = revertData.ludan_banker;\n tableData.ludan_player = revertData.ludan_player;\n gameAmountKey = baccaratData.key;\n } else if (tableData.game_id == 2) {\n tableData.bankerCount = revertData.bankerCount;\n tableData.playerCount = revertData.playerCount;\n tableData.tieCount = revertData.tieCount;\n gameAmountKey = [\"banker_amount\", \"player_amount\", \"tie_amount\"];\n } else if (tableData.game_id == 4 || tableData.game_id == 5) {\n tableData.player_1_count = revertData.player_1_count;\n tableData.player_2_count = revertData.player_2_count;\n tableData.player_3_count = revertData.player_3_count;\n gameAmountKey = nnData.key;\n } else if (tableData.game_id == 6) {\n tableData.count = revertData.count;\n gameAmountKey = toningData.key;\n } else if (tableData.game_id == 7) {\n tableData.count = revertData.count;\n gameAmountKey = diceData.key;\n } else if (tableData.game_id == 8) {\n tableData.count = revertData.count;\n gameAmountKey = rouletteData.key;\n }\n // 清0 下注金额\n if (gameAmountKey.length) {\n gameAmountKey.forEach(v => {\n tableData.bet_amount_msg[v] = 0;\n });\n }\n resetCardInfo(tableData);\n }\n tableData.sendMode = sendMode || \"\";\n tableData.round = round;\n if (type == \"update\") {\n resetCardInfo(tableData);\n store.dispatch(\"sendMsg\", {\n mode: \"getState\",\n table_id: tableData.id\n });\n }\n if (revertData.isout == 1) {\n showToast(\"你已经断开连接!\");\n setTimeout(() => {\n localStorage.removeItem(\"userInfo\");\n router.push({\n path: \"/\"\n });\n window.location.reload();\n }, 2000);\n }\n } else {\n localStorage.removeItem(\"userInfo\");\n router.push({\n path: \"/\"\n });\n window.location.reload();\n }\n }).catch(err => {\n console.log(err);\n }).finally(() => {\n if (type == \"update\") {\n closeToast();\n }\n });\n }\n },\n getGoodTabData({\n state\n }) {\n const {\n id: uid,\n api_token\n } = $store.state.app.userInfo;\n getGoodRoad({\n user_id: uid,\n api_token\n }).then(res => {\n if (res.Success == 1) {\n state.goodRoadList = res.Data;\n }\n }).catch(err => {\n console.log(err);\n });\n }\n};\nexport default {\n namespaced: true,\n state,\n mutations,\n actions\n};","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}