@jetthai/cuora 1.0.0
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/.prettierrc +7 -0
- package/index.js +52 -0
- package/package.json +18 -0
- package/plugin/activity.js +280 -0
- package/plugin/core.js +562 -0
- package/plugin/game.js +439 -0
- package/plugin/inbox.js +211 -0
- package/plugin/information.js +57 -0
- package/plugin/payment.js +255 -0
- package/plugin/request.js +164 -0
- package/plugin/search.js +277 -0
- package/plugin/user.js +179 -0
package/plugin/search.js
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
const api = {
|
|
2
|
+
getGameTags: ({ q }) => ({ url: 'game/search', method: 'get', params: { q } }),
|
|
3
|
+
getGameSearchList: ({ id, index, q, click, clickDefault }) => ({
|
|
4
|
+
url: 'game/search/list',
|
|
5
|
+
method: 'get',
|
|
6
|
+
params: { id, index, q, click, clickDefault },
|
|
7
|
+
}),
|
|
8
|
+
setGameSearchTrace: ({ traceId, tagId, tagIndex, gameCode, gameCodeIndex, query, click }) => ({
|
|
9
|
+
url: 'game/search/trace',
|
|
10
|
+
method: 'post',
|
|
11
|
+
params: {
|
|
12
|
+
traceId,
|
|
13
|
+
tagId,
|
|
14
|
+
tagIndex,
|
|
15
|
+
gameCode,
|
|
16
|
+
gameCodeIndex,
|
|
17
|
+
query,
|
|
18
|
+
click,
|
|
19
|
+
},
|
|
20
|
+
}),
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let source = null
|
|
24
|
+
|
|
25
|
+
function createStore(request, generateSource) {
|
|
26
|
+
return {
|
|
27
|
+
namespaced: true,
|
|
28
|
+
state: () => ({
|
|
29
|
+
delay: 500,
|
|
30
|
+
timer: null,
|
|
31
|
+
keyword: '', // a set of char for searching tags
|
|
32
|
+
mainTagList: [], // a default tag list
|
|
33
|
+
tagList: [], // a searched tag list
|
|
34
|
+
gameList: [],
|
|
35
|
+
isTagFound: true,
|
|
36
|
+
tagId: null,
|
|
37
|
+
tagIndex: null,
|
|
38
|
+
traceId: null,
|
|
39
|
+
isMainTag: false,
|
|
40
|
+
isTagLoading: false,
|
|
41
|
+
isTagSearching: false,
|
|
42
|
+
}),
|
|
43
|
+
getters: {
|
|
44
|
+
getTagId(state) {
|
|
45
|
+
return state.tagId
|
|
46
|
+
},
|
|
47
|
+
getKeyword(state) {
|
|
48
|
+
return state.keyword
|
|
49
|
+
},
|
|
50
|
+
getTagFound(state) {
|
|
51
|
+
return state.isTagFound
|
|
52
|
+
},
|
|
53
|
+
getTagSearching(state) {
|
|
54
|
+
return state.isTagSearching
|
|
55
|
+
},
|
|
56
|
+
getTagLoading(state) {
|
|
57
|
+
return state.isTagLoading
|
|
58
|
+
},
|
|
59
|
+
getMainTagList(state) {
|
|
60
|
+
return state.mainTagList
|
|
61
|
+
},
|
|
62
|
+
getTagList(state) {
|
|
63
|
+
if (!state.keyword || state.tagList.length === 0) {
|
|
64
|
+
return state.mainTagList
|
|
65
|
+
} else {
|
|
66
|
+
return state.tagList
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
getGameList(state) {
|
|
70
|
+
return state.gameList
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
mutations: {
|
|
74
|
+
_setTimer(state, timer) {
|
|
75
|
+
state.timer = timer
|
|
76
|
+
},
|
|
77
|
+
_setMainTagList(state, tags) {
|
|
78
|
+
state.mainTagList = tags
|
|
79
|
+
},
|
|
80
|
+
_setTagId(state, tagId) {
|
|
81
|
+
state.tagId = tagId
|
|
82
|
+
},
|
|
83
|
+
_setTagIndex(state, tagIndex) {
|
|
84
|
+
state.tagIndex = tagIndex
|
|
85
|
+
},
|
|
86
|
+
_setTagList(state, tagList) {
|
|
87
|
+
// 後端資料不穩定 幫忙過濾一下
|
|
88
|
+
state.tagList = tagList.filter((tag) => tag.i18n)
|
|
89
|
+
},
|
|
90
|
+
_setGameList(state, gameList) {
|
|
91
|
+
state.gameList = gameList
|
|
92
|
+
},
|
|
93
|
+
_setTraceId(state, traceId) {
|
|
94
|
+
state.traceId = traceId
|
|
95
|
+
},
|
|
96
|
+
_setKeyword(state, keyword) {
|
|
97
|
+
state.keyword = keyword
|
|
98
|
+
},
|
|
99
|
+
_setMainTag(state, bool) {
|
|
100
|
+
state.isMainTag = bool
|
|
101
|
+
},
|
|
102
|
+
_setTagFound(state, bool) {
|
|
103
|
+
state.isTagFound = bool
|
|
104
|
+
},
|
|
105
|
+
_setTagSearching(state, bool) {
|
|
106
|
+
state.isTagSearching = bool
|
|
107
|
+
},
|
|
108
|
+
_setTagLoading(state, bool) {
|
|
109
|
+
state.isTagLoading = bool
|
|
110
|
+
},
|
|
111
|
+
_reset(state) {
|
|
112
|
+
state.keyword = ''
|
|
113
|
+
state.isTagFound = true
|
|
114
|
+
state.mainTagList = []
|
|
115
|
+
state.tagId = null
|
|
116
|
+
state.tagIndex = null
|
|
117
|
+
state.tagList = []
|
|
118
|
+
state.gameList = []
|
|
119
|
+
state.traceId = null
|
|
120
|
+
state.isMainTag = false
|
|
121
|
+
state.isTagLoading = false
|
|
122
|
+
state.isTagSearching = false
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
actions: {
|
|
126
|
+
async initialize({ commit, dispatch }) {
|
|
127
|
+
commit('_reset')
|
|
128
|
+
const { result = [] } = await dispatch('getGameTags')
|
|
129
|
+
commit('_setMainTagList', result)
|
|
130
|
+
const tagId = result[0]?.id
|
|
131
|
+
if (tagId) {
|
|
132
|
+
await dispatch('selectTagMain', tagId)
|
|
133
|
+
}
|
|
134
|
+
// commit('setReady', true)
|
|
135
|
+
},
|
|
136
|
+
openSearchTags({ state, commit }) {
|
|
137
|
+
commit('_setKeyword', '')
|
|
138
|
+
commit('_setTagId', null)
|
|
139
|
+
commit('_setTagList', [])
|
|
140
|
+
commit('_setTagFound', true)
|
|
141
|
+
},
|
|
142
|
+
async searchTags({ state, commit, dispatch }, keyword) {
|
|
143
|
+
commit('_setTagSearching', true)
|
|
144
|
+
commit('_setKeyword', keyword)
|
|
145
|
+
const { timer, delay } = state
|
|
146
|
+
clearTimeout(timer)
|
|
147
|
+
const newTimer = setTimeout(async () => {
|
|
148
|
+
await dispatch('_fetchTags', keyword)
|
|
149
|
+
commit('_setTagSearching', false)
|
|
150
|
+
}, delay)
|
|
151
|
+
commit('_setTimer', newTimer)
|
|
152
|
+
},
|
|
153
|
+
async _fetchTags({ state, commit, dispatch }, keyword) {
|
|
154
|
+
let tagList = []
|
|
155
|
+
try {
|
|
156
|
+
commit('_setTagLoading', true)
|
|
157
|
+
const { result = [] } = await dispatch('getGameTags', keyword)
|
|
158
|
+
tagList = result
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.log(error)
|
|
161
|
+
} finally {
|
|
162
|
+
commit('_setTagLoading', false)
|
|
163
|
+
commit('_setTagFound', tagList.length > 0 ? true : false)
|
|
164
|
+
commit('_setTagList', tagList)
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
async closeSearchTags({ state, commit, dispatch }) {
|
|
168
|
+
commit('_setKeyword', '')
|
|
169
|
+
commit('_setTagId', state.mainTagList[0].id)
|
|
170
|
+
commit('_setTagList', [])
|
|
171
|
+
commit('_setTagFound', true)
|
|
172
|
+
await dispatch('selectTagMain', state.mainTagList[0].id)
|
|
173
|
+
},
|
|
174
|
+
async selectTagMain({ state, commit, dispatch }, tagId) {
|
|
175
|
+
const index = state.mainTagList.findIndex((tag) => tag.id === tagId)
|
|
176
|
+
commit('_setKeyword', '')
|
|
177
|
+
commit('_setTagList', [])
|
|
178
|
+
commit('_setTagFound', true)
|
|
179
|
+
commit('_setTagId', tagId)
|
|
180
|
+
commit('_setTagIndex', index)
|
|
181
|
+
commit('_setMainTag', true)
|
|
182
|
+
await dispatch('_fetchGameList', { tagId, index })
|
|
183
|
+
},
|
|
184
|
+
async selectTag({ state, commit, dispatch }, tagId) {
|
|
185
|
+
const { isTagFound, tagList, keyword: q } = state
|
|
186
|
+
const index = tagList.findIndex((tag) => tag.id === tagId)
|
|
187
|
+
commit('_setMainTag', false)
|
|
188
|
+
commit('_setTagId', tagId)
|
|
189
|
+
commit('_setTagIndex', index)
|
|
190
|
+
if (isTagFound) {
|
|
191
|
+
await dispatch('_fetchGameList', { tagId, index, q, click: 1 })
|
|
192
|
+
} else {
|
|
193
|
+
await dispatch('_fetchGameList', { tagId, index, q, clickDefault: 1 })
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
async selectTagEnter({ state, commit, dispatch }) {
|
|
197
|
+
const { isTagFound, mainTagList, tagList, keyword: q } = state
|
|
198
|
+
if (isTagFound) {
|
|
199
|
+
const firstTagId = tagList.length > 0 ? tagList[0].id : mainTagList[0].id
|
|
200
|
+
commit('_setTagId', firstTagId)
|
|
201
|
+
commit('_setTagIndex', 0)
|
|
202
|
+
await dispatch('_fetchGameList', { tagId: firstTagId, index: 0, q })
|
|
203
|
+
} else {
|
|
204
|
+
commit('_setTagId', null)
|
|
205
|
+
commit('_setGameList', [])
|
|
206
|
+
await dispatch('setGameSearchTrace', { query: state.keyword })
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
async _fetchGameList({ state, commit, dispatch }, { tagId, index, q, click, clickDefault }) {
|
|
210
|
+
const { traceId, result } = await dispatch('getGameSearchList', { id: tagId, index, q, click, clickDefault })
|
|
211
|
+
commit('_setTraceId', traceId)
|
|
212
|
+
commit('_setGameList', result)
|
|
213
|
+
},
|
|
214
|
+
async sendTrace({ state, dispatch }, gameCode) {
|
|
215
|
+
const { isTagFound, isMainTag, gameList, traceId, tagId, tagIndex, keyword: query } = state
|
|
216
|
+
const gameCodeIndex = gameList.findIndex((game) => game === gameCode)
|
|
217
|
+
let param = { traceId, tagId, tagIndex, gameCode, gameCodeIndex, query }
|
|
218
|
+
|
|
219
|
+
if (!isMainTag) {
|
|
220
|
+
if (isTagFound) {
|
|
221
|
+
param.click = 1
|
|
222
|
+
} else {
|
|
223
|
+
param.clickDefault = 1
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
await dispatch('setGameSearchTrace', param)
|
|
227
|
+
},
|
|
228
|
+
async getGameTags({}, q) {
|
|
229
|
+
if (source) {
|
|
230
|
+
source.cancel('Requests Cancelled')
|
|
231
|
+
}
|
|
232
|
+
source = generateSource()
|
|
233
|
+
return await request(api.getGameTags({ q }), source.token)
|
|
234
|
+
},
|
|
235
|
+
async getGameSearchList({}, { id, index, q, click, clickDefault }) {
|
|
236
|
+
return await request(api.getGameSearchList({ id, index, q, click, clickDefault }))
|
|
237
|
+
},
|
|
238
|
+
async setGameSearchTrace({}, { traceId, tagId, tagIndex, gameCode, gameCodeIndex, query, click }) {
|
|
239
|
+
return await request(
|
|
240
|
+
api.setGameSearchTrace({
|
|
241
|
+
traceId,
|
|
242
|
+
tagId,
|
|
243
|
+
tagIndex,
|
|
244
|
+
gameCode,
|
|
245
|
+
gameCodeIndex,
|
|
246
|
+
query,
|
|
247
|
+
click,
|
|
248
|
+
})
|
|
249
|
+
)
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export default (ctx, inject) => {
|
|
256
|
+
const { store, $request, $generateSource } = ctx
|
|
257
|
+
store.registerModule('search', createStore($request, $generateSource))
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function wait(interval, fn) {
|
|
261
|
+
if (fn()) {
|
|
262
|
+
return
|
|
263
|
+
} else {
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
try {
|
|
266
|
+
const delay = setInterval(() => {
|
|
267
|
+
if (fn()) {
|
|
268
|
+
clearInterval(delay)
|
|
269
|
+
resolve()
|
|
270
|
+
}
|
|
271
|
+
}, interval)
|
|
272
|
+
} catch (err) {
|
|
273
|
+
reject()
|
|
274
|
+
}
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
}
|
package/plugin/user.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import qs from 'qs'
|
|
2
|
+
|
|
3
|
+
const api = {
|
|
4
|
+
updateUserInfo: (data) => ({ url: 'self', method: 'post', params: data }),
|
|
5
|
+
changePassword: (data) => ({ url: 'settings/password', method: 'post', params: data }),
|
|
6
|
+
reset: ({ requestId, number }) => ({ url: 'reset', method: 'post', params: { requestId, number } }),
|
|
7
|
+
getAffiliate: () => ({ url: 'affiliate', method: 'get' }),
|
|
8
|
+
postAffiliate: ({ affiliateCode }) => ({ url: 'affiliate', method: 'post', params: { affiliateCode } }),
|
|
9
|
+
passwordRecovery: (recoveryData) => ({ url: () => 'recovery', method: 'post', params: recoveryData }),
|
|
10
|
+
passwordAbandon: ({number}) => ({ url: () => 'recovery/abandon', method: 'post', params: {number} }),
|
|
11
|
+
passwordAcknowledge: (acknowledgeData) => ({
|
|
12
|
+
url: () => 'recovery/acknowledge',
|
|
13
|
+
method: 'post',
|
|
14
|
+
params: acknowledgeData,
|
|
15
|
+
}),
|
|
16
|
+
verify: () => ({ url: 'verify', method: 'post' }),
|
|
17
|
+
acknowledge: ({ requestId, code }) => ({ url: 'acknowledge', method: 'post', params: { requestId, code } }),
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function createStore(request, loadingRequest, fullURL) {
|
|
21
|
+
return {
|
|
22
|
+
namespaced: true,
|
|
23
|
+
state: () => ({
|
|
24
|
+
userInfo: null,
|
|
25
|
+
savedLevel: null,
|
|
26
|
+
isInline: false,
|
|
27
|
+
recoveryData: {},
|
|
28
|
+
}),
|
|
29
|
+
getters: {
|
|
30
|
+
isLocked(state, getters) {
|
|
31
|
+
return getters.userInfo.status === 3
|
|
32
|
+
},
|
|
33
|
+
hasTopUp(state, getters) {
|
|
34
|
+
return getters.userInfo.topup === 1
|
|
35
|
+
},
|
|
36
|
+
getCurrentLevel(state, getters) {
|
|
37
|
+
return getters.userInfo.level
|
|
38
|
+
},
|
|
39
|
+
isValidAccount(state, getters) {
|
|
40
|
+
return getters.userInfo.verification_status === 1
|
|
41
|
+
},
|
|
42
|
+
hasPoints(state, getters) {
|
|
43
|
+
return getters.userInfo.points >= 500
|
|
44
|
+
},
|
|
45
|
+
isFreeMode(state, getters) {
|
|
46
|
+
return getters.userInfo.withdraw_policy === 'FREE'
|
|
47
|
+
},
|
|
48
|
+
getServerTime(state, getters) {
|
|
49
|
+
return getters.userInfo.server_time || ''
|
|
50
|
+
},
|
|
51
|
+
userInfo(state, getters) {
|
|
52
|
+
return state.userInfo || {}
|
|
53
|
+
},
|
|
54
|
+
levelAvatarFrame: () => (level) => {
|
|
55
|
+
switch (true) {
|
|
56
|
+
case level === 0:
|
|
57
|
+
return 'guest'
|
|
58
|
+
case level <= 20:
|
|
59
|
+
return 'elite'
|
|
60
|
+
case level <= 40:
|
|
61
|
+
return 'master'
|
|
62
|
+
case level <= 60:
|
|
63
|
+
return 'epic'
|
|
64
|
+
case level <= 80:
|
|
65
|
+
return 'legend'
|
|
66
|
+
case level < 100:
|
|
67
|
+
return 'mythic'
|
|
68
|
+
case level >= 100:
|
|
69
|
+
return 'immortal'
|
|
70
|
+
default:
|
|
71
|
+
return 'guest'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
isInline(state, getters) {
|
|
75
|
+
// todo - inline check
|
|
76
|
+
return state.isInline
|
|
77
|
+
},
|
|
78
|
+
getSavedLevel(state, getters) {
|
|
79
|
+
return state.savedLevel
|
|
80
|
+
},
|
|
81
|
+
getRecoveryData(state) {
|
|
82
|
+
return state.recoveryData
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
mutations: {
|
|
86
|
+
setUserInfo(state, data) {
|
|
87
|
+
state.userInfo = data
|
|
88
|
+
},
|
|
89
|
+
setInline(state, data) {
|
|
90
|
+
state.isInline = data
|
|
91
|
+
},
|
|
92
|
+
setSavedLevel(state, data) {
|
|
93
|
+
// todo - levelup check
|
|
94
|
+
state.savedLevel = data
|
|
95
|
+
},
|
|
96
|
+
setRecoveryData(state, data) {
|
|
97
|
+
state.recoveryData = data
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
actions: {
|
|
101
|
+
async modifyUserInfo({ commit }, payload) {
|
|
102
|
+
try {
|
|
103
|
+
commit(`core/setLoading`, true, { root: true })
|
|
104
|
+
const data = await request(api.updateUserInfo(payload))
|
|
105
|
+
commit(`core/setLoading`, false, { root: true })
|
|
106
|
+
return data
|
|
107
|
+
} catch (err) {
|
|
108
|
+
commit(`core/setLoading`, false, { root: true })
|
|
109
|
+
console.log(err)
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
async changePassword({ commit }, payload) {
|
|
113
|
+
try {
|
|
114
|
+
commit(`core/setLoading`, true, { root: true })
|
|
115
|
+
const data = await request(api.changePassword(payload))
|
|
116
|
+
commit(`core/setLoading`, false, { root: true })
|
|
117
|
+
return data
|
|
118
|
+
} catch (err) {
|
|
119
|
+
commit(`core/setLoading`, false, { root: true })
|
|
120
|
+
throw err
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
async resetOTP({ commit }, { requestId, number }) {
|
|
124
|
+
try {
|
|
125
|
+
commit(`core/setLoading`, true, { root: true })
|
|
126
|
+
const data = await request(api.reset({ requestId, number }))
|
|
127
|
+
commit(`core/setVerificationData`, data, { root: true })
|
|
128
|
+
commit(`core/setLoading`, false, { root: true })
|
|
129
|
+
} catch (err) {
|
|
130
|
+
console.log(err)
|
|
131
|
+
commit(`core/setLoading`, false, { root: true })
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
async getAffiliate({}) {
|
|
135
|
+
return await request(api.getAffiliate())
|
|
136
|
+
},
|
|
137
|
+
async postAffiliate({}, affiliateCode) {
|
|
138
|
+
return await request(api.postAffiliate({ affiliateCode }))
|
|
139
|
+
},
|
|
140
|
+
async passwordAbandon({ commit }, number) {
|
|
141
|
+
await request(api.passwordAbandon({number}))
|
|
142
|
+
commit(`setRecoveryData`, {})
|
|
143
|
+
},
|
|
144
|
+
async passwordRecovery({ commit }, recoveryData) {
|
|
145
|
+
const data = await request(api.passwordRecovery(recoveryData))
|
|
146
|
+
commit(`setRecoveryData`, data)
|
|
147
|
+
},
|
|
148
|
+
async passwordAcknowledge({ commit }, acknowledgeData) {
|
|
149
|
+
await request(api.passwordAcknowledge(acknowledgeData))
|
|
150
|
+
commit(`setRecoveryData`, {})
|
|
151
|
+
},
|
|
152
|
+
async verify({ commit }) {
|
|
153
|
+
const data = await loadingRequest(api.verify())
|
|
154
|
+
commit(`core/setVerificationData`, data, { root: true })
|
|
155
|
+
return data
|
|
156
|
+
},
|
|
157
|
+
async acknowledge({}, requestId, code) {
|
|
158
|
+
return loadingRequest(api.acknowledge({ requestId, code }))
|
|
159
|
+
},
|
|
160
|
+
thirdPartyRedirect({}, method) {
|
|
161
|
+
return (
|
|
162
|
+
fullURL +
|
|
163
|
+
'login?' +
|
|
164
|
+
qs.stringify({
|
|
165
|
+
provider: method,
|
|
166
|
+
redirectURI: `${window.location.protocol}//${window.location.host}`,
|
|
167
|
+
channel: 'official',
|
|
168
|
+
subchannel: 'pwa',
|
|
169
|
+
})
|
|
170
|
+
)
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export default (ctx, inject) => {
|
|
177
|
+
const { store, $request, $loadingRequest, fullURL } = ctx
|
|
178
|
+
store.registerModule('user', createStore($request, $loadingRequest, fullURL))
|
|
179
|
+
}
|