@jolibox/demos 0.0.1 → 1.3.3-beta.1
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/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jolibox/demos",
|
|
3
3
|
"description": "This project is common demos for development",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "1.3.3-beta.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@jolibox/sdk": "1.
|
|
11
|
-
"@jolibox/implement": "1.
|
|
10
|
+
"@jolibox/sdk": "1.3.3-beta.1",
|
|
11
|
+
"@jolibox/implement": "1.3.3-beta.1",
|
|
12
12
|
"react": "18.2.0",
|
|
13
13
|
"react-dom": "18.2.0"
|
|
14
14
|
},
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@types/react": "18.2.0",
|
|
18
18
|
"@types/react-dom": "18.2.0",
|
|
19
19
|
"typescript": "5.7.3",
|
|
20
|
-
"@jolibox/eslint-config": "1.0.1-beta.
|
|
20
|
+
"@jolibox/eslint-config": "1.0.1-beta.16",
|
|
21
21
|
"@types/jest": "28.1.1",
|
|
22
22
|
"rimraf": "6.0.1",
|
|
23
23
|
"vite": "5.1.4",
|
package/src/App.tsx
CHANGED
|
@@ -76,9 +76,18 @@ export const App = () => {
|
|
|
76
76
|
setCallbackResult(`${JSON.stringify(ev)}`);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
joliboxSDK2.lifecycle.onReady((ev) => {
|
|
79
|
+
joliboxSDK2.lifecycle.onReady(async (ev) => {
|
|
80
80
|
console.log('----receive on ready22', ev);
|
|
81
81
|
setCallbackResult(`${JSON.stringify(ev)}`);
|
|
82
|
+
|
|
83
|
+
const res = await joliboxSDK2.track({
|
|
84
|
+
event: 'testReport',
|
|
85
|
+
eventType: 0,
|
|
86
|
+
params: {
|
|
87
|
+
test: 'test'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
console.log('----track res', res);
|
|
82
91
|
});
|
|
83
92
|
|
|
84
93
|
jolibox.lifecycle.onJoliboxShow(() => {
|
|
@@ -302,6 +311,33 @@ export const App = () => {
|
|
|
302
311
|
}
|
|
303
312
|
};
|
|
304
313
|
|
|
314
|
+
const getSubscriptionPlans = useCallback(async () => {
|
|
315
|
+
try {
|
|
316
|
+
const res = await jolibox.payment.getSubscriptionPlans();
|
|
317
|
+
setResult(JSON.stringify(res ?? {}));
|
|
318
|
+
} catch (error) {
|
|
319
|
+
setResult(JSON.stringify(error ?? {}));
|
|
320
|
+
}
|
|
321
|
+
}, [jolibox]);
|
|
322
|
+
|
|
323
|
+
const flushSubInfoCache = useCallback(async () => {
|
|
324
|
+
try {
|
|
325
|
+
const res = await jolibox.payment.flushSubInfoCache();
|
|
326
|
+
setResult(JSON.stringify(res ?? {}));
|
|
327
|
+
} catch (error) {
|
|
328
|
+
setResult(JSON.stringify(error ?? {}));
|
|
329
|
+
}
|
|
330
|
+
}, [jolibox]);
|
|
331
|
+
|
|
332
|
+
const subscribe = useCallback(async () => {
|
|
333
|
+
try {
|
|
334
|
+
const res = await jolibox.payment.subscribe({ productId: 'P32477113212850250733691206557' });
|
|
335
|
+
setResult(JSON.stringify(res ?? {}));
|
|
336
|
+
} catch (error) {
|
|
337
|
+
setResult(JSON.stringify(error ?? {}));
|
|
338
|
+
}
|
|
339
|
+
}, [jolibox]);
|
|
340
|
+
|
|
305
341
|
return (
|
|
306
342
|
<div>
|
|
307
343
|
{/* 测试音频播放器 */}
|
|
@@ -325,10 +361,10 @@ export const App = () => {
|
|
|
325
361
|
>
|
|
326
362
|
Test isNativeSupport API
|
|
327
363
|
</button>
|
|
328
|
-
<button onClick={isNativeSupportAPI.bind(this, {
|
|
364
|
+
<button onClick={isNativeSupportAPI.bind(this, { version: '1.2.1' })}>
|
|
329
365
|
Test isNativeSupport versionCode
|
|
330
366
|
</button>
|
|
331
|
-
<button onClick={callHostMethod.bind(this, '
|
|
367
|
+
<button onClick={callHostMethod.bind(this, 'openMiniapp')}>Test callHostMethod</button>
|
|
332
368
|
<p style={{ whiteSpace: 'pre-wrap' }}>{result}</p>
|
|
333
369
|
<p style={{ whiteSpace: 'pre-wrap' }}>Lifecycle callback: {callbackResult}</p>
|
|
334
370
|
</div>
|
|
@@ -406,6 +442,16 @@ export const App = () => {
|
|
|
406
442
|
navigate Value: <span style={{ color: '#666' }}>{`${navigateValue}`}</span>
|
|
407
443
|
</p>
|
|
408
444
|
</div>
|
|
445
|
+
{/* payment */}
|
|
446
|
+
<div style={{ marginTop: '20px', borderTop: '1px solid #eee', paddingTop: '20px' }}>
|
|
447
|
+
<h3>navigate</h3>
|
|
448
|
+
<button onClick={getSubscriptionPlans}>getSubscriptionPlans</button>
|
|
449
|
+
<button onClick={subscribe}>subscribe</button>
|
|
450
|
+
<button onClick={flushSubInfoCache}>flushSubInfoCache</button>
|
|
451
|
+
<p>
|
|
452
|
+
navigate Value: <span style={{ color: '#666' }}>{`${navigateValue}`}</span>
|
|
453
|
+
</p>
|
|
454
|
+
</div>
|
|
409
455
|
</div>
|
|
410
456
|
</div>
|
|
411
457
|
);
|