@jetthai/cuora 1.1.93-cash → 1.1.93
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/.husky/pre-commit +1 -1
- package/CHANGELOG.md +0 -4
- package/dist/bundle.mjs +1263 -515
- package/package.json +1 -1
- package/src/api/activity.js +1 -13
- package/src/machine/activity/deposit_activity.js +2 -2
- package/src/machine/activity/fafafa_activity.js +11 -35
- package/src/machine/activity/index.js +0 -2
- package/src/machine/activity/ranking_activity.js +2 -31
- package/src/machine/activity/specify_bets_activity.js +3 -44
- package/src/machine/activity/specify_turnover_activity.js +3 -44
- package/src/machine/deposit/index.js +0 -6
- package/src/machine/game.js +285 -0
- package/src/machine/game_favorite.js +123 -0
- package/src/machine/game_favorite_v2.js +2 -6
- package/src/machine/game_v2.js +381 -0
- package/src/machine/game_v2_1.js +9 -35
- package/src/machine/index.js +6 -4
- package/src/machine/user_info.js +2 -8
- package/src/request/request.js +5 -9
- package/src/util/index.js +1 -2
- package/src/machine/activity/diamond_shop_activity_cash.js +0 -214
- package/src/machine/deposit/manual_cash.js +0 -321
- package/src/machine/deposit/qrcode_cash.js +0 -258
- package/src/machine/deposit/usdt_cash.js +0 -138
- package/src/machine/reward_cash.js +0 -220
- package/src/machine/side_cash.js +0 -110
- package/src/machine/withdraw/withdraw_activity.js +0 -383
- package/src/util/math.js +0 -4
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { assign, createMachine } from 'xstate'
|
|
2
|
+
import api from '../api/game.js'
|
|
3
|
+
import UAParser from 'ua-parser-js'
|
|
4
|
+
import { GAME_SEARCH } from '../util/constant.js'
|
|
5
|
+
|
|
6
|
+
export default function (request) {
|
|
7
|
+
return createMachine(
|
|
8
|
+
{
|
|
9
|
+
id: 'game',
|
|
10
|
+
type: 'parallel',
|
|
11
|
+
context: {
|
|
12
|
+
room: null,
|
|
13
|
+
index: 0,
|
|
14
|
+
content: {
|
|
15
|
+
data: [],
|
|
16
|
+
timestamp: null,
|
|
17
|
+
parentCategoryId: null,
|
|
18
|
+
totalPage: 1,
|
|
19
|
+
},
|
|
20
|
+
addition: {
|
|
21
|
+
data: [],
|
|
22
|
+
timestamp: null,
|
|
23
|
+
totalPage: 1,
|
|
24
|
+
},
|
|
25
|
+
// play params
|
|
26
|
+
game: {
|
|
27
|
+
providerId: null,
|
|
28
|
+
gameId: null,
|
|
29
|
+
gameTypeId: null,
|
|
30
|
+
mappingId: null,
|
|
31
|
+
portrait: null,
|
|
32
|
+
},
|
|
33
|
+
lang: 'en_US',
|
|
34
|
+
isMobile: new UAParser().getResult().device.type,
|
|
35
|
+
gameURL: null,
|
|
36
|
+
...oldContext,
|
|
37
|
+
},
|
|
38
|
+
states: {
|
|
39
|
+
flow: {
|
|
40
|
+
initial: 'idle',
|
|
41
|
+
states: {
|
|
42
|
+
idle: {
|
|
43
|
+
enter: 'clearGameInfo',
|
|
44
|
+
on: {
|
|
45
|
+
ENTER_ROOM: {
|
|
46
|
+
target: 'loading',
|
|
47
|
+
cond: 'isDifferentRoom',
|
|
48
|
+
actions: ['setRoom', 'resetContent'],
|
|
49
|
+
},
|
|
50
|
+
NEXT_PAGE: {
|
|
51
|
+
target: 'loading',
|
|
52
|
+
cond: 'hasNext',
|
|
53
|
+
actions: 'increaseIndex',
|
|
54
|
+
},
|
|
55
|
+
ENTER_GAME: {
|
|
56
|
+
target: 'connecting',
|
|
57
|
+
actions: ['setGameInfo', 'setLang'],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
loading: {
|
|
62
|
+
invoke: {
|
|
63
|
+
src: 'getPageContent',
|
|
64
|
+
onDone: {
|
|
65
|
+
target: 'idle',
|
|
66
|
+
actions: 'appendContent',
|
|
67
|
+
},
|
|
68
|
+
onError: {
|
|
69
|
+
target: 'idle',
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
connecting: {
|
|
74
|
+
invoke: {
|
|
75
|
+
src: 'connectGame',
|
|
76
|
+
onDone: {
|
|
77
|
+
target: 'playing',
|
|
78
|
+
actions: 'setGameURL',
|
|
79
|
+
},
|
|
80
|
+
onError: {
|
|
81
|
+
target: 'idle',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
playing: {
|
|
86
|
+
on: {
|
|
87
|
+
EXIT_GAME: {
|
|
88
|
+
target: 'disconnect',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
disconnect: {
|
|
93
|
+
invoke: {
|
|
94
|
+
src: 'disconnectGame',
|
|
95
|
+
onDone: {
|
|
96
|
+
target: 'idle',
|
|
97
|
+
},
|
|
98
|
+
onError: {
|
|
99
|
+
target: 'idle',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
timer: {
|
|
106
|
+
initial: 'pending',
|
|
107
|
+
states: {
|
|
108
|
+
pending: {
|
|
109
|
+
after: {
|
|
110
|
+
20000: [
|
|
111
|
+
{
|
|
112
|
+
target: 'updating',
|
|
113
|
+
cond: 'hasRoom',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
target: 'pending',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
updating: {
|
|
122
|
+
invoke: {
|
|
123
|
+
src: 'updatePageContent',
|
|
124
|
+
onDone: {
|
|
125
|
+
target: 'pending',
|
|
126
|
+
actions: 'swapContent',
|
|
127
|
+
},
|
|
128
|
+
onError: {
|
|
129
|
+
target: 'pending',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
oldTimer: {
|
|
136
|
+
initial: 'fetchingGameSHA',
|
|
137
|
+
states: {
|
|
138
|
+
fetchingGameSHA: {
|
|
139
|
+
invoke: {
|
|
140
|
+
src: 'fetchGameSHA',
|
|
141
|
+
onDone: {
|
|
142
|
+
target: 'checking',
|
|
143
|
+
actions: 'setGameSHA',
|
|
144
|
+
},
|
|
145
|
+
onError: {
|
|
146
|
+
target: 'pending',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
checking: {
|
|
151
|
+
always: [{ target: 'updatingStatus', cond: 'isStatusChanged' }, { target: 'pending' }],
|
|
152
|
+
},
|
|
153
|
+
updatingStatus: {
|
|
154
|
+
invoke: {
|
|
155
|
+
src: 'fetchStatus',
|
|
156
|
+
onDone: {
|
|
157
|
+
target: 'updatingOption',
|
|
158
|
+
actions: ['setStatus'],
|
|
159
|
+
},
|
|
160
|
+
onError: {
|
|
161
|
+
target: 'pending',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
updatingOption: {
|
|
166
|
+
invoke: {
|
|
167
|
+
src: 'fetchOption',
|
|
168
|
+
onDone: {
|
|
169
|
+
target: 'pending',
|
|
170
|
+
actions: 'mergeOption',
|
|
171
|
+
},
|
|
172
|
+
onError: {
|
|
173
|
+
target: 'pending',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
pending: {
|
|
178
|
+
after: {
|
|
179
|
+
20000: {
|
|
180
|
+
target: 'fetchingGameSHA',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
actions: {
|
|
190
|
+
setFavoriteList: assign((context, event) => {
|
|
191
|
+
return {
|
|
192
|
+
favoriteList: event.data.data || [],
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
setRoom: assign((context, event) => {
|
|
196
|
+
return {
|
|
197
|
+
room: event.data,
|
|
198
|
+
}
|
|
199
|
+
}),
|
|
200
|
+
resetContent: assign((context, event) => {
|
|
201
|
+
return {
|
|
202
|
+
index: 0,
|
|
203
|
+
content: {
|
|
204
|
+
data: [],
|
|
205
|
+
timestamp: null,
|
|
206
|
+
parentCategoryId: null,
|
|
207
|
+
totalPage: 1,
|
|
208
|
+
},
|
|
209
|
+
addition: {
|
|
210
|
+
data: [],
|
|
211
|
+
timestamp: null,
|
|
212
|
+
totalPage: 1,
|
|
213
|
+
},
|
|
214
|
+
}
|
|
215
|
+
}),
|
|
216
|
+
appendContent: assign((context, event) => {
|
|
217
|
+
const { room, favoriteList } = context
|
|
218
|
+
if (room.categoryId === GAME_SEARCH) {
|
|
219
|
+
return
|
|
220
|
+
} else {
|
|
221
|
+
const [content, addition] = event.data
|
|
222
|
+
return {
|
|
223
|
+
content: {
|
|
224
|
+
...context.content,
|
|
225
|
+
...content,
|
|
226
|
+
data: context.content.data.concat(content.data),
|
|
227
|
+
},
|
|
228
|
+
addition: {
|
|
229
|
+
...context.addition,
|
|
230
|
+
...addition,
|
|
231
|
+
data: context.addition.data.concat(addition.data),
|
|
232
|
+
},
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}),
|
|
236
|
+
swapContent: assign((context, event) => {
|
|
237
|
+
const [content, addition] = event.data
|
|
238
|
+
let result = {}
|
|
239
|
+
if (content?.data?.length) {
|
|
240
|
+
result.content = content
|
|
241
|
+
}
|
|
242
|
+
if (addition?.data?.length) {
|
|
243
|
+
result.addition = addition
|
|
244
|
+
}
|
|
245
|
+
return result
|
|
246
|
+
}),
|
|
247
|
+
increaseIndex: assign((context, event) => {
|
|
248
|
+
return {
|
|
249
|
+
index: context.index + 1,
|
|
250
|
+
}
|
|
251
|
+
}),
|
|
252
|
+
setGameURL: assign({
|
|
253
|
+
gameURL: (context, event) => {
|
|
254
|
+
return event.data.gameURL
|
|
255
|
+
},
|
|
256
|
+
}),
|
|
257
|
+
clearGameInfo: assign((context, event) => {
|
|
258
|
+
return { game: { providerId: null, gameId: null, gameTypeId: null, mappingId: null } }
|
|
259
|
+
}),
|
|
260
|
+
setGameInfo: assign((context, event) => {
|
|
261
|
+
const { providerId, gameId, gameTypeId, mappingId, portrait } = event.data.game
|
|
262
|
+
return { game: { providerId, gameId, gameTypeId, mappingId, portrait: portrait ? 1 : 0 } }
|
|
263
|
+
}),
|
|
264
|
+
setLang: assign((context, event) => {
|
|
265
|
+
const lang = event.data.locale.replace('-', '_')
|
|
266
|
+
return { lang }
|
|
267
|
+
}),
|
|
268
|
+
...oldActions,
|
|
269
|
+
},
|
|
270
|
+
guards: {
|
|
271
|
+
isDifferentRoom: (context, event) => context.room?.categoryId !== event.data?.categoryId,
|
|
272
|
+
hasNext: (context, event) => context.index < context?.content?.totalPage - 1,
|
|
273
|
+
hasRoom: (context, event) => context.room?.categoryId,
|
|
274
|
+
...oldGuards,
|
|
275
|
+
},
|
|
276
|
+
services: {
|
|
277
|
+
getPageContent: async (context, event) => {
|
|
278
|
+
const { room, index } = context
|
|
279
|
+
if (room.categoryId === GAME_SEARCH) {
|
|
280
|
+
return
|
|
281
|
+
} else {
|
|
282
|
+
const param = { categoryId: room.categoryId, index }
|
|
283
|
+
return await Promise.all([request.send(api.getListCategory(param)), request.send(api.getListAddition(param))])
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
updatePageContent: async (context, event) => {
|
|
287
|
+
const { room, content, index } = context
|
|
288
|
+
if (room.categoryId === GAME_SEARCH) {
|
|
289
|
+
return
|
|
290
|
+
} else {
|
|
291
|
+
return await Promise.all([
|
|
292
|
+
request.send(
|
|
293
|
+
api.getListCategoryByRange({
|
|
294
|
+
categoryId: room.categoryId,
|
|
295
|
+
end: index,
|
|
296
|
+
timestamp: content.timestamp,
|
|
297
|
+
})
|
|
298
|
+
),
|
|
299
|
+
request.send(
|
|
300
|
+
api.getListAdditionByRange({
|
|
301
|
+
categoryId: room.categoryId,
|
|
302
|
+
end: index,
|
|
303
|
+
timestamp: content.timestamp,
|
|
304
|
+
})
|
|
305
|
+
),
|
|
306
|
+
])
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
connectGame: async (context, event) => {
|
|
310
|
+
const { lang, isMobile } = context
|
|
311
|
+
const { providerId, gameId, gameTypeId, mappingId } = context.game
|
|
312
|
+
const params = {
|
|
313
|
+
provider_id: providerId,
|
|
314
|
+
game_id: gameId,
|
|
315
|
+
gametype_id: gameTypeId,
|
|
316
|
+
mapping_id: mappingId,
|
|
317
|
+
is_demo: false,
|
|
318
|
+
is_mobile: isMobile,
|
|
319
|
+
lang,
|
|
320
|
+
return_url: window.location.href,
|
|
321
|
+
}
|
|
322
|
+
const { redirect_url } = await request.send(api.playGame(params))
|
|
323
|
+
return { gameURL: redirect_url }
|
|
324
|
+
},
|
|
325
|
+
disconnectGame: async (context, event) => {
|
|
326
|
+
const uid_site = event.data
|
|
327
|
+
const provider_id = context.game.providerId
|
|
328
|
+
return await request.send(api.logoutGame({ uid_site, provider_id }))
|
|
329
|
+
},
|
|
330
|
+
...oldServices(request),
|
|
331
|
+
},
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const oldContext = {
|
|
337
|
+
sha: {
|
|
338
|
+
status: null,
|
|
339
|
+
},
|
|
340
|
+
isStatusChanged: false,
|
|
341
|
+
statusMap: {},
|
|
342
|
+
optionMap: {},
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const oldActions = {
|
|
346
|
+
setGameSHA: assign((context, event) => {
|
|
347
|
+
const { sha } = context
|
|
348
|
+
const newSha = event.data
|
|
349
|
+
return {
|
|
350
|
+
sha: newSha,
|
|
351
|
+
isStatusChanged: !sha.status || sha.status !== newSha.status,
|
|
352
|
+
}
|
|
353
|
+
}),
|
|
354
|
+
setStatus: assign((context, event) => {
|
|
355
|
+
return {
|
|
356
|
+
statusMap: event.data,
|
|
357
|
+
}
|
|
358
|
+
}),
|
|
359
|
+
mergeOption: assign((context, event) => {
|
|
360
|
+
const { optionMap } = context
|
|
361
|
+
return {
|
|
362
|
+
optionMap: { ...optionMap, ...event.data },
|
|
363
|
+
}
|
|
364
|
+
}),
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const oldGuards = {
|
|
368
|
+
isStatusChanged: (context, event) => context.isStatusChanged,
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const oldServices = (request) => ({
|
|
372
|
+
fetchOption: async (context, event) => {
|
|
373
|
+
return await request.send(api.getOptionMap())
|
|
374
|
+
},
|
|
375
|
+
fetchGameSHA: async (context, event) => {
|
|
376
|
+
return await request.send(api.getGameSHA())
|
|
377
|
+
},
|
|
378
|
+
fetchStatus: async (context, event) => {
|
|
379
|
+
return await request.send(api.getGameStatus())
|
|
380
|
+
},
|
|
381
|
+
})
|
package/src/machine/game_v2_1.js
CHANGED
|
@@ -27,7 +27,6 @@ export default function (request) {
|
|
|
27
27
|
timestamp: null,
|
|
28
28
|
totalPage: 0,
|
|
29
29
|
},
|
|
30
|
-
staticData: [],
|
|
31
30
|
// play params
|
|
32
31
|
game: {
|
|
33
32
|
providerId: null,
|
|
@@ -48,9 +47,6 @@ export default function (request) {
|
|
|
48
47
|
idle: {
|
|
49
48
|
enter: 'clearGameInfo',
|
|
50
49
|
on: {
|
|
51
|
-
SET_STATIC_DATA: {
|
|
52
|
-
actions: 'setStaticData',
|
|
53
|
-
},
|
|
54
50
|
SET_ADDITION_ENABLE: {
|
|
55
51
|
actions: 'setAdditionEnable',
|
|
56
52
|
},
|
|
@@ -210,11 +206,6 @@ export default function (request) {
|
|
|
210
206
|
},
|
|
211
207
|
{
|
|
212
208
|
actions: {
|
|
213
|
-
setStaticData: assign((context, event) => {
|
|
214
|
-
return {
|
|
215
|
-
staticData: event.data,
|
|
216
|
-
}
|
|
217
|
-
}),
|
|
218
209
|
setAdditionEnable: assign((context, event) => {
|
|
219
210
|
return {
|
|
220
211
|
additionEnable: event.data,
|
|
@@ -231,6 +222,11 @@ export default function (request) {
|
|
|
231
222
|
isLastPage: index >= content?.totalPage - 1,
|
|
232
223
|
}
|
|
233
224
|
}),
|
|
225
|
+
setFavoriteList: assign((context, event) => {
|
|
226
|
+
return {
|
|
227
|
+
favoriteList: event.data.data || [],
|
|
228
|
+
}
|
|
229
|
+
}),
|
|
234
230
|
setRoom: assign((context, event) => {
|
|
235
231
|
return {
|
|
236
232
|
room: event.data,
|
|
@@ -328,19 +324,9 @@ export default function (request) {
|
|
|
328
324
|
},
|
|
329
325
|
services: {
|
|
330
326
|
getPageContent: async (context, event) => {
|
|
331
|
-
const { room, index, additionEnable
|
|
327
|
+
const { room, index, additionEnable } = context
|
|
332
328
|
if (room.categoryId === GAME_SEARCH) {
|
|
333
329
|
return
|
|
334
|
-
} else if (!request.getToken()) {
|
|
335
|
-
const list = staticData.find((data) => data.category == room.categoryId)?.info || []
|
|
336
|
-
|
|
337
|
-
return [
|
|
338
|
-
{
|
|
339
|
-
data: list.slice(index * 20, (index + 1) * 20),
|
|
340
|
-
totalPage: Math.ceil(list.length / 20),
|
|
341
|
-
timestamp: Math.floor(Date.now() / 1000),
|
|
342
|
-
},
|
|
343
|
-
]
|
|
344
330
|
} else if (additionEnable) {
|
|
345
331
|
const param = { categoryId: room.categoryId, index }
|
|
346
332
|
return await Promise.all([request.send(api.getListCategory(param)), request.send(api.getListAddition(param))])
|
|
@@ -353,8 +339,6 @@ export default function (request) {
|
|
|
353
339
|
const { room, content, index, additionEnable } = context
|
|
354
340
|
if (room.categoryId === GAME_SEARCH) {
|
|
355
341
|
return
|
|
356
|
-
} else if (!request.getToken()) {
|
|
357
|
-
return []
|
|
358
342
|
} else if (additionEnable) {
|
|
359
343
|
return await Promise.all([
|
|
360
344
|
request.send(
|
|
@@ -449,22 +433,12 @@ const oldGuards = {
|
|
|
449
433
|
|
|
450
434
|
const oldServices = (request) => ({
|
|
451
435
|
fetchOption: async (context, event) => {
|
|
452
|
-
|
|
453
|
-
return await request.send(api.getOptionMap())
|
|
454
|
-
}
|
|
436
|
+
return await request.send(api.getOptionMap())
|
|
455
437
|
},
|
|
456
438
|
fetchGameSHA: async (context, event) => {
|
|
457
|
-
|
|
458
|
-
return await request.send(api.getGameSHA())
|
|
459
|
-
} else {
|
|
460
|
-
return {
|
|
461
|
-
status: null,
|
|
462
|
-
}
|
|
463
|
-
}
|
|
439
|
+
return await request.send(api.getGameSHA())
|
|
464
440
|
},
|
|
465
441
|
fetchStatus: async (context, event) => {
|
|
466
|
-
|
|
467
|
-
return await request.send(api.getGameStatus())
|
|
468
|
-
}
|
|
442
|
+
return await request.send(api.getGameStatus())
|
|
469
443
|
},
|
|
470
444
|
})
|
package/src/machine/index.js
CHANGED
|
@@ -3,7 +3,10 @@ import auth from './auth.js'
|
|
|
3
3
|
import welcome from './welcome.js'
|
|
4
4
|
import common from './common.js'
|
|
5
5
|
import error from './error.js'
|
|
6
|
+
import game from './game.js'
|
|
7
|
+
import game_v2 from './game_v2.js'
|
|
6
8
|
import game_v2_1 from './game_v2_1.js'
|
|
9
|
+
import game_favorite from './game_favorite.js'
|
|
7
10
|
import game_favorite_v2 from './game_favorite_v2.js'
|
|
8
11
|
import game_search from './game_search.js'
|
|
9
12
|
import game_search_v2 from './game_search_v2.js'
|
|
@@ -13,11 +16,9 @@ import merge from './merge.js'
|
|
|
13
16
|
import payment_data from './payment_data.js'
|
|
14
17
|
import reward_fc from './reward_fc.js'
|
|
15
18
|
import reward from './reward.js'
|
|
16
|
-
import reward_cash from './reward_cash.js'
|
|
17
19
|
import setting from './setting.js'
|
|
18
20
|
import side from './side.js'
|
|
19
21
|
import side_v2 from './side_v2.js'
|
|
20
|
-
import side_cash from './side_cash.js'
|
|
21
22
|
import user_info from './user_info.js'
|
|
22
23
|
import user_sign_up from './user_sign_up.js'
|
|
23
24
|
import user_reset_password from './user_reset_password.js'
|
|
@@ -44,6 +45,9 @@ export default {
|
|
|
44
45
|
common,
|
|
45
46
|
deposit,
|
|
46
47
|
error,
|
|
48
|
+
game,
|
|
49
|
+
game_v2,
|
|
50
|
+
game_favorite,
|
|
47
51
|
game_favorite_v2,
|
|
48
52
|
game_search,
|
|
49
53
|
game_search_v2,
|
|
@@ -52,12 +56,10 @@ export default {
|
|
|
52
56
|
merge,
|
|
53
57
|
payment_data,
|
|
54
58
|
reward,
|
|
55
|
-
reward_cash,
|
|
56
59
|
reward_fc,
|
|
57
60
|
setting,
|
|
58
61
|
side,
|
|
59
62
|
side_v2,
|
|
60
|
-
side_cash,
|
|
61
63
|
game_v2_1,
|
|
62
64
|
user_info,
|
|
63
65
|
user_sign_up,
|
package/src/machine/user_info.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assign, createMachine } from 'xstate'
|
|
2
2
|
import user from '../api/user.js'
|
|
3
|
-
import payment from '../api/payment.js'
|
|
4
3
|
|
|
5
4
|
export default function (request) {
|
|
6
5
|
return createMachine(
|
|
@@ -9,7 +8,6 @@ export default function (request) {
|
|
|
9
8
|
initial: 'fetching',
|
|
10
9
|
context: {
|
|
11
10
|
userInfo: {},
|
|
12
|
-
bankList: [],
|
|
13
11
|
},
|
|
14
12
|
states: {
|
|
15
13
|
fetching: {
|
|
@@ -49,17 +47,13 @@ export default function (request) {
|
|
|
49
47
|
actions: {
|
|
50
48
|
setUserInfo: assign((context, event) => {
|
|
51
49
|
return {
|
|
52
|
-
userInfo: event.data
|
|
53
|
-
bankList: event.data.bankList,
|
|
50
|
+
userInfo: event.data,
|
|
54
51
|
}
|
|
55
52
|
}),
|
|
56
53
|
},
|
|
57
54
|
services: {
|
|
58
55
|
fetchUserInfo: async (context, event) => {
|
|
59
|
-
|
|
60
|
-
const method = paymentDetail.find((payment) => payment.category === 'manual').method
|
|
61
|
-
const [bankList, userInfo] = await Promise.all([request.send(payment.getBankList(method)), request.send(user.getUserInfo())])
|
|
62
|
-
return { bankList, userInfo }
|
|
56
|
+
return await request.send(user.getUserInfo())
|
|
63
57
|
},
|
|
64
58
|
updateUserInfo: async (context, event) => {
|
|
65
59
|
return await request.send(user.updateUserInfo(event.data))
|
package/src/request/request.js
CHANGED
|
@@ -22,8 +22,8 @@ export default class Request {
|
|
|
22
22
|
this.axios.interceptors.request.use((axiosConfig) => {
|
|
23
23
|
axiosConfig.headers['X-TH1GAMES-VERSION'] = this.config.version
|
|
24
24
|
axiosConfig.headers['X-TH1GAMES-PLATFORM'] = this.config.platform
|
|
25
|
-
if (this.
|
|
26
|
-
axiosConfig.headers.Authorization = this.
|
|
25
|
+
if (storage.get(this.key)) {
|
|
26
|
+
axiosConfig.headers.Authorization = storage.get(this.key)
|
|
27
27
|
}
|
|
28
28
|
return axiosConfig
|
|
29
29
|
})
|
|
@@ -51,7 +51,7 @@ export default class Request {
|
|
|
51
51
|
async send(req, customToken) {
|
|
52
52
|
try {
|
|
53
53
|
const cancelToken = customToken || this.source.token
|
|
54
|
-
this._checkToken(req)
|
|
54
|
+
this._checkToken(req, storage.get(this.key))
|
|
55
55
|
const requestConfig = this._createConfig(req, cancelToken)
|
|
56
56
|
const { data } = await this.axios.request(requestConfig)
|
|
57
57
|
return data
|
|
@@ -97,14 +97,10 @@ export default class Request {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
_checkToken(req) {
|
|
101
|
-
if (!req.isPublic && !
|
|
100
|
+
_checkToken(req, token) {
|
|
101
|
+
if (!req.isPublic && !token) {
|
|
102
102
|
console.error(req)
|
|
103
103
|
throw { code: 'ERR_A103', url: req.url }
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
|
|
107
|
-
getToken() {
|
|
108
|
-
return storage.get(this.key)
|
|
109
|
-
}
|
|
110
106
|
}
|
package/src/util/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { getDeviceToken } from './deviceToken.js'
|
|
2
2
|
import storage from './storage.js'
|
|
3
3
|
import * as constant from './constant.js'
|
|
4
|
-
import { max } from './math.js'
|
|
5
4
|
|
|
6
5
|
export default { getDeviceToken }
|
|
7
|
-
export { constant, storage
|
|
6
|
+
export { constant, storage }
|