@jetthai/cuora 1.0.25 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/api/activity.js +46 -0
- package/api/auth.js +15 -0
- package/api/common.js +4 -0
- package/api/game.js +32 -0
- package/api/index.js +9 -0
- package/api/mailbox.js +20 -0
- package/api/payment.js +63 -0
- package/api/user.js +19 -0
- package/index.js +3 -58
- package/machine/activity/activity.js +73 -0
- package/machine/activity/continue_deposit_activity.js +132 -0
- package/machine/activity/deposit_activity.js +86 -0
- package/machine/activity/diamond_shop_activity.js +163 -0
- package/machine/activity/fafafa_activity.js +131 -0
- package/machine/activity/index.js +21 -0
- package/machine/activity/invite_friends_activity.js +121 -0
- package/machine/activity/ranking_activity.js +76 -0
- package/machine/activity/return_bonus_activity.js +150 -0
- package/machine/activity/specify_bets_activity.js +116 -0
- package/machine/auth.js +245 -0
- package/machine/auth_otp.js +191 -0
- package/machine/check.js +113 -0
- package/machine/common.js +163 -0
- package/machine/deposit.js +236 -0
- package/machine/error.js +72 -0
- package/machine/game.js +265 -0
- package/machine/game_favorite.js +123 -0
- package/machine/game_search.js +248 -0
- package/machine/inbox.js +246 -0
- package/machine/index.js +37 -0
- package/machine/merge.js +57 -0
- package/machine/payment_data.js +81 -0
- package/machine/reward.js +73 -0
- package/machine/setting.js +37 -0
- package/machine/side.js +147 -0
- package/machine/withdraw.js +367 -0
- package/package.json +3 -2
- package/request/config.js +18 -0
- package/request/cookie.js +52 -0
- package/request/request.js +97 -0
- package/plugin/activity.js +0 -289
- package/plugin/core.js +0 -518
- package/plugin/game.js +0 -474
- package/plugin/inbox.js +0 -216
- package/plugin/information.js +0 -57
- package/plugin/job/network.js +0 -61
- package/plugin/payment.js +0 -257
- package/plugin/request.js +0 -225
- package/plugin/search.js +0 -277
- package/plugin/user.js +0 -198
package/plugin/game.js
DELETED
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
const api = {
|
|
2
|
-
getGameSHA: () => ({ method: 'get', url: 'game/list/v2/sha' }),
|
|
3
|
-
getGameMap: (code) => ({ method: 'get', url: 'game/list/v2/options', params: { code } }),
|
|
4
|
-
getGameStatus: () => ({ method: 'get', url: 'game/list/v2/status' }),
|
|
5
|
-
getGameCategory: ({ id, first }) => ({ method: 'get', url: 'game/list/v2/category', params: { id, first } }),
|
|
6
|
-
addFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/add', params: code }),
|
|
7
|
-
removeFavoriteGame: (code) => ({ method: 'post', url: 'game/myfavorite/remove', params: code }),
|
|
8
|
-
getStatements: () => ({ url: 'game/statements', method: 'get' }),
|
|
9
|
-
setPreference: ({ defaultCategory }) => ({ url: 'settings/preference', method: 'post', params: { defaultCategory } }),
|
|
10
|
-
playGame: (params) => ({ url: 'game/play', method: 'get', params }),
|
|
11
|
-
logoutGame: ({ uid_site, provider_id }) => ({ url: 'game/logout', method: 'get', params: { uid_site, provider_id } }),
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function createStore({ $request }) {
|
|
15
|
-
return {
|
|
16
|
-
namespaced: true,
|
|
17
|
-
state: () => ({
|
|
18
|
-
categoryId: null,
|
|
19
|
-
gameList: [],
|
|
20
|
-
virtualCategoryList: [],
|
|
21
|
-
gameMap: {},
|
|
22
|
-
inverseGameMap: {},
|
|
23
|
-
selectedPrimaryCategory: 'slot',
|
|
24
|
-
primaryCategoryList: [
|
|
25
|
-
{ category: 'SYSTEM_BIG_CATEGORY_SLOT', code: null, type: 'slot' },
|
|
26
|
-
{ category: 'SYSTEM_BIG_CATEGORY_TABLECARD', code: null, type: 'tablegame' },
|
|
27
|
-
{ category: 'SYSTEM_BIG_CATEGORY_FISHING', code: null, type: 'fish' },
|
|
28
|
-
{ category: 'SYSTEM_BIG_CATEGORY_VIP', code: null, type: 'vip' },
|
|
29
|
-
{ category: 'SYSTEM_BIG_CATEGORY_ARCADE', code: null, type: 'arcade' },
|
|
30
|
-
{ category: 'SYSTEM_BIG_CATEGORY_OLD', code: null, type: 'old' },
|
|
31
|
-
],
|
|
32
|
-
favorite: { category: 'SYSTEM_MY_FAVORITE', code: null, list: [] },
|
|
33
|
-
//
|
|
34
|
-
gameURL: null,
|
|
35
|
-
currentProvider: null,
|
|
36
|
-
currentGameId: null,
|
|
37
|
-
currentGameType: null,
|
|
38
|
-
isMatching: false,
|
|
39
|
-
statements: [],
|
|
40
|
-
gameTimer: null,
|
|
41
|
-
}),
|
|
42
|
-
getters: {
|
|
43
|
-
getCurrentProvider(state) {
|
|
44
|
-
return state.currentProvider || null
|
|
45
|
-
},
|
|
46
|
-
getCurrentGameId(state) {
|
|
47
|
-
return state.currentGameId || null
|
|
48
|
-
},
|
|
49
|
-
getCurrentPlaying(state, getters) {
|
|
50
|
-
return `${getters.getCurrentProvider}.${getters.getCurrentGameId}`
|
|
51
|
-
},
|
|
52
|
-
getCurrentGameType(state, getters) {
|
|
53
|
-
return state.currentGameType
|
|
54
|
-
},
|
|
55
|
-
currentGameURL(state) {
|
|
56
|
-
return state.gameURL
|
|
57
|
-
},
|
|
58
|
-
//
|
|
59
|
-
getCategoryId(state, getters) {
|
|
60
|
-
return state.categoryId
|
|
61
|
-
},
|
|
62
|
-
getGameList(state, getters) {
|
|
63
|
-
return state.gameList
|
|
64
|
-
},
|
|
65
|
-
getVirtualCategoryList(state, getters) {
|
|
66
|
-
return state.virtualCategoryList
|
|
67
|
-
},
|
|
68
|
-
getGameMap(state, getters) {
|
|
69
|
-
return state.gameMap
|
|
70
|
-
},
|
|
71
|
-
getInverseGameMap(state, getters) {
|
|
72
|
-
return state.inverseGameMap
|
|
73
|
-
},
|
|
74
|
-
getFavoriteList(state, getters) {
|
|
75
|
-
return state.favorite?.list || []
|
|
76
|
-
},
|
|
77
|
-
getFavoriteId(state, getters) {
|
|
78
|
-
return state.favorite.code
|
|
79
|
-
},
|
|
80
|
-
getPrimaryCategoryList(state) {
|
|
81
|
-
return state.primaryCategoryList
|
|
82
|
-
},
|
|
83
|
-
getSelectedPrimaryCategory(state, getters) {
|
|
84
|
-
return state.selectedPrimaryCategory
|
|
85
|
-
},
|
|
86
|
-
isMatching(state) {
|
|
87
|
-
return state.isMatching
|
|
88
|
-
},
|
|
89
|
-
getUserStatements(state) {
|
|
90
|
-
return state.statements
|
|
91
|
-
},
|
|
92
|
-
getGameTimer(state) {
|
|
93
|
-
return state.gameTimer
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
mutations: {
|
|
97
|
-
setCurrentProvider(state, data) {
|
|
98
|
-
state.currentProvider = data
|
|
99
|
-
},
|
|
100
|
-
setCurrentGameId(state, data) {
|
|
101
|
-
state.currentGameId = data
|
|
102
|
-
},
|
|
103
|
-
setCurrentGameType(state, data) {
|
|
104
|
-
state.currentGameType = data
|
|
105
|
-
},
|
|
106
|
-
setGameURL(state, url) {
|
|
107
|
-
if (url) {
|
|
108
|
-
url = url.replace('isAPP=false', 'isAPP=true')
|
|
109
|
-
}
|
|
110
|
-
state.gameURL = url
|
|
111
|
-
},
|
|
112
|
-
//
|
|
113
|
-
reset(state) {
|
|
114
|
-
state.categoryId = null
|
|
115
|
-
state.gameList = null
|
|
116
|
-
state.virtualCategoryList = []
|
|
117
|
-
state.gameMap = null
|
|
118
|
-
state.favorite = { category: 'SYSTEM_MY_FAVORITE', code: null, list: [] }
|
|
119
|
-
state.inverseGameMap = null
|
|
120
|
-
state.primaryCategoryList = [
|
|
121
|
-
{ category: 'SYSTEM_BIG_CATEGORY_SLOT', code: null, type: 'slot' },
|
|
122
|
-
{ category: 'SYSTEM_BIG_CATEGORY_TABLECARD', code: null, type: 'tablegame' },
|
|
123
|
-
{ category: 'SYSTEM_BIG_CATEGORY_FISHING', code: null, type: 'fish' },
|
|
124
|
-
{ category: 'SYSTEM_BIG_CATEGORY_VIP', code: null, type: 'vip' },
|
|
125
|
-
{ category: 'SYSTEM_BIG_CATEGORY_ARCADE', code: null, type: 'arcade' },
|
|
126
|
-
{ category: 'SYSTEM_BIG_CATEGORY_OLD', code: null, type: 'old' },
|
|
127
|
-
]
|
|
128
|
-
},
|
|
129
|
-
_setCategoryId(state, data) {
|
|
130
|
-
state.categoryId = data
|
|
131
|
-
},
|
|
132
|
-
setGameList(state, data) {
|
|
133
|
-
state.gameList = data
|
|
134
|
-
},
|
|
135
|
-
_setGameMap(state, data) {
|
|
136
|
-
state.gameMap = data
|
|
137
|
-
},
|
|
138
|
-
_appendGameMap(state, { key, value }) {
|
|
139
|
-
state.gameMap = { ...state.gameMap, [key]: value }
|
|
140
|
-
},
|
|
141
|
-
_setInverseGameMap(state, data) {
|
|
142
|
-
const inverseOption = {}
|
|
143
|
-
for (const key in data) {
|
|
144
|
-
try {
|
|
145
|
-
const arr = data[key]?.id.split('|')
|
|
146
|
-
const composedKey = `${arr[0]}_${arr[3]}`
|
|
147
|
-
inverseOption[composedKey] = key
|
|
148
|
-
} catch (err) {
|
|
149
|
-
console.log(`[Gamehall] Error: { key: ${key}, data: ${data[key]} }`)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
state.inverseGameMap = inverseOption
|
|
153
|
-
},
|
|
154
|
-
_appendInverseGameMap(state, { key, value }) {
|
|
155
|
-
const arr = value.id.split('|')
|
|
156
|
-
const composedKey = `${arr[0]}_${arr[3]}`
|
|
157
|
-
state.inverseGameMap = { ...state.inverseGameMap, [composedKey]: key }
|
|
158
|
-
},
|
|
159
|
-
_setFavorite(state, favorite) {
|
|
160
|
-
state.favorite = favorite
|
|
161
|
-
},
|
|
162
|
-
_setFavoriteList(state, codeList) {
|
|
163
|
-
state.favorite = { ...state.favorite, list: codeList }
|
|
164
|
-
},
|
|
165
|
-
_setPrimaryCategoryList(state, categories) {
|
|
166
|
-
const primaryCategories = [
|
|
167
|
-
'SYSTEM_BIG_CATEGORY_OLD',
|
|
168
|
-
'SYSTEM_BIG_CATEGORY_SLOT',
|
|
169
|
-
'SYSTEM_BIG_CATEGORY_ARCADE',
|
|
170
|
-
'SYSTEM_BIG_CATEGORY_FISHING',
|
|
171
|
-
'SYSTEM_BIG_CATEGORY_VIP',
|
|
172
|
-
'SYSTEM_BIG_CATEGORY_TABLECARD',
|
|
173
|
-
]
|
|
174
|
-
const validCategories = categories.filter((category) => {
|
|
175
|
-
return primaryCategories.includes(category.category)
|
|
176
|
-
})
|
|
177
|
-
|
|
178
|
-
const updatedCategories = state.primaryCategoryList.map((category) => {
|
|
179
|
-
const matchCategory = validCategories.find((item) => item.category === category.category)
|
|
180
|
-
return { ...category, code: matchCategory?.id }
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
state.primaryCategoryList = updatedCategories
|
|
184
|
-
},
|
|
185
|
-
_setVirtualCategoryList(state, virualCategoryList) {
|
|
186
|
-
const virtual = virualCategoryList?.filter((item) => item.virtual === 1) || []
|
|
187
|
-
state.virtualCategoryList = virtual.filter((item) => item.category !== 'SYSTEM_MY_FAVORITE')
|
|
188
|
-
},
|
|
189
|
-
setSelectedPrimaryCategory(state, data) {
|
|
190
|
-
state.selectedPrimaryCategory = data
|
|
191
|
-
},
|
|
192
|
-
gameMatching(state, data) {
|
|
193
|
-
state.isMatching = data
|
|
194
|
-
},
|
|
195
|
-
setStatements(state, data) {
|
|
196
|
-
state.statements = data
|
|
197
|
-
},
|
|
198
|
-
setGameTimer(state, timer) {
|
|
199
|
-
state.gameTimer = timer
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
actions: {
|
|
203
|
-
async examineGame({ state, getters, commit, dispatch, rootState, rootGetters }) {
|
|
204
|
-
const currentPath = this.$router.history.current.fullPath
|
|
205
|
-
if (isPlayingGame(currentPath)) return
|
|
206
|
-
|
|
207
|
-
const oldSHA = rootGetters['localStorage/getGameV2SHA']
|
|
208
|
-
const newSHA = await $request.send(api.getGameSHA())
|
|
209
|
-
const isGameChanged = newSHA?.status !== oldSHA?.status
|
|
210
|
-
const isCategoryChanged = newSHA?.category !== oldSHA?.category
|
|
211
|
-
|
|
212
|
-
if (isGameChanged) {
|
|
213
|
-
console.log(`[Gamehall] game changed`, newSHA?.status)
|
|
214
|
-
commit(`localStorage/setGameV2SHA`, newSHA, { root: true })
|
|
215
|
-
const oldStatus = rootGetters['localStorage/getGameV2Status']
|
|
216
|
-
const newStatus = await $request.send(api.getGameStatus())
|
|
217
|
-
const infoChangedList = extractInfoChangedGames(oldStatus, newStatus)
|
|
218
|
-
commit(`localStorage/setGameV2Status`, newStatus, { root: true })
|
|
219
|
-
|
|
220
|
-
if (infoChangedList.length > 0) {
|
|
221
|
-
const options = JSON.parse(JSON.stringify(rootState.game.gameMap))
|
|
222
|
-
for (const code of infoChangedList) {
|
|
223
|
-
if (options[code]) {
|
|
224
|
-
delete options[code]
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
commit(`_setGameMap`, options)
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
dispatch('fetchGameList', getters.getCategoryId)
|
|
231
|
-
} else if (isCategoryChanged) {
|
|
232
|
-
console.log(`[Gamehall] category changed`, newSHA?.category)
|
|
233
|
-
commit(`localStorage/setGameV2SHA`, newSHA, { root: true })
|
|
234
|
-
|
|
235
|
-
dispatch('fetchGameList', getters.getCategoryId)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// check for saving to localstorage
|
|
239
|
-
const optionInRAM = state.gameMap
|
|
240
|
-
const optionInLocal = rootState.localStorage.gameV2PersistedOption
|
|
241
|
-
if (Object.keys(optionInRAM || {}).length !== Object.keys(optionInLocal || {}).length) {
|
|
242
|
-
console.log('[Gamehall] save to local')
|
|
243
|
-
commit('localStorage/setGameV2PersistedOption', optionInRAM, { root: true })
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
async addGameOption({ getters, commit, dispatch }, code) {
|
|
247
|
-
const option = await $request.send(api.getGameMap(code))
|
|
248
|
-
if (Object.keys(option || {}).length > 0) {
|
|
249
|
-
commit('_appendGameMap', { key: code, value: option })
|
|
250
|
-
commit('_appendInverseGameMap', { key: code, value: option })
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
updateGameOption({ state, getters, commit, dispatch, rootState, rootGetters }, list) {
|
|
254
|
-
const games = list.filter((item) => !!item.g) || []
|
|
255
|
-
games.forEach((game) => {
|
|
256
|
-
const code = game.g
|
|
257
|
-
const options = state.gameMap || {}
|
|
258
|
-
if (!options[code]) {
|
|
259
|
-
dispatch('addGameOption', code)
|
|
260
|
-
}
|
|
261
|
-
})
|
|
262
|
-
},
|
|
263
|
-
async checkGameListPreset({ state, commit, getters, dispatch, rootState, rootGetters }, fullScan) {
|
|
264
|
-
const oldSHA = rootGetters['localStorage/getGameV2SHA']
|
|
265
|
-
const isInLocalStorage = !!oldSHA
|
|
266
|
-
if (!isInLocalStorage || fullScan === true) {
|
|
267
|
-
// 首次使用
|
|
268
|
-
const [newSHA, newStatus, option] = await Promise.all([
|
|
269
|
-
$request.send(api.getGameSHA()),
|
|
270
|
-
$request.send(api.getGameStatus()),
|
|
271
|
-
$request.send(api.getGameMap()),
|
|
272
|
-
])
|
|
273
|
-
commit('localStorage/setGameV2SHA', newSHA, { root: true })
|
|
274
|
-
commit('localStorage/setGameV2Status', newStatus, { root: true })
|
|
275
|
-
commit('_setGameMap', option)
|
|
276
|
-
commit('_setInverseGameMap', option)
|
|
277
|
-
} else if (!state.gameMap && rootState.localStorage.gameV2PersistedOption) {
|
|
278
|
-
// 重新整理
|
|
279
|
-
console.log('[Gamehall] copy from local')
|
|
280
|
-
commit('_setGameMap', rootState.localStorage.gameV2PersistedOption)
|
|
281
|
-
commit('_setInverseGameMap', rootState.localStorage.gameV2PersistedOption)
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
// fnc
|
|
285
|
-
async getGameCategory({}, id) {
|
|
286
|
-
return $request.send(api.getGameCategory({ id }))
|
|
287
|
-
},
|
|
288
|
-
// fnc
|
|
289
|
-
async fetchGameMap({}, id) {
|
|
290
|
-
return $request.send(api.getGameMap(id))
|
|
291
|
-
},
|
|
292
|
-
async fetchGameList({ state, commit, getters, dispatch, rootState, rootGetters }, id) {
|
|
293
|
-
await dispatch('checkGameListPreset')
|
|
294
|
-
const currentPath = this.$router.history.current.fullPath
|
|
295
|
-
|
|
296
|
-
if (isInGamehall(currentPath)) {
|
|
297
|
-
commit('_setCategoryId', id)
|
|
298
|
-
const category = await $request.send(api.getGameCategory({ id }))
|
|
299
|
-
const categoryChildren = category?.list || []
|
|
300
|
-
|
|
301
|
-
if (state.primaryCategoryList.map((item) => item.category).includes(category.name)) {
|
|
302
|
-
commit('_setVirtualCategoryList', categoryChildren)
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (id) {
|
|
306
|
-
commit('setGameList', categoryChildren)
|
|
307
|
-
} else {
|
|
308
|
-
commit('game/_setPrimaryCategoryList', categoryChildren, { root: true })
|
|
309
|
-
const favoriteId = categoryChildren.find((item) => item.category === 'SYSTEM_MY_FAVORITE').id
|
|
310
|
-
const category = await $request.send(api.getGameCategory({ id: favoriteId }))
|
|
311
|
-
const list = category?.list || []
|
|
312
|
-
commit('_setFavorite', { ...state.favorite, code: favoriteId, list: list.map((item) => item.g) })
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
},
|
|
316
|
-
async addFavoriteGame({ state, commit, getters, dispatch, rootState, rootGetters }, code) {
|
|
317
|
-
try {
|
|
318
|
-
const appendedList = [...getters.getFavoriteList, code]
|
|
319
|
-
commit('_setFavoriteList', appendedList)
|
|
320
|
-
await $request.send(api.addFavoriteGame({ games: [code] }))
|
|
321
|
-
} catch (err) {
|
|
322
|
-
console.log(err)
|
|
323
|
-
const restoredList = getters.getFavoriteList.filter((item) => item !== code)
|
|
324
|
-
commit('_setFavoriteList', restoredList)
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
async removeFavoriteGame({ state, commit, getters, dispatch, rootState, rootGetters }, code) {
|
|
328
|
-
try {
|
|
329
|
-
const reservedList = getters.getFavoriteList.filter((item) => item !== code)
|
|
330
|
-
commit('_setFavoriteList', reservedList)
|
|
331
|
-
await $request.send(api.removeFavoriteGame({ games: [code] }))
|
|
332
|
-
} catch (err) {
|
|
333
|
-
console.log(err)
|
|
334
|
-
const restoredList = [...getters.getFavoriteList, code]
|
|
335
|
-
commit('_setFavoriteList', restoredList)
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
async getStatements({ state, commit, getters, dispatch, rootState, rootGetters }) {
|
|
339
|
-
try {
|
|
340
|
-
commit(`core/setLoading`, true, { root: true })
|
|
341
|
-
const data = await $request.send(api.getStatements())
|
|
342
|
-
commit(`setStatements`, data)
|
|
343
|
-
commit(`core/setLoading`, false, { root: true })
|
|
344
|
-
return data
|
|
345
|
-
} catch (err) {
|
|
346
|
-
commit(`core/setLoading`, false, { root: true })
|
|
347
|
-
throw err
|
|
348
|
-
}
|
|
349
|
-
},
|
|
350
|
-
async setPreference({}, defaultCategory) {
|
|
351
|
-
return await $request.send(api.setPreference({ defaultCategory }))
|
|
352
|
-
},
|
|
353
|
-
// executeGameTimer({ state, commit, dispatch }) {
|
|
354
|
-
// clearInterval(state.gameTimer)
|
|
355
|
-
// dispatch('examineGame')
|
|
356
|
-
// const timer = setInterval(() => {
|
|
357
|
-
// dispatch('examineGame')
|
|
358
|
-
// }, 20000)
|
|
359
|
-
// commit('setGameTimer', timer)
|
|
360
|
-
// },
|
|
361
|
-
async exitGame({ commit, rootGetters }) {
|
|
362
|
-
const uid_site = rootGetters['user/userInfo'].uid_site
|
|
363
|
-
const provider_id = rootGetters['gameStore/getCurrentProvider']
|
|
364
|
-
if (provider_id) {
|
|
365
|
-
await $request.sendWithLoading(api.logoutGame({ uid_site, provider_id }))
|
|
366
|
-
}
|
|
367
|
-
commit('setCurrentProvider', null)
|
|
368
|
-
commit('setCurrentGameId', null)
|
|
369
|
-
},
|
|
370
|
-
// fnc
|
|
371
|
-
async disconnectGame({rootGetters}, provider) {
|
|
372
|
-
const uid_site = rootGetters['user/userInfo'].uid_site
|
|
373
|
-
return $request.send(api.logoutGame({ uid_site, provider_id: provider }))
|
|
374
|
-
},
|
|
375
|
-
// fnc
|
|
376
|
-
async connectGame({}, {game, lang = 'en_US'}) {
|
|
377
|
-
const {provider, game_id, game_type, mapping_id} = game
|
|
378
|
-
const params = {
|
|
379
|
-
provider_id: provider,
|
|
380
|
-
game_id: game_id,
|
|
381
|
-
gametype_id: game_type,
|
|
382
|
-
mapping_id: mapping_id,
|
|
383
|
-
is_demo: false,
|
|
384
|
-
// todo - set false temporarily
|
|
385
|
-
// is_mobile: rootGetters['core/isMobileDevice'],
|
|
386
|
-
is_mobile: false,
|
|
387
|
-
lang: lang.replace('-', '_'),
|
|
388
|
-
// todo - set temporarily
|
|
389
|
-
// return_url: returnProviders.includes(game.provider) ? `${window.location.origin}/return` : window.location.href, // For providers to return.
|
|
390
|
-
return_url: window.location.href
|
|
391
|
-
}
|
|
392
|
-
const { redirect_url } = await $request.send(api.playGame(params))
|
|
393
|
-
return redirect_url
|
|
394
|
-
},
|
|
395
|
-
async play({ getters, rootGetters, commit, dispatch }, { game, isDemo = false }) {
|
|
396
|
-
try {
|
|
397
|
-
if (
|
|
398
|
-
(await dispatch('core/checkStatus', null, { root: true })) === true &&
|
|
399
|
-
rootGetters['core/isAuthorized'] &&
|
|
400
|
-
game.system_enable !== 0 &&
|
|
401
|
-
(await dispatch('core/checkVerification', null, { root: true })) === true
|
|
402
|
-
) {
|
|
403
|
-
// 和遊戲商連線時畫面
|
|
404
|
-
commit('gameMatching', true)
|
|
405
|
-
|
|
406
|
-
const returnProviders = ['RSG', 'KP', 'EPICWIN', 'KA']
|
|
407
|
-
const lang = rootGetters['core/getLocale'](
|
|
408
|
-
{ shorthand: getters.getLocale, isUnderline: true },
|
|
409
|
-
{ root: true }
|
|
410
|
-
)
|
|
411
|
-
const params = {
|
|
412
|
-
provider_id: game.provider || game.provider_id,
|
|
413
|
-
game_id: game.id || game.game_id,
|
|
414
|
-
gametype_id: game.game_type || game.gametype_id,
|
|
415
|
-
mapping_id: game.mapping_id || game.mapping_id,
|
|
416
|
-
is_demo: isDemo,
|
|
417
|
-
is_mobile: rootGetters['core/isMobileDevice'],
|
|
418
|
-
lang,
|
|
419
|
-
return_url:
|
|
420
|
-
returnProviders.includes(game.provider) || returnProviders.includes(game.provider_id)
|
|
421
|
-
? `${window.location.origin}/return`
|
|
422
|
-
: window.location.href, // For providers to return.
|
|
423
|
-
}
|
|
424
|
-
const data = await $request.send(api.playGame(params))
|
|
425
|
-
commit('gameMatching', false)
|
|
426
|
-
const targetUrl = data.redirect_url
|
|
427
|
-
commit('setGameURL', targetUrl)
|
|
428
|
-
commit('setCurrentProvider', params.provider_id)
|
|
429
|
-
commit('setCurrentGameId', params.game_id)
|
|
430
|
-
commit('setCurrentGameType', params.mapping_id)
|
|
431
|
-
return targetUrl
|
|
432
|
-
} else {
|
|
433
|
-
commit('gameMatching', false)
|
|
434
|
-
throw new Error('not authorized')
|
|
435
|
-
}
|
|
436
|
-
} catch (err) {
|
|
437
|
-
commit('gameMatching', false)
|
|
438
|
-
throw err
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
export default (ctx, inject) => {
|
|
446
|
-
const { store, $request } = ctx
|
|
447
|
-
store.registerModule('game', createStore({ $request }))
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
function extractInfoChangedGames(oldStatus, newStatus) {
|
|
451
|
-
const list = []
|
|
452
|
-
const oldKeys = Object.keys(oldStatus || {})
|
|
453
|
-
|
|
454
|
-
// timestamp changed
|
|
455
|
-
for (const key of oldKeys) {
|
|
456
|
-
const isInfoChanged = oldStatus[key]?.[1] !== newStatus[key]?.[1]
|
|
457
|
-
if (isInfoChanged) {
|
|
458
|
-
list.push(key)
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
return list
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function isInGamehall(url) {
|
|
466
|
-
const gamehallRegex = /^\/main(\/?|(\/[a-zA-Z0-g]+\/?))?$/g
|
|
467
|
-
const playingRegex = /^\/?main\/game\/?$/g
|
|
468
|
-
return gamehallRegex.test(url) && !playingRegex.test(url)
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
function isPlayingGame(url) {
|
|
472
|
-
const playingRegex = /^\/?main\/game\/?$/g
|
|
473
|
-
return playingRegex.test(url)
|
|
474
|
-
}
|
package/plugin/inbox.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
const api = {
|
|
2
|
-
getMessageTypes: () => ({ url: 'mailbox/getMessageTypes', method: 'get' }),
|
|
3
|
-
getMessageList: ({ type, limit = 10, page }) => ({
|
|
4
|
-
url: 'mailbox/getMessageList?include=cl',
|
|
5
|
-
method: 'post',
|
|
6
|
-
params: { type, limit, page },
|
|
7
|
-
}),
|
|
8
|
-
updateMessage: ({ groupId, isRead }) => ({
|
|
9
|
-
url: 'mailbox/updateMessage',
|
|
10
|
-
method: 'post',
|
|
11
|
-
params: { groupId, isRead },
|
|
12
|
-
}),
|
|
13
|
-
sendMessage: () => ({ url: 'mailbox/sendMessage', method: 'post' }),
|
|
14
|
-
getMessage: ({ groupId, limit = 10, pageIdx }) => ({
|
|
15
|
-
url: 'mailbox/getMessage',
|
|
16
|
-
method: 'post',
|
|
17
|
-
params: { groupId, limit, pageIdx },
|
|
18
|
-
}),
|
|
19
|
-
deleteMessage: ({ mid, isDelete }) => ({ url: 'mailbox/deleteMessage', method: 'post', params: { mid, isDelete } }),
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function createStore({$request}) {
|
|
23
|
-
return {
|
|
24
|
-
namespaced: true,
|
|
25
|
-
state: () => ({
|
|
26
|
-
inbox: [],
|
|
27
|
-
tabList: [],
|
|
28
|
-
tab: '',
|
|
29
|
-
message: null,
|
|
30
|
-
isCrash: false,
|
|
31
|
-
systemPrompt: false,
|
|
32
|
-
summary: {},
|
|
33
|
-
newMessageLevel: null, // 'system' | 'normal'
|
|
34
|
-
}),
|
|
35
|
-
getters: {
|
|
36
|
-
getSummary(state) {
|
|
37
|
-
return state.summary
|
|
38
|
-
},
|
|
39
|
-
getInbox(state) {
|
|
40
|
-
return state.inbox
|
|
41
|
-
},
|
|
42
|
-
getTabList(state, getters) {
|
|
43
|
-
return state.tabList
|
|
44
|
-
},
|
|
45
|
-
getTab(state, getters) {
|
|
46
|
-
return state.tab
|
|
47
|
-
},
|
|
48
|
-
getMessage(state) {
|
|
49
|
-
return state.message
|
|
50
|
-
},
|
|
51
|
-
getCrash(state, getters) {
|
|
52
|
-
return state.isCrash
|
|
53
|
-
},
|
|
54
|
-
hasSystemMessage(state, getters) {
|
|
55
|
-
return !!state.summary?.detailRows?.SYSTEM
|
|
56
|
-
},
|
|
57
|
-
getSystemPrompt(state, getters) {
|
|
58
|
-
return state.systemPrompt
|
|
59
|
-
},
|
|
60
|
-
_getTabContent(state, getters) {
|
|
61
|
-
return state.inbox.find((item) => item.tab === state.tab) || {}
|
|
62
|
-
},
|
|
63
|
-
shouldOpenInbox(state, getters, rootState, rootGetters) {
|
|
64
|
-
const isEnable = rootGetters['core/getSiteConfig'].mailboxEnable === '1'
|
|
65
|
-
const isModalOpening = rootGetters['core/getModal']?.type
|
|
66
|
-
return isEnable && !state.isCrash && !isModalOpening && getters.hasSystemMessage
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
mutations: {
|
|
70
|
-
_setSummary(state, data) {
|
|
71
|
-
state.summary = data
|
|
72
|
-
},
|
|
73
|
-
_setNewMessageLevel(state, data) {
|
|
74
|
-
state.newMessageLevel = data
|
|
75
|
-
},
|
|
76
|
-
setSystemPrompt(state, data) {
|
|
77
|
-
state.systemPrompt = data
|
|
78
|
-
},
|
|
79
|
-
setTab(state, data) {
|
|
80
|
-
state.tab = data
|
|
81
|
-
},
|
|
82
|
-
_setInbox(state, data) {
|
|
83
|
-
state.inbox = data
|
|
84
|
-
},
|
|
85
|
-
_setTabList(state, data) {
|
|
86
|
-
state.tabList = data
|
|
87
|
-
},
|
|
88
|
-
_setCrash(state, bool) {
|
|
89
|
-
state.isCrash = bool
|
|
90
|
-
},
|
|
91
|
-
_setMessage(state, message) {
|
|
92
|
-
state.message = message
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
actions: {
|
|
96
|
-
async initialize({ state, getters, commit, dispatch }) {
|
|
97
|
-
const { data = [] } = await $request.send(api.getMessageTypes())
|
|
98
|
-
const tabList = data?.map((item) => item.type)
|
|
99
|
-
const inbox = tabList.map((type) => ({ tab: type, data: [], page: -1 }))
|
|
100
|
-
commit('_setTabList', tabList)
|
|
101
|
-
commit('_setInbox', inbox)
|
|
102
|
-
if (!state.tab) {
|
|
103
|
-
commit('setTab', tabList[0])
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
async loadNextMessages({ state, getters, commit, dispatch }, { loaded, complete }) {
|
|
107
|
-
// 'loaded' and 'complete' are 'infinite-loading' component's methods, just bring in
|
|
108
|
-
const { tab } = state
|
|
109
|
-
const { totalPage, page } = getters._getTabContent
|
|
110
|
-
const nextIndex = page + 1
|
|
111
|
-
const maxIndex = totalPage - 1
|
|
112
|
-
|
|
113
|
-
if (!totalPage || maxIndex > nextIndex) {
|
|
114
|
-
try {
|
|
115
|
-
const data = await $request.send(api.getMessageList({ type: tab, page: nextIndex }))
|
|
116
|
-
if (data.data.length === 0) {
|
|
117
|
-
complete()
|
|
118
|
-
return
|
|
119
|
-
}
|
|
120
|
-
dispatch('_appendMessages', data)
|
|
121
|
-
dispatch('_handleUnreadSystemMessage')
|
|
122
|
-
loaded()
|
|
123
|
-
} catch (err) {
|
|
124
|
-
console.log(err)
|
|
125
|
-
// 因為 api 有時會壞掉,要幫他們防呆...
|
|
126
|
-
commit('_setCrash', true)
|
|
127
|
-
}
|
|
128
|
-
} else {
|
|
129
|
-
complete()
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
selectMessage({ state, getters, commit, dispatch }, message) {
|
|
133
|
-
if (message && !message.isRead) {
|
|
134
|
-
dispatch('_updateStatusRead', message)
|
|
135
|
-
}
|
|
136
|
-
commit('_setMessage', message)
|
|
137
|
-
},
|
|
138
|
-
updateRewardMessage({ state, getters, commit, dispatch }) {
|
|
139
|
-
const clone = JSON.parse(JSON.stringify(state.inbox))
|
|
140
|
-
clone.forEach((tab) => {
|
|
141
|
-
if (tab.tab !== state.tab) {
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
tab.data.forEach((message) => {
|
|
145
|
-
if (message.groupId !== state.message.groupId) {
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
message.receiveStatus = 1
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
commit('_setInbox', clone)
|
|
152
|
-
commit('_setMessage', { ...state.message, receiveStatus: 1 })
|
|
153
|
-
},
|
|
154
|
-
setSummary({ state, getters, commit, dispatch }, data) {
|
|
155
|
-
let level = null
|
|
156
|
-
if (data.rows > state.summary.rows) {
|
|
157
|
-
if (data.detailRows.SYSTEM > state.summary.detailRows.SYSTEM) {
|
|
158
|
-
commit('_setNewMessageLevel', 'system')
|
|
159
|
-
level = 'system'
|
|
160
|
-
} else {
|
|
161
|
-
commit('_setNewMessageLevel', 'normal')
|
|
162
|
-
level = 'normal'
|
|
163
|
-
}
|
|
164
|
-
} else {
|
|
165
|
-
commit('_setNewMessageLevel', null)
|
|
166
|
-
}
|
|
167
|
-
commit('_setSummary', data)
|
|
168
|
-
return level
|
|
169
|
-
},
|
|
170
|
-
_handleUnreadSystemMessage({ state, getters, commit, dispatch }) {
|
|
171
|
-
const { tab, systemPrompt } = state
|
|
172
|
-
if (tab === 'SYSTEM' && systemPrompt) {
|
|
173
|
-
const tabContent = getters._getTabContent
|
|
174
|
-
commit('setSystemPrompt', false)
|
|
175
|
-
// 系統信要強制玩家閱讀
|
|
176
|
-
const unread = tabContent.data.find((item) => !item.isRead)
|
|
177
|
-
if (unread) {
|
|
178
|
-
dispatch('selectMessage', unread)
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
_appendMessages({ state, getters, commit, dispatch }, res) {
|
|
183
|
-
const { inbox, tab } = state
|
|
184
|
-
const { data, ...rest } = res
|
|
185
|
-
const clone = JSON.parse(JSON.stringify(inbox))
|
|
186
|
-
const index = clone.findIndex((inboxTab) => inboxTab.tab === tab)
|
|
187
|
-
const messages = [...clone[index].data, ...data]
|
|
188
|
-
clone[index] = { ...clone[index], ...rest, data: messages }
|
|
189
|
-
commit('_setInbox', clone)
|
|
190
|
-
},
|
|
191
|
-
_updateStatusRead({ state, getters, commit, dispatch }, message) {
|
|
192
|
-
const { inbox, tab, summary } = state
|
|
193
|
-
const cloneInbox = JSON.parse(JSON.stringify(inbox))
|
|
194
|
-
cloneInbox
|
|
195
|
-
.find((inboxTab) => inboxTab.tab === tab)
|
|
196
|
-
.data.forEach((item) => {
|
|
197
|
-
if (item.groupId === message.groupId) {
|
|
198
|
-
item.isRead = true
|
|
199
|
-
// 更新未讀數量
|
|
200
|
-
const cloneSummary = JSON.parse(JSON.stringify(summary))
|
|
201
|
-
cloneSummary.rows = cloneSummary.rows - 1 // 總數減1
|
|
202
|
-
cloneSummary.detailRows = { ...cloneSummary.detailRows, [tab]: cloneSummary.detailRows[tab] - 1 } // 分類減1
|
|
203
|
-
commit('_setSummary', cloneSummary)
|
|
204
|
-
}
|
|
205
|
-
})
|
|
206
|
-
commit('_setInbox', cloneInbox)
|
|
207
|
-
$request.send(api.updateMessage({ groupId: message.groupId, isRead: true }))
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export default (ctx, inject) => {
|
|
214
|
-
const { store, $request } = ctx
|
|
215
|
-
store.registerModule('inbox', createStore({$request}))
|
|
216
|
-
}
|