@jolibox/implement 1.1.53-beta.0 → 1.1.54
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/.rush/temp/package-deps_build.json +34 -43
- package/dist/common/rewards/index.d.ts +0 -2
- package/dist/common/rewards/registers/utils/coins/commands/index.d.ts +1 -1
- package/dist/common/rewards/registers/utils/coins/commands/use-jolicoin.d.ts +8 -10
- package/dist/common/rewards/registers/utils/coins/commands/use-payment.d.ts +8 -10
- package/dist/common/rewards/registers/utils/coins/commands/use-unlogin.d.ts +8 -6
- package/dist/common/rewards/registers/utils/coins/index.d.ts +18 -2
- package/dist/common/rewards/registers/utils/index.d.ts +1 -3
- package/dist/common/rewards/reward-emitter.d.ts +13 -23
- package/dist/common/rewards/reward-helper.d.ts +1 -3
- package/dist/common/rewards/type.d.ts +1 -10
- package/dist/h5/report/event-tracker.d.ts +0 -1
- package/dist/index.js +9 -9
- package/dist/index.native.js +33 -33
- package/dist/native/payment/payment-helper.d.ts +1 -5
- package/dist/native/rewards/check-frequency.d.ts +0 -24
- package/implement.build.log +2 -2
- package/package.json +6 -6
- package/src/common/context/index.ts +2 -2
- package/src/common/report/base-tracker.ts +2 -2
- package/src/common/rewards/__tests__/can-use-jolicoin.test.ts +9 -265
- package/src/common/rewards/fetch-reward.ts +3 -18
- package/src/common/rewards/index.ts +0 -2
- package/src/common/rewards/registers/use-jolicoin-only.ts +4 -4
- package/src/common/rewards/registers/use-jolicoin.ts +4 -4
- package/src/common/rewards/registers/utils/coins/commands/index.ts +1 -1
- package/src/common/rewards/registers/utils/coins/commands/use-jolicoin.ts +19 -31
- package/src/common/rewards/registers/utils/coins/commands/use-payment.ts +25 -32
- package/src/common/rewards/registers/utils/coins/commands/use-unlogin.ts +24 -22
- package/src/common/rewards/registers/utils/coins/index.ts +139 -2
- package/src/common/rewards/registers/utils/index.ts +1 -20
- package/src/common/rewards/reward-emitter.ts +13 -23
- package/src/common/rewards/reward-helper.ts +1 -3
- package/src/common/rewards/type.ts +1 -13
- package/src/h5/api/ads.ts +13 -5
- package/src/h5/api/storage.ts +2 -2
- package/src/h5/http/index.ts +2 -2
- package/src/h5/report/event-tracker.ts +2 -17
- package/src/h5/rewards/index.ts +20 -33
- package/src/native/api/ads.ts +1 -22
- package/src/native/api/call-host-method.ts +1 -36
- package/src/native/network/create-fetch.ts +12 -2
- package/src/native/network/index.ts +2 -1
- package/src/native/payment/index.ts +0 -2
- package/src/native/payment/payment-helper.ts +1 -2
- package/src/native/report/task-tracker.ts +2 -4
- package/src/native/rewards/check-frequency.ts +0 -10
- package/src/native/rewards/ui/payment-modal.ts +33 -110
- package/src/native/rewards/ui/unlogin-modal.ts +87 -182
- package/src/native/rewards/ui/use-modal.ts +68 -126
- package/CHANGELOG.json +0 -11
- package/CHANGELOG.md +0 -9
- package/dist/common/rewards/registers/use-gem-only.d.ts +0 -10
- package/dist/common/rewards/registers/use-gem.d.ts +0 -10
- package/dist/common/rewards/registers/utils/coins/commands/currency-handlers.d.ts +0 -15
- package/dist/common/rewards/registers/utils/coins/currency-config.d.ts +0 -8
- package/dist/common/rewards/registers/utils/coins/jolicoin/jolicoin-handler.d.ts +0 -18
- package/dist/common/rewards/registers/utils/coins/joligem/fetch-gem-balance.d.ts +0 -4
- package/dist/common/rewards/registers/utils/coins/joligem/gem-handler.d.ts +0 -19
- package/src/common/rewards/registers/use-gem-only.ts +0 -58
- package/src/common/rewards/registers/use-gem.ts +0 -53
- package/src/common/rewards/registers/utils/coins/commands/currency-handlers.ts +0 -48
- package/src/common/rewards/registers/utils/coins/currency-config.ts +0 -23
- package/src/common/rewards/registers/utils/coins/jolicoin/jolicoin-handler.ts +0 -149
- package/src/common/rewards/registers/utils/coins/joligem/fetch-gem-balance.ts +0 -15
- package/src/common/rewards/registers/utils/coins/joligem/gem-handler.ts +0 -131
- /package/dist/common/rewards/registers/utils/coins/{jolicoin/fetch-balance.d.ts → fetch-balance.d.ts} +0 -0
- /package/src/common/rewards/registers/utils/coins/{jolicoin/fetch-balance.ts → fetch-balance.ts} +0 -0
|
@@ -6,13 +6,8 @@ import {
|
|
|
6
6
|
UseUnloginModalResultEventName
|
|
7
7
|
} from '@/common/rewards/reward-emitter';
|
|
8
8
|
import { createEventPromiseHandler } from '@/common/rewards/registers/utils/event-listener';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
updateUnloginModalFrequency,
|
|
12
|
-
checkUnloginModalFrequencyGem,
|
|
13
|
-
updateUnloginModalFrequencyGem
|
|
14
|
-
} from '../check-frequency';
|
|
15
|
-
import { StandardResponse, TrackEvent } from '@jolibox/types';
|
|
9
|
+
import { checkUnloginModalFrequency, updateUnloginModalFrequency } from '../check-frequency';
|
|
10
|
+
import { StandardResponse } from '@jolibox/types';
|
|
16
11
|
import { innerFetch as fetch } from '@/native/network';
|
|
17
12
|
import { reportError } from '@/common/report/errors/report';
|
|
18
13
|
import { EventType, InternalInvokeMethodError } from '@jolibox/common';
|
|
@@ -20,63 +15,6 @@ import { loginImplement } from '@/native/api/login';
|
|
|
20
15
|
import { createToast, createUnloginJolicoinModal } from '@jolibox/ui';
|
|
21
16
|
import { track } from '@/native/report';
|
|
22
17
|
|
|
23
|
-
// 货币配置映射
|
|
24
|
-
interface CurrencyUnloginConfig {
|
|
25
|
-
frequencyChecker: (config: {
|
|
26
|
-
show: boolean;
|
|
27
|
-
dailyMaxPopUps?: number;
|
|
28
|
-
minInterval?: number;
|
|
29
|
-
}) => Promise<{ canShow: boolean; isFirst: boolean }>;
|
|
30
|
-
frequencyUpdater: () => Promise<void>;
|
|
31
|
-
trackEvents: {
|
|
32
|
-
modalExpose: TrackEvent;
|
|
33
|
-
clickConfirm: TrackEvent;
|
|
34
|
-
clickConfirmLogin: TrackEvent;
|
|
35
|
-
modalHide: TrackEvent;
|
|
36
|
-
clickClose: TrackEvent;
|
|
37
|
-
clickWatchAds: TrackEvent;
|
|
38
|
-
};
|
|
39
|
-
toastMessage: {
|
|
40
|
-
i18nKey: string;
|
|
41
|
-
usedText: string;
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const CURRENCY_UNLOGIN_CONFIG: Record<'JOLI_COIN' | 'JOLI_GEM', CurrencyUnloginConfig> = {
|
|
46
|
-
JOLI_COIN: {
|
|
47
|
-
frequencyChecker: checkUnloginModalFrequency,
|
|
48
|
-
frequencyUpdater: updateUnloginModalFrequency,
|
|
49
|
-
trackEvents: {
|
|
50
|
-
modalExpose: 'LoginGuideModal',
|
|
51
|
-
clickConfirm: 'LoginGuideModal',
|
|
52
|
-
clickConfirmLogin: 'LoginGuideModal',
|
|
53
|
-
modalHide: 'LoginGuideModal',
|
|
54
|
-
clickClose: 'LoginGuideModal',
|
|
55
|
-
clickWatchAds: 'LoginGuideModal'
|
|
56
|
-
},
|
|
57
|
-
toastMessage: {
|
|
58
|
-
i18nKey: '{slot-i18ntran-loginGuide.rewardTips}',
|
|
59
|
-
usedText: 'Jolicoin Used'
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
JOLI_GEM: {
|
|
63
|
-
frequencyChecker: checkUnloginModalFrequencyGem,
|
|
64
|
-
frequencyUpdater: updateUnloginModalFrequencyGem,
|
|
65
|
-
trackEvents: {
|
|
66
|
-
modalExpose: 'GemLoginGuideModal', // 暂时复用,可后续扩展为 GemLoginGuideModal
|
|
67
|
-
clickConfirm: 'GemLoginGuideModal',
|
|
68
|
-
clickConfirmLogin: 'GemLoginGuideModal',
|
|
69
|
-
modalHide: 'GemLoginGuideModal',
|
|
70
|
-
clickClose: 'GemLoginGuideModal',
|
|
71
|
-
clickWatchAds: 'GemLoginGuideModal'
|
|
72
|
-
},
|
|
73
|
-
toastMessage: {
|
|
74
|
-
i18nKey: '{slot-i18ntran-loginGuide.gemRewardTips}',
|
|
75
|
-
usedText: 'Gem Used'
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
18
|
const unloginModalConfig = createEventPromiseHandler<
|
|
81
19
|
IUseModalFrequencyConfig,
|
|
82
20
|
typeof UseModalFrequencyEventName
|
|
@@ -84,142 +22,109 @@ const unloginModalConfig = createEventPromiseHandler<
|
|
|
84
22
|
|
|
85
23
|
unloginModalConfig.getData();
|
|
86
24
|
|
|
87
|
-
rewardsEmitter.on(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const currencyType = params.currency;
|
|
93
|
-
const unloginConfig = CURRENCY_UNLOGIN_CONFIG[currencyType];
|
|
94
|
-
|
|
95
|
-
if (type.includes('ADS-')) {
|
|
96
|
-
const config = await unloginModalConfig.getData();
|
|
97
|
-
console.log(`${currencyType} unlogin guide config`, config.loginGuide);
|
|
98
|
-
|
|
99
|
-
if (!config.loginGuide.show) {
|
|
100
|
-
rewardsEmitter.emit(UseUnloginModalResultEventName, { result: 'NOT_SUPPORT' });
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const { canShow: canShowUseModal } = await unloginConfig.frequencyChecker(config.loginGuide);
|
|
104
|
-
|
|
105
|
-
console.log(`${currencyType} canShowUseModal`, canShowUseModal);
|
|
106
|
-
if (!canShowUseModal) {
|
|
107
|
-
rewardsEmitter.emit(UseUnloginModalResultEventName, { result: 'FAILED' });
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
25
|
+
rewardsEmitter.on(InvokeUnloginModalEventName, async (type: 'JOLI_COIN' | 'ADS-JOLI_COIN', params) => {
|
|
26
|
+
try {
|
|
27
|
+
if (type === 'ADS-JOLI_COIN') {
|
|
28
|
+
const config = await unloginModalConfig.getData();
|
|
29
|
+
console.log('unlogin guide config', config.loginGuide);
|
|
111
30
|
|
|
112
|
-
|
|
113
|
-
if (!firstLogin?.reward) {
|
|
114
|
-
console.log('[JoliboxSDK] unlogin modal reward is empty');
|
|
31
|
+
if (!config.loginGuide.show) {
|
|
115
32
|
rewardsEmitter.emit(UseUnloginModalResultEventName, { result: 'NOT_SUPPORT' });
|
|
116
33
|
return;
|
|
117
34
|
}
|
|
35
|
+
const { canShow: canShowUseModal } = await checkUnloginModalFrequency(config.loginGuide);
|
|
118
36
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
},
|
|
126
|
-
EventType.Expose
|
|
127
|
-
);
|
|
128
|
-
const modal = createUnloginJolicoinModal({
|
|
129
|
-
data: {
|
|
130
|
-
rewardType: type,
|
|
131
|
-
rewardValue: firstLogin.reward.rewardValue,
|
|
132
|
-
currency: params.currency
|
|
133
|
-
},
|
|
134
|
-
buttons: {
|
|
135
|
-
confirm: {
|
|
136
|
-
text: params.confirmButtonText,
|
|
137
|
-
onPress: async () => {
|
|
138
|
-
// 根据货币类型上报不同的埋点
|
|
139
|
-
track(
|
|
140
|
-
unloginConfig.trackEvents.clickConfirm,
|
|
141
|
-
{ type: 'click_confirm', eventType: EventType.Click, currency: currencyType },
|
|
142
|
-
EventType.Click
|
|
143
|
-
);
|
|
144
|
-
const { isLogin, extra, isFirstLogin } = await loginImplement({}, true);
|
|
145
|
-
if (!isLogin) {
|
|
146
|
-
console.log('login failed');
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
37
|
+
console.log('canShowUseModal', canShowUseModal);
|
|
38
|
+
if (!canShowUseModal) {
|
|
39
|
+
rewardsEmitter.emit(UseUnloginModalResultEventName, { result: 'FAILED' });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
149
43
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
currency: currencyType
|
|
157
|
-
},
|
|
158
|
-
EventType.Click
|
|
159
|
-
);
|
|
160
|
-
if (isFirstLogin && extra?.firstLogin?.reward) {
|
|
161
|
-
const { rewardValue } = extra.firstLogin.reward;
|
|
162
|
-
createToast(unloginConfig.toastMessage.i18nKey, {
|
|
163
|
-
i18nParams: {
|
|
164
|
-
text: unloginConfig.toastMessage.usedText,
|
|
165
|
-
coin: rewardValue
|
|
166
|
-
},
|
|
167
|
-
position: 'top',
|
|
168
|
-
duration: 3000
|
|
169
|
-
});
|
|
170
|
-
}
|
|
44
|
+
const { firstLogin } = (await getRewardCoin()) ?? {};
|
|
45
|
+
if (!firstLogin?.reward) {
|
|
46
|
+
console.log('[JoliboxSDK] unlogin modal reward is empty');
|
|
47
|
+
rewardsEmitter.emit(UseUnloginModalResultEventName, { result: 'NOT_SUPPORT' });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
171
50
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
51
|
+
track(
|
|
52
|
+
'LoginGuideModal',
|
|
53
|
+
{
|
|
54
|
+
eventType: EventType.Expose
|
|
55
|
+
},
|
|
56
|
+
EventType.Expose
|
|
57
|
+
);
|
|
58
|
+
const modal = createUnloginJolicoinModal({
|
|
59
|
+
data: {
|
|
60
|
+
rewardType: type,
|
|
61
|
+
rewardValue: firstLogin.reward.rewardValue
|
|
62
|
+
},
|
|
63
|
+
buttons: {
|
|
64
|
+
confirm: {
|
|
65
|
+
text: params.confirmButtonText,
|
|
66
|
+
onPress: async () => {
|
|
67
|
+
track('LoginGuideModal', { type: 'click_confirm', eventType: EventType.Click }, EventType.Click);
|
|
68
|
+
const { isLogin, extra, isFirstLogin } = await loginImplement({}, true);
|
|
69
|
+
if (!isLogin) {
|
|
70
|
+
console.log('login failed');
|
|
181
71
|
return;
|
|
182
72
|
}
|
|
183
|
-
},
|
|
184
|
-
cancel: {
|
|
185
|
-
text: params.cancelButtonText,
|
|
186
|
-
onPress: ({ type }) => {
|
|
187
|
-
// 根据货币类型上报不同的埋点
|
|
188
|
-
track(
|
|
189
|
-
unloginConfig.trackEvents.modalHide,
|
|
190
|
-
{ eventType: EventType.Hide, currency: currencyType },
|
|
191
|
-
EventType.Hide
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
const trackType = type === 'CANCEL' ? 'click_close' : 'click_watch_ads';
|
|
195
|
-
const trackEvent =
|
|
196
|
-
type === 'CANCEL'
|
|
197
|
-
? unloginConfig.trackEvents.clickClose
|
|
198
|
-
: unloginConfig.trackEvents.clickWatchAds;
|
|
199
73
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
74
|
+
track(
|
|
75
|
+
'LoginGuideModal',
|
|
76
|
+
{ type: 'click_confirm_login', isFirstLogin, eventType: EventType.Click },
|
|
77
|
+
EventType.Click
|
|
78
|
+
);
|
|
79
|
+
if (isFirstLogin && extra?.firstLogin?.reward) {
|
|
80
|
+
const { rewardValue } = extra.firstLogin.reward;
|
|
81
|
+
createToast(`{slot-i18ntran-loginGuide.rewardTips}`, {
|
|
82
|
+
i18nParams: {
|
|
83
|
+
text: 'Jolicoin Used',
|
|
84
|
+
coin: rewardValue
|
|
85
|
+
},
|
|
86
|
+
position: 'top',
|
|
87
|
+
duration: 3000
|
|
88
|
+
});
|
|
207
89
|
}
|
|
90
|
+
|
|
91
|
+
rewardsEmitter.emit(UseUnloginModalResultEventName, {
|
|
92
|
+
result: 'SUCCESS',
|
|
93
|
+
rewards: {
|
|
94
|
+
jolicoin: {
|
|
95
|
+
claimedRewardValue: extra?.firstLogin?.reward?.rewardValue ?? 0,
|
|
96
|
+
isFirstLogin: isFirstLogin ?? false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
modal.destroy();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
cancel: {
|
|
105
|
+
text: params.cancelButtonText,
|
|
106
|
+
onPress: ({ type }) => {
|
|
107
|
+
track('LoginGuideModal', { eventType: EventType.Hide }, EventType.Hide);
|
|
108
|
+
|
|
109
|
+
const trackType = type === 'CANCEL' ? 'click_close' : 'click_watch_ads';
|
|
110
|
+
track('LoginGuideModal', { type: trackType, eventType: EventType.Click }, EventType.Click);
|
|
111
|
+
rewardsEmitter.emit(UseUnloginModalResultEventName, { result: 'FAILED' });
|
|
112
|
+
modal.destroy();
|
|
208
113
|
}
|
|
209
114
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
await updateUnloginModalFrequency();
|
|
118
|
+
} catch (e) {
|
|
119
|
+
reportError(new InternalInvokeMethodError(e as Error));
|
|
120
|
+
rewardsEmitter.emit(UseUnloginModalResultEventName, { result: 'FAILED' });
|
|
216
121
|
}
|
|
217
|
-
);
|
|
122
|
+
});
|
|
218
123
|
|
|
219
124
|
interface IRewardCoinResponse {
|
|
220
125
|
firstLogin: {
|
|
221
126
|
reward: {
|
|
222
|
-
rewardType: 'JOLI_COIN'
|
|
127
|
+
rewardType: 'JOLI_COIN';
|
|
223
128
|
rewardValue: number;
|
|
224
129
|
};
|
|
225
130
|
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
checkUseModalFrequency,
|
|
3
|
-
updateUseModalFrequency,
|
|
4
|
-
checkUseModalFrequencyGem,
|
|
5
|
-
updateUseModalFrequencyGem
|
|
6
|
-
} from '../check-frequency';
|
|
1
|
+
import { checkUseModalFrequency, updateUseModalFrequency } from '../check-frequency';
|
|
7
2
|
import { updateAutoDeductConfig } from './utils';
|
|
8
3
|
import {
|
|
9
4
|
IUseModalFrequencyConfig,
|
|
@@ -15,47 +10,9 @@ import { UseModalEventName, UseModalResultEventName } from '@/common/rewards/rew
|
|
|
15
10
|
import { createConfirmJolicoinModal, createLoading } from '@jolibox/ui';
|
|
16
11
|
import { track } from '@/native/report';
|
|
17
12
|
import { EventType } from '@jolibox/common';
|
|
18
|
-
import {
|
|
13
|
+
import {} from '@jolibox/ui';
|
|
19
14
|
import { createEventPromiseHandler } from '@/common/rewards/registers/utils/event-listener';
|
|
20
15
|
|
|
21
|
-
// 货币配置映射
|
|
22
|
-
interface CurrencyModalConfig {
|
|
23
|
-
frequencyConfigKey: keyof IUseModalFrequencyConfig['joliCoinUseAndCharge'];
|
|
24
|
-
trackEvents: {
|
|
25
|
-
popupShow: TrackEvent;
|
|
26
|
-
coinUnlock: TrackEvent;
|
|
27
|
-
adUnlock: TrackEvent;
|
|
28
|
-
};
|
|
29
|
-
frequencyChecker: (config: {
|
|
30
|
-
dailyMaxPopUps?: number;
|
|
31
|
-
minInterval?: number;
|
|
32
|
-
}) => Promise<{ canShow: boolean; isFirst: boolean }>;
|
|
33
|
-
frequencyUpdater: () => Promise<void>;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const CURRENCY_MODAL_CONFIG: Record<'JOLI_COIN' | 'JOLI_GEM', CurrencyModalConfig> = {
|
|
37
|
-
JOLI_COIN: {
|
|
38
|
-
frequencyConfigKey: 'useJolicoin',
|
|
39
|
-
trackEvents: {
|
|
40
|
-
popupShow: 'unlock_popup_show',
|
|
41
|
-
coinUnlock: 'coin_unlock_click',
|
|
42
|
-
adUnlock: 'ad_unlock_click'
|
|
43
|
-
},
|
|
44
|
-
frequencyChecker: checkUseModalFrequency,
|
|
45
|
-
frequencyUpdater: updateUseModalFrequency
|
|
46
|
-
},
|
|
47
|
-
JOLI_GEM: {
|
|
48
|
-
frequencyConfigKey: 'useJolicoin', // 暂时复用,可以后续扩展
|
|
49
|
-
trackEvents: {
|
|
50
|
-
popupShow: 'gem_unlock_popup_show',
|
|
51
|
-
coinUnlock: 'gem_unlock_click',
|
|
52
|
-
adUnlock: 'gem_ad_unlock_click'
|
|
53
|
-
},
|
|
54
|
-
frequencyChecker: checkUseModalFrequencyGem,
|
|
55
|
-
frequencyUpdater: updateUseModalFrequencyGem
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
16
|
const loading = createLoading();
|
|
60
17
|
|
|
61
18
|
const modalUseFrequencyConfig = createEventPromiseHandler<
|
|
@@ -65,98 +22,83 @@ const modalUseFrequencyConfig = createEventPromiseHandler<
|
|
|
65
22
|
|
|
66
23
|
modalUseFrequencyConfig.getData();
|
|
67
24
|
/**
|
|
68
|
-
* confirm
|
|
25
|
+
* confirm jolicoin modal
|
|
69
26
|
*/
|
|
70
|
-
rewardsEmitter.on(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const { canShow: canShowUseModal, isFirst: isFirstUseModal } = await modalConfig.frequencyChecker(
|
|
83
|
-
config.joliCoinUseAndCharge[modalConfig.frequencyConfigKey]
|
|
84
|
-
);
|
|
85
|
-
console.log(`${currencyType} modal show by frequency`, canShowUseModal, isFirstUseModal);
|
|
86
|
-
loading.hide();
|
|
27
|
+
rewardsEmitter.on(UseModalEventName, async (type: 'JOLI_COIN' | 'ADS-JOLI_COIN', params: IUseModalEvent) => {
|
|
28
|
+
if (type === 'ADS-JOLI_COIN') {
|
|
29
|
+
//TODO
|
|
30
|
+
await loading.show({
|
|
31
|
+
duration: 3000
|
|
32
|
+
});
|
|
33
|
+
const config = await modalUseFrequencyConfig.getData();
|
|
34
|
+
const { canShow: canShowUseModal, isFirst: isFirstUseModal } = await checkUseModalFrequency(
|
|
35
|
+
config.joliCoinUseAndCharge.useJolicoin
|
|
36
|
+
);
|
|
37
|
+
console.log('use modal show by frequency', canShowUseModal, isFirstUseModal);
|
|
38
|
+
loading.hide();
|
|
87
39
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
40
|
+
// First, check for direct use: sufficient balance, auto-deduct enabled, and not the first modal.
|
|
41
|
+
const { balance } = params.userJoliCoin;
|
|
42
|
+
const useDirectly = balance >= params.joliCoinQuantity && params.enableAutoDeduct;
|
|
91
43
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
44
|
+
if (useDirectly && !isFirstUseModal) {
|
|
45
|
+
rewardsEmitter.emit(UseModalResultEventName, { useModalResult: 'CONFIRM' });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
96
48
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
49
|
+
// If not used directly, then check frequency control.
|
|
50
|
+
if (!canShowUseModal) {
|
|
51
|
+
// confirm by frequency control
|
|
52
|
+
rewardsEmitter.emit(UseModalResultEventName, { useModalResult: 'FAILED' });
|
|
53
|
+
return;
|
|
103
54
|
}
|
|
55
|
+
}
|
|
104
56
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
currency: currencyType
|
|
110
|
-
});
|
|
57
|
+
track('unlock_popup_show', {
|
|
58
|
+
eventType: EventType.View,
|
|
59
|
+
targetType: 'game'
|
|
60
|
+
});
|
|
111
61
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
62
|
+
const modal = createConfirmJolicoinModal({
|
|
63
|
+
data: {
|
|
64
|
+
enableAutoDeduct: params.enableAutoDeduct,
|
|
65
|
+
userJolicoin: params.userJoliCoin,
|
|
66
|
+
joliCoinQuantity: params.joliCoinQuantity
|
|
67
|
+
},
|
|
68
|
+
buttons: {
|
|
69
|
+
confirm: {
|
|
70
|
+
text: params.confirmButtonText,
|
|
71
|
+
onPress: () => {
|
|
72
|
+
track('coin_unlock_click', {
|
|
73
|
+
targetType: 'game',
|
|
74
|
+
eventType: EventType.Click,
|
|
75
|
+
coinConsume: params.joliCoinQuantity,
|
|
76
|
+
ifAutoUnlock: params.enableAutoDeduct
|
|
77
|
+
});
|
|
78
|
+
rewardsEmitter.emit(UseModalResultEventName, { useModalResult: 'CONFIRM' });
|
|
79
|
+
modal.destroy();
|
|
80
|
+
}
|
|
119
81
|
},
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
track(modalConfig.trackEvents.coinUnlock as any, {
|
|
82
|
+
cancel: {
|
|
83
|
+
text: params.cancelButtonText,
|
|
84
|
+
onPress: ({ type }) => {
|
|
85
|
+
if (type === 'FAILED') {
|
|
86
|
+
track('ad_unlock_click', {
|
|
126
87
|
targetType: 'game',
|
|
127
|
-
eventType: EventType.Click
|
|
128
|
-
coinConsume: params.quantity,
|
|
129
|
-
ifAutoUnlock: params.enableAutoDeduct,
|
|
130
|
-
currency: currencyType
|
|
131
|
-
});
|
|
132
|
-
rewardsEmitter.emit(UseModalResultEventName, { useModalResult: 'CONFIRM' });
|
|
133
|
-
modal.destroy();
|
|
134
|
-
}
|
|
135
|
-
},
|
|
136
|
-
cancel: {
|
|
137
|
-
text: params.cancelButtonText,
|
|
138
|
-
onPress: ({ type }) => {
|
|
139
|
-
if (type === 'FAILED') {
|
|
140
|
-
// 根据货币类型上报不同的埋点
|
|
141
|
-
track(modalConfig.trackEvents.adUnlock as any, {
|
|
142
|
-
targetType: 'game',
|
|
143
|
-
eventType: EventType.Click,
|
|
144
|
-
currency: currencyType
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
rewardsEmitter.emit(UseModalResultEventName, {
|
|
148
|
-
useModalResult: (type ?? '') === 'CANCEL' ? 'CANCEL' : 'FAILED'
|
|
88
|
+
eventType: EventType.Click
|
|
149
89
|
});
|
|
150
|
-
modal.destroy();
|
|
151
90
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
91
|
+
rewardsEmitter.emit(UseModalResultEventName, {
|
|
92
|
+
useModalResult: (type ?? '') === 'CANCEL' ? 'CANCEL' : 'FAILED'
|
|
93
|
+
});
|
|
94
|
+
modal.destroy();
|
|
155
95
|
}
|
|
96
|
+
},
|
|
97
|
+
onEnableDeductChanged: async (enabled: boolean) => {
|
|
98
|
+
await updateAutoDeductConfig(enabled);
|
|
156
99
|
}
|
|
157
|
-
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
158
102
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
);
|
|
103
|
+
await updateUseModalFrequency();
|
|
104
|
+
});
|
package/CHANGELOG.json
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IHttpClient } from '@/common/http';
|
|
2
|
-
import { IAdBreakParams } from '@/common/ads';
|
|
3
|
-
export type GemOnlyRewardsHandler = (params: IAdBreakParams) => Promise<boolean>;
|
|
4
|
-
export declare const createGemOnlyRewardHandler: (httpClient: IHttpClient, { onUnlockSuccess, onUnlockFailed }: {
|
|
5
|
-
onUnlockSuccess?: (data: {
|
|
6
|
-
quantity: number;
|
|
7
|
-
balance: number;
|
|
8
|
-
}) => void;
|
|
9
|
-
onUnlockFailed?: () => void;
|
|
10
|
-
}) => GemOnlyRewardsHandler;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { IHttpClient } from '@/common/http';
|
|
2
|
-
import { IAdBreakParams } from '@/common/ads';
|
|
3
|
-
export type GemRewardsHandler = (params: IAdBreakParams) => Promise<boolean>;
|
|
4
|
-
export declare const createGemRewardHandler: (httpClient: IHttpClient, { onUnlockSuccess, onUnlockFailed }: {
|
|
5
|
-
onUnlockSuccess?: (data: {
|
|
6
|
-
quantity: number;
|
|
7
|
-
balance: number;
|
|
8
|
-
}) => void;
|
|
9
|
-
onUnlockFailed?: () => void;
|
|
10
|
-
}) => GemRewardsHandler;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { IHttpClient } from '@/common/http';
|
|
2
|
-
import { IJoliCoin, IGem } from '@/common/rewards/type';
|
|
3
|
-
import { IUnlockOptionsEvent } from '@/common/rewards/reward-emitter';
|
|
4
|
-
export type CurrencyType = 'JOLI_COIN' | 'JOLI_GEM';
|
|
5
|
-
export interface CurrencyHandler {
|
|
6
|
-
fetchBalance: (httpClient: IHttpClient) => Promise<{
|
|
7
|
-
balance: number;
|
|
8
|
-
} | undefined>;
|
|
9
|
-
getQuantity: (unlockOptions: IUnlockOptionsEvent | null) => number;
|
|
10
|
-
getCurrentUser: (unlockOptions: IUnlockOptionsEvent | null) => IJoliCoin | IGem;
|
|
11
|
-
createUpdatedUser: (balance: number, enableAutoDeduct: boolean) => IJoliCoin | IGem;
|
|
12
|
-
getUpdateKey: () => keyof Pick<IUnlockOptionsEvent, 'userJoliCoin' | 'userGem'>;
|
|
13
|
-
isEnough: (unlockOptions: IUnlockOptionsEvent | null, user: IJoliCoin | IGem) => boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare const CURRENCY_HANDLERS: Record<CurrencyType, CurrencyHandler>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export type CurrencyType = 'JOLI_COIN' | 'GEM';
|
|
2
|
-
export interface CurrencyConfig {
|
|
3
|
-
balanceEndpoint: string;
|
|
4
|
-
unlockEndpoint: string;
|
|
5
|
-
balanceDetailEndpoint: string;
|
|
6
|
-
unlockType: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const CURRENCY_CONFIG: Record<CurrencyType, CurrencyConfig>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { IHttpClient } from '@/common/http';
|
|
2
|
-
import { UnlockOptionsEventName, IUnlockOptionsEvent } from '@/common/rewards/reward-emitter';
|
|
3
|
-
import { IAdBreakParams } from '@/common/ads';
|
|
4
|
-
import { EventPromiseHandler } from '../../event-listener';
|
|
5
|
-
import { createInitiateAndAwaitPayment, createShowUnlockWithCurrencyModal, createShowUnloginModal } from '../commands';
|
|
6
|
-
export declare const createCommonJolicoinRewardHandler: (type: "JOLI_COIN" | "ADS-JOLI_COIN", httpClient: IHttpClient, config: {
|
|
7
|
-
handlers: {
|
|
8
|
-
handleUnlockSuccess?: (data: {
|
|
9
|
-
quantity: number;
|
|
10
|
-
balance: number;
|
|
11
|
-
}) => void;
|
|
12
|
-
handleUnlockFailed?: (params: IAdBreakParams) => void;
|
|
13
|
-
unlockOptionsHandler: EventPromiseHandler<IUnlockOptionsEvent, typeof UnlockOptionsEventName>;
|
|
14
|
-
initiateAndAwaitPayment: ReturnType<typeof createInitiateAndAwaitPayment>;
|
|
15
|
-
showUnlockWithCurrencyModal: ReturnType<typeof createShowUnlockWithCurrencyModal>;
|
|
16
|
-
showUnloginModal: ReturnType<typeof createShowUnloginModal>;
|
|
17
|
-
};
|
|
18
|
-
}) => (params: IAdBreakParams) => Promise<boolean>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IHttpClient } from '@/common/http';
|
|
2
|
-
import { UnlockOptionsEventName, IUnlockOptionsEvent } from '@/common/rewards/reward-emitter';
|
|
3
|
-
import { IAdBreakParams } from '@/common/ads';
|
|
4
|
-
import { EventPromiseHandler } from '../../event-listener';
|
|
5
|
-
import { createInitiateAndAwaitPayment, createShowUnloginModal } from '../commands';
|
|
6
|
-
import { createShowUnlockWithCurrencyModal } from '../commands/use-jolicoin';
|
|
7
|
-
export declare const createCommonGemRewardHandler: (type: "JOLI_GEM" | "ADS-JOLI_GEM", httpClient: IHttpClient, { handlers: { handleUnlockSuccess, handleUnlockFailed, unlockOptionsHandler, initiateAndAwaitPayment, showUnlockWithCurrencyModal, showUnloginModal } }: {
|
|
8
|
-
handlers: {
|
|
9
|
-
handleUnlockSuccess?: (data: {
|
|
10
|
-
quantity: number;
|
|
11
|
-
balance: number;
|
|
12
|
-
}) => void;
|
|
13
|
-
handleUnlockFailed?: (params: IAdBreakParams) => void;
|
|
14
|
-
unlockOptionsHandler: EventPromiseHandler<IUnlockOptionsEvent, typeof UnlockOptionsEventName>;
|
|
15
|
-
initiateAndAwaitPayment: ReturnType<typeof createInitiateAndAwaitPayment>;
|
|
16
|
-
showUnlockWithCurrencyModal: ReturnType<typeof createShowUnlockWithCurrencyModal>;
|
|
17
|
-
showUnloginModal: ReturnType<typeof createShowUnloginModal>;
|
|
18
|
-
};
|
|
19
|
-
}) => (params: IAdBreakParams) => Promise<boolean>;
|