diff --git a/main.js b/main.js index 4f78e61..8172689 100644 --- a/main.js +++ b/main.js @@ -12,6 +12,20 @@ import { Vue.config.productionTip = false; Vue.prototype.$api = api; +const formatK = (val) => { + if (val === null || val === undefined || val === '') return val + if (typeof val === 'string' && val.includes('-')) { + return val.split('-').map(s => formatK(isNaN(s) ? s : Number(s))).join('-') + } + const n = Number(val) + if (isNaN(n)) return val + if (n >= 1000 || n <= -1000) { + const k = n / 1000 + return (k % 1 === 0 ? k.toFixed(0) : k) + 'K' + } + return val +} +Vue.prototype.$fk = formatK Vue.use(uView); Vue.use(router); App.mpType = "app"; diff --git a/pages/index.vue b/pages/index.vue index 18db4e0..4b86054 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -52,7 +52,7 @@ {{ $lang.onlineCount }} - 2506 + {{ onlineNum }} @@ -75,7 +75,7 @@ {{ item.table_name }} - {{ $lang.maxLimit }}:50000 {{ $lang.minLimit }}:20 + {{ $lang.maxLimit }}:{{ $fk(item.limit_money ? item.limit_money.split('-')[1] : 0) }} {{ $lang.minLimit }}:{{ item.limit_money ? item.limit_money.split('-')[0] : 0 }} @@ -94,7 +94,7 @@ }" :class="getCellClass(cell.result)" > - {{ getResultText(cell.result) }} + {{ getResultText(cell.result, item.game_id) }} @@ -164,6 +164,7 @@ export default { allTables: [], loading: false, timer: null, + onlineNum: 0, // Roadmap config cellWidth: 16.5, // slightly adjusted for mobile fit @@ -229,11 +230,18 @@ export default { }); if (res.Success && res.Data) { this.processData(res.Data); + this.updateOnlineNum(); } } catch(e) { console.error(e); } }, + updateOnlineNum() { + const hour = new Date().getHours(); + const base = 800; + const extra = (hour >= 0 && hour < 6) ? 200 : 0; + this.onlineNum = base + extra + Math.floor(Math.random() * 100); + }, processData(data) { // Transform data for UI this.allTables = data.map(item => { @@ -273,7 +281,12 @@ export default { if (result === 3) return 'cell-green'; return ''; }, - getResultText(result) { + getResultText(result, gameId) { + if (gameId == 2) { + if (result === 1) return '龙'; + if (result === 2) return '虎'; + if (result === 3) return '和'; + } if (result === 1) return '庄'; if (result === 2) return '闲'; if (result === 3) return '和';