@cc-component/cc-ex-component 1.1.6 → 1.1.8

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.
Files changed (80) hide show
  1. package/assets/core/BaseReference.ts +40 -0
  2. package/assets/{video/VideoComponent.ts.meta → core/BaseReference.ts.meta} +1 -1
  3. package/assets/core/BaseViewModelData.ts +12 -0
  4. package/assets/{video/Interface.ts.meta → core/BaseViewModelData.ts.meta} +1 -1
  5. package/assets/core/ReferenceComponent.ts +317 -0
  6. package/assets/core/ViewModel.ts +542 -0
  7. package/assets/{video/IVideo.ts.meta → core/ViewModel.ts.meta} +9 -9
  8. package/assets/ex/EXButton.ts +191 -0
  9. package/assets/ex/EXButton.ts.meta +9 -0
  10. package/assets/ex/ExCommon.ts +6 -4
  11. package/assets/ex/ExTool.ts +116 -0
  12. package/assets/ex/ExTool.ts.meta +9 -0
  13. package/assets/lib/collectView/lib-ext/custom-grid-flow-layout.ts +105 -0
  14. package/assets/lib/collectView/lib-ext/custom-grid-flow-layout.ts.meta +9 -0
  15. package/assets/lib/collectView/lib-ext/horizontal-center-layout.ts +84 -0
  16. package/assets/lib/collectView/lib-ext/horizontal-center-layout.ts.meta +9 -0
  17. package/assets/lib/collectView/lib-ext/yx-card-page-layout.ts +132 -0
  18. package/assets/lib/collectView/lib-ext/yx-card-page-layout.ts.meta +9 -0
  19. package/assets/lib/collectView/lib-ext/yx-carousel-layout.ts +156 -0
  20. package/assets/lib/collectView/lib-ext/yx-carousel-layout.ts.meta +9 -0
  21. package/assets/lib/collectView/lib-ext/yx-cover-layout.ts +405 -0
  22. package/assets/lib/collectView/lib-ext/yx-cover-layout.ts.meta +9 -0
  23. package/assets/lib/collectView/lib-ext/yx-masonry-flow-layout.ts +194 -0
  24. package/assets/lib/collectView/lib-ext/yx-masonry-flow-layout.ts.meta +9 -0
  25. package/assets/lib/collectView/lib-ext/yx-page-view.ts +232 -0
  26. package/assets/lib/collectView/lib-ext/yx-page-view.ts.meta +9 -0
  27. package/assets/lib/collectView/lib-ext/yx-table-view.ts +159 -0
  28. package/assets/lib/collectView/lib-ext/yx-table-view.ts.meta +9 -0
  29. package/assets/lib/collectView/lib-ext.meta +9 -0
  30. package/assets/lib/collectView/lib_collect/yx-collection-view.ts +1549 -0
  31. package/assets/lib/collectView/lib_collect/yx-collection-view.ts.meta +9 -0
  32. package/assets/lib/collectView/lib_collect/yx-compact-flow-layout.ts +364 -0
  33. package/assets/lib/collectView/lib_collect/yx-compact-flow-layout.ts.meta +9 -0
  34. package/assets/lib/collectView/lib_collect/yx-flow-layout.ts +909 -0
  35. package/assets/lib/collectView/lib_collect/yx-flow-layout.ts.meta +9 -0
  36. package/assets/lib/collectView/lib_collect/yx-table-layout.ts +352 -0
  37. package/assets/lib/collectView/lib_collect/yx-table-layout.ts.meta +9 -0
  38. package/assets/lib/collectView/lib_collect.meta +9 -0
  39. package/assets/{video/list.meta → lib/collectView.meta} +9 -9
  40. package/assets/lib/tableView/IListView.ts +17 -0
  41. package/assets/lib/tableView/IListView.ts.meta +9 -0
  42. package/assets/lib/tableView/ListView.ts +197 -0
  43. package/assets/lib/tableView/ListView.ts.meta +9 -0
  44. package/assets/lib/tableView/ListViewPage.ts +1048 -0
  45. package/assets/lib/tableView/ListViewPage.ts.meta +9 -0
  46. package/assets/lib/tableView/ListViewPageLoop.ts +922 -0
  47. package/assets/lib/tableView/ListViewPageLoop.ts.meta +1 -0
  48. package/assets/lib/tableView/TableView.ts +82 -0
  49. package/assets/lib/tableView/TableView.ts.meta +9 -0
  50. package/assets/lib/tableView.meta +9 -0
  51. package/assets/{video.meta → lib.meta} +1 -1
  52. package/assets/platform/Interface.ts +15 -10
  53. package/assets/platform/android/AndroidModule.ts +12 -0
  54. package/assets/platform/android/AndroidModule.ts.meta +9 -0
  55. package/assets/platform/android/AndroidSDK.ts +1 -2
  56. package/assets/platform/base/PlatfprmModule.ts +44 -29
  57. package/assets/platform/base/SDKBase.ts +2 -2
  58. package/assets/platform/base/TTSDK.ts +21 -10
  59. package/assets/platform/base/WXSDK.ts +15 -16
  60. package/assets/platform/wx/MiniSDK.ts +41 -3
  61. package/assets/platform/wx/wxmini.d.ts +2 -2
  62. package/index.ts +10 -3
  63. package/package.json +1 -1
  64. package/assets/core/ReferenceCollector.ts +0 -172
  65. package/assets/video/IVideo.ts +0 -73
  66. package/assets/video/Interface.ts +0 -25
  67. package/assets/video/VideoComponent.prefab +0 -614
  68. package/assets/video/VideoComponent.prefab.meta +0 -13
  69. package/assets/video/VideoComponent.ts +0 -33
  70. package/assets/video/VideoManager.ts +0 -399
  71. package/assets/video/VideoManager.ts.meta +0 -9
  72. package/assets/video/VideoModule.ts +0 -137
  73. package/assets/video/VideoModule.ts.meta +0 -9
  74. package/assets/video/VideoPlayTT.ts +0 -338
  75. package/assets/video/VideoPlayTT.ts.meta +0 -9
  76. package/assets/video/VideoPlayWX.ts +0 -274
  77. package/assets/video/VideoPlayWX.ts.meta +0 -9
  78. package/assets/video/VideoPlayWeb.ts +0 -228
  79. package/assets/video/VideoPlayWeb.ts.meta +0 -9
  80. /package/assets/core/{ReferenceCollector.ts.meta → ReferenceComponent.ts.meta} +0 -0
@@ -0,0 +1 @@
1
+ {"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"75405e06-7406-42a4-9fbd-3bc9aac788d4","files":[],"subMetas":{},"userData":{}}
@@ -0,0 +1,82 @@
1
+ import { _decorator, Component, Enum, find, Gradient, Graphics, instantiate, Mask, Node, NodePool, Pool, Prefab, ScrollView, Size, UITransform, utils, v2, v3 } from 'cc';
2
+ import { IIndexPath, ILayout, IListView } from './IListView';
3
+ import { collection_view_scroll_direction, ListView, node_element_comp, scroll_config } from './ListView';
4
+ import { ListViewPageLoop } from './ListViewPageLoop';
5
+ import { ListViewPage } from './ListViewPage';
6
+ const { ccclass, property } = _decorator;
7
+ @ccclass('TableView')
8
+ export class TableView extends Component {
9
+
10
+ @property({ type: scroll_config, visible: true, displayName: `配置滚动` })
11
+ config: scroll_config = new scroll_config();
12
+ public delegate: IListView
13
+ scrollView: ListView;
14
+ set isScroll(value: boolean) {
15
+ this.scrollView.isScroll = value;
16
+ if (value) {
17
+ this.scrollView.horizontal = this.config.scrollDirection == collection_view_scroll_direction.HORIZONTAL ? true : false;
18
+ this.scrollView.vertical = this.config.scrollDirection == collection_view_scroll_direction.HORIZONTAL ? false : true;
19
+ } else {
20
+ this.scrollView.horizontal = false
21
+ this.scrollView.vertical = false
22
+ }
23
+ };
24
+ get isScroll(): boolean {
25
+ return this.scrollView.isScroll;
26
+ };
27
+
28
+ get content(): Node {
29
+ return this.scrollView.content;
30
+ }
31
+
32
+ get isInit() {
33
+ return this.delegate ? true : false;
34
+ }
35
+ finish: Function;
36
+ // view: Node;
37
+ protected onLoad(): void {
38
+ if (this.config.isLoop) {
39
+ this.scrollView = this.node.addComponent(ListViewPageLoop)
40
+ } else {
41
+ this.scrollView = this.node.addComponent(ListViewPage)
42
+ }
43
+ this.scrollView.elastic = false
44
+ this.scrollView.delegate = this.delegate;
45
+ this.scrollView.config = this.config;
46
+ this.scrollView.init();
47
+ this.finish?.()
48
+ }
49
+ init(delegate: IListView) {
50
+ this.delegate = delegate
51
+ //解决一些设置时间点慢的问题
52
+ if (this.scrollView) {
53
+ this.scrollView.delegate = delegate
54
+ }
55
+ console.error("列表初始化完成2")
56
+
57
+ }
58
+ onLoadFinish(call: () => void) {
59
+ this.finish = call
60
+ }
61
+
62
+ public reload() {
63
+ this.scrollView.reloadData()
64
+ }
65
+ public moveToRow(index: number, time = 0.2) {
66
+ this.scrollView.moveToRow(index, time)
67
+ }
68
+
69
+ //子类重写
70
+ dequeueReusableCell(identifier: string, indexPath: IIndexPath): Node {
71
+ return this.scrollView.dequeueReusableCell(identifier, indexPath)
72
+ }
73
+
74
+ /**通过代码注册Cell--有大量不一样的cell的时候使用 */
75
+ registerCell(list: { identifier: string, prefab: Prefab }[]) {
76
+ this.scrollView.config.registerCell.push(...list)
77
+ }
78
+
79
+
80
+ }
81
+
82
+
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "f59aea52-42b6-4c91-9f9a-f57948a5f906",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "1.2.0",
3
+ "importer": "directory",
4
+ "imported": true,
5
+ "uuid": "513ba65f-6911-4bc5-b798-4220320a0841",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -2,7 +2,7 @@
2
2
  "ver": "1.2.0",
3
3
  "importer": "directory",
4
4
  "imported": true,
5
- "uuid": "3741d2b3-cfcc-4207-8ae0-5ed87dc637e6",
5
+ "uuid": "9b761f85-96f2-4a58-b97c-013ad8b48754",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -1,19 +1,16 @@
1
- import { _decorator } from 'cc';
2
- import { AdsData, ButtonTouch, PositonData, SDKBuyParam, SDKLoginData, SDKStatus, TTBaseData, TTData, UserInfoData } from './base/SDKEnum';
1
+ import { _decorator, Node } from 'cc';
2
+ import { AdsCall, AdsData, ButtonTouch, PositonData, SDKBuyParam, SDKLoginData, SDKStatus, TTBaseData, TTData, UserInfoData } from './base/SDKEnum';
3
3
  import { ICreateUserInfoButton } from './wx/MiniSDK';
4
+ import { SDKBase } from './base/SDKBase';
4
5
  declare global {
5
6
  namespace PlatfprmModule {
6
7
  /**小游戏:按钮触摸 需要在按钮onTouchEnd中调用的方法 使用这个属性*/
7
8
  const buttonTouch: ButtonTouch;
8
9
  //#region 通用==============
9
10
  /**模块初始化 */
10
- export function Init(): Promise<void>
11
+ export function Init(): Promise<boolean>
11
12
  /**登录 */
12
13
  export function Login(data?: string): Promise<SDKLoginData>
13
- /**退出登录 */
14
- export function Logout(): Promise<SDKStatus>
15
- /**支付--目前只有安卓接入了 */
16
- export function Pay(param: SDKBuyParam): Promise<SDKStatus>
17
14
  /**抖音:打开侧边栏
18
15
  * callBack: 从侧边栏点击进入 游戏回调
19
16
  */
@@ -25,16 +22,19 @@ declare global {
25
22
  /**激励视频初始化 */
26
23
  export function InitRewardedVideo(param: AdsData);
27
24
  /**激励视频显示 */
28
- export function ShowRewardedVideo(): Promise<boolean>
25
+ export function ShowRewardedVideo(param: AdsCall): Promise<boolean>
29
26
  //开放数据域
30
27
  export function InitOpenDataLayout(node: Node)
31
28
  export function SendMessageToOpenData(params: { type: string, event: string })
32
29
  /** 更新开放数据榜单数据 */
33
30
  export function UpdateCloudRank(key: string, score: number): Promise<boolean>
34
31
  export function ShowRank(keyList: string[], openId?: string)
35
- //#region 安卓相关===========
36
-
37
32
 
33
+ //#region 安卓相关===========
34
+ /**退出登录 */
35
+ export function Logout(): Promise<SDKStatus>
36
+ /**支付--目前只有安卓接入了 */
37
+ export function Pay(param: SDKBuyParam): Promise<SDKStatus>
38
38
 
39
39
  //#region 微信相关===========
40
40
  /**创建游戏圈按钮 */
@@ -65,6 +65,11 @@ declare global {
65
65
  export function CheckScene(scene?: string): Promise<boolean>
66
66
 
67
67
  }
68
+
69
+ namespace AndroidModule {
70
+ export function Init()
71
+ }
72
+
68
73
  }
69
74
 
70
75
  //暂时不用这种方式
@@ -0,0 +1,12 @@
1
+ import { assetManager } from "cc"
2
+ import { SDKBase } from "../base/SDKBase"
3
+ import { AndroidSDK } from "./AndroidSDK"
4
+
5
+ export class AndroidModule {
6
+
7
+ static Init() {
8
+ return new AndroidSDK()
9
+ }
10
+ }
11
+
12
+ window.AndroidModule = AndroidModule
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "07fbf5f8-5364-4dfd-863b-f9a8e103bb3e",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -80,8 +80,7 @@ export class AndroidSDK extends SDKBase {
80
80
  assetManager.loadBundle('android', (error, bundle) => {
81
81
  if (error) {
82
82
  console.error('加载bundle android 失败', error)
83
- resolve(true)
84
-
83
+ resolve(false)
85
84
  } else {
86
85
  resolve(true)
87
86
  }
@@ -1,5 +1,4 @@
1
1
  import { sys, Node } from "cc";
2
- import { AndroidSDK } from "../android/AndroidSDK";
3
2
  import { TTSDK } from "./TTSDK";
4
3
  import { SDKBase } from "./SDKBase";
5
4
  import { EditorSDK } from "./EditorSDK";
@@ -7,7 +6,7 @@ import { WXSDK } from "./WXSDK";
7
6
  import { AdsCall, AdsData, ButtonTouch, SDKBuyParam, SDKStatus, TTBaseData, TTData, UserInfoData } from "./SDKEnum";
8
7
  import { ICreateUserInfoButton } from "../wx/MiniSDK";
9
8
  import { UITransform } from "cc";
10
-
9
+ import { assetManager } from "cc";
11
10
 
12
11
  export class PlatfprmModule {
13
12
  static _instance: PlatfprmModule = null;
@@ -26,23 +25,38 @@ export class PlatfprmModule {
26
25
  wx_button_subscribe: false
27
26
  };
28
27
 
29
- Init(): Promise<boolean> {
28
+ static async Init(): Promise<boolean> {
29
+ console.error("Init")
30
30
  switch (sys.platform) {
31
31
  case sys.Platform.BYTEDANCE_MINI_GAME:
32
- this.sdk = new TTSDK();
32
+ PlatfprmModule.instance.sdk = new TTSDK();
33
33
  break;
34
34
  case sys.Platform.WECHAT_GAME:
35
35
  case sys.Platform.WECHAT_MINI_PROGRAM:
36
- this.sdk = new WXSDK();
36
+ PlatfprmModule.instance.sdk = new WXSDK();
37
37
  break;
38
38
  case sys.Platform.ANDROID:
39
- this.sdk = new AndroidSDK();
39
+ await PlatfprmModule.LoadBundle("android");
40
+ PlatfprmModule.instance.sdk = AndroidModule.Init();
40
41
  break;
41
42
  default:
42
- this.sdk = new EditorSDK();
43
+ PlatfprmModule.instance.sdk = new EditorSDK();
43
44
  break;
44
45
  }
45
- return this.sdk.init();
46
+ return PlatfprmModule.instance.sdk.init();
47
+ }
48
+ static LoadBundle(name: string): Promise<any> {
49
+ return new Promise<any>((resolve, reject) => {
50
+ assetManager.loadBundle(name, (error, bundle) => {
51
+ if (error) {
52
+ console.error('加载bundle android 失败', error)
53
+ resolve(null)
54
+ } else {
55
+ console.log('加载bundle android 成功')
56
+ resolve(bundle)
57
+ }
58
+ })
59
+ })
46
60
  }
47
61
 
48
62
  static Login(param?: any) {
@@ -53,85 +67,86 @@ export class PlatfprmModule {
53
67
  }
54
68
  /**支付--目前只有安卓接入了 */
55
69
  static Pay(param: SDKBuyParam): Promise<SDKStatus> {
56
- return PlatfprmModule.instance.sdk.pay(param);
70
+ return PlatfprmModule.instance.sdk.pay?.(param);
57
71
  }
58
72
  static NavigateToScene(param?: { scene?: string, callBack?: () => void }) {
59
- PlatfprmModule.instance.sdk.navigateToScene(param);//sidebar
73
+ PlatfprmModule.instance.sdk.navigateToScene?.(param);//sidebar
60
74
  }
61
75
 
62
76
  static RequestFeedSubscribe(call: (success: boolean) => void) {
63
77
  PlatfprmModule.instance.sdk.requestFeedSubscribe = call;
64
78
  }
65
79
  static ReportScene() {
66
- PlatfprmModule.instance.sdk.reportScene();
80
+ PlatfprmModule.instance.sdk.reportScene?.();
67
81
  }
68
82
  static ReportFeed(data: TTBaseData) {
69
- PlatfprmModule.instance.sdk.reportFeed(data.contentID, data.scene);
83
+ PlatfprmModule.instance.sdk.reportFeed?.(data.contentID, data.scene);
70
84
  }
71
85
 
72
86
  static StoreFeedData(data: TTData) {
73
- PlatfprmModule.instance.sdk.storeFeedData(data);
87
+ PlatfprmModule.instance.sdk.storeFeedData?.(data);
74
88
  }
75
89
 
76
90
  static GetFeedData(contentID: string, scene: number): Promise<boolean> {
77
- return PlatfprmModule.instance.sdk.getFeedData(contentID, scene);
91
+ return PlatfprmModule.instance.sdk.getFeedData?.(contentID, scene) ?? Promise.resolve(false);
78
92
  }
79
93
 
80
94
  static CheckFeedSubscribeStatus(): Promise<boolean> {
81
- return PlatfprmModule.instance.sdk.checkFeedSubscribeStatus();
95
+ return PlatfprmModule.instance.sdk.checkFeedSubscribeStatus?.();
82
96
  }
83
97
  static CheckScene(): Promise<boolean> {
84
- return PlatfprmModule.instance.sdk.checkScene();
98
+ return PlatfprmModule.instance.sdk.checkScene?.();
85
99
  }
86
100
  static AddShortcut() {
87
- return PlatfprmModule.instance.sdk.addShortcut();
101
+ return PlatfprmModule.instance.sdk.addShortcut?.();
88
102
  }
89
103
 
90
104
  static ToPosition(node: Node) {
91
- return PlatfprmModule.instance.sdk.toPosition(node);
105
+ return PlatfprmModule.instance.sdk.toPosition?.(node);
92
106
  }
93
107
  static CreateGameClubButton(node: Node) {
94
- return PlatfprmModule.instance.sdk.createGameClubButton(node)
108
+ return PlatfprmModule.instance.sdk.createGameClubButton?.(node) ?? null
95
109
  }
96
110
 
97
111
  static CreateUserInfoButton(param: ICreateUserInfoButton, callBack: (userInfo: UserInfoData) => void) {
98
- return PlatfprmModule.instance.sdk.createUserInfoButton(param, callBack);
112
+ return PlatfprmModule.instance.sdk.createUserInfoButton?.(param, callBack) ?? null;
99
113
  }
100
114
 
101
115
  //开放数据域
102
116
  static InitOpenDataLayout(node: Node) {
103
117
  const tr = node.getComponent(UITransform);
104
118
  const params = { x: 0, y: 0, width: tr.width, height: tr.height }
105
- PlatfprmModule.instance.sdk.initOpenDataLayout(params);
119
+ PlatfprmModule.instance.sdk.initOpenDataLayout?.(params);
106
120
  }
107
121
  static SendMessageToOpenData(params: { type: string, event: string }) {
108
- PlatfprmModule.instance.sdk.sendMessageToOpenData(params);
122
+ PlatfprmModule.instance.sdk.sendMessageToOpenData?.(params);
109
123
  }
110
124
  /** 更新微信开放数据榜单数据 */
111
125
  static UpdateCloudRank(key: string, score: number): Promise<boolean> {
112
- return PlatfprmModule.instance.sdk.updateCloudRank(key, score);
126
+ return PlatfprmModule.instance.sdk.updateCloudRank?.(key, score);
113
127
  }
114
128
  static ShowRank(keyList: string[], openId?: string) {
115
- return PlatfprmModule.instance.sdk.showRank(keyList, openId);
129
+ return PlatfprmModule.instance.sdk.showRank?.(keyList, openId);
116
130
  }
117
131
 
118
132
  /**检查是否显示隐私条约 */
119
133
  static CheckShowPrivacy(): Promise<boolean> {
120
- return PlatfprmModule.instance.sdk.checkShowPrivacy();
134
+ return PlatfprmModule.instance.sdk.checkShowPrivacy?.();
121
135
  }
122
136
  static OpenPrivacyCUrl(): void {
123
- PlatfprmModule.instance.sdk.openPrivacyCUrl();
137
+ PlatfprmModule.instance.sdk.openPrivacyCUrl?.();
124
138
  }
125
139
 
126
140
  /**激励视频初始化 */
127
141
  static InitRewardedVideo(param: AdsData) {
128
- return PlatfprmModule.instance.sdk.initRewardedVideo(param);
142
+ return PlatfprmModule.instance.sdk.initRewardedVideo?.(param);
129
143
  }
130
144
 
131
145
  /**激励视频显示 */
132
146
  static ShowRewardedVideo(param: AdsCall) {
133
- PlatfprmModule.instance.sdk.showRewardedVideo(param);
147
+ PlatfprmModule.instance.sdk.showRewardedVideo?.(param);
134
148
  }
135
149
  }
136
-
150
+ //@ts-ignore
151
+ window.PlatfprmModule = PlatfprmModule;
137
152
 
@@ -37,8 +37,8 @@ export abstract class SDKBase {
37
37
  public updateCloudRank(key: string, score: number): Promise<boolean> { return null }
38
38
  public showRank(keyList: string[], openId?: string) { }
39
39
  //#region 微信相关 =========
40
- public createUserInfoButton(param: ICreateUserInfoButton, callBack: (userInfo: UserInfoData) => void) { };
41
- public createGameClubButton(node: Node) { }
40
+ public createUserInfoButton(param: ICreateUserInfoButton, callBack: (userInfo: UserInfoData) => void) { return null };
41
+ public createGameClubButton(node: Node) { return null }
42
42
  /**检查是否显示隐私条约 */
43
43
  public checkShowPrivacy(): Promise<boolean> { return null }
44
44
  public openPrivacyCUrl(): void { }
@@ -54,7 +54,7 @@ export class TTSDK extends SDKBase {
54
54
  });
55
55
  tt.onHide(() => { });
56
56
  this.bindTouchEnd();
57
- return null
57
+ return Promise.resolve(true);
58
58
  }
59
59
 
60
60
  public login(data?: string): Promise<SDKLoginData> {
@@ -74,16 +74,26 @@ export class TTSDK extends SDKBase {
74
74
  return null
75
75
  }
76
76
 
77
-
77
+ // 在 class 中定义
78
+ private _boundOnError: any = null;
79
+ private _boundOnClose: any = null;
78
80
  public initRewardedVideo(param: AdsData) {
79
- //广告
80
- this.videoAds = tt.createRewardedVideoAd({
81
- adUnitId: param.adUnitId,
82
- });
83
- this.videoAds.offError(this.onError)
84
- this.videoAds.offClose(this.onClose); //这里监听广告的close 事件
85
- this.videoAds.onError(this.onError)
86
- this.videoAds.onClose(this.onClose); //这里监听广告的close 事件
81
+ this.videoAds = tt.createRewardedVideoAd({ adUnitId: param.adUnitId });
82
+
83
+ // 先移除旧监听(如果存在)
84
+ if (this._boundOnError) {
85
+ this.videoAds.offError(this._boundOnError);
86
+ }
87
+ if (this._boundOnClose) {
88
+ this.videoAds.offClose(this._boundOnClose);
89
+ }
90
+
91
+ // 缓存 bind 后的函数
92
+ this._boundOnError = this.onError.bind(this);
93
+ this._boundOnClose = this.onClose.bind(this);
94
+
95
+ this.videoAds.onError(this._boundOnError);
96
+ this.videoAds.onClose(this._boundOnClose);
87
97
  }
88
98
 
89
99
  public showRewardedVideo(param: AdsCall) {
@@ -220,6 +230,7 @@ export class TTSDK extends SDKBase {
220
230
  } else {
221
231
  this.adsCall.fail?.('未完整观看视频')
222
232
  }
233
+ this.adsCall.close?.(res)
223
234
  // console.log("视频广告关闭:", res, res.isEnded);
224
235
  }
225
236
 
@@ -16,10 +16,21 @@ export class WXSDK extends SDKBase {
16
16
 
17
17
  });
18
18
  this.bindTouchEnd()
19
- return null
19
+ return Promise.resolve(true);
20
20
  }
21
21
  public login(data?: string): Promise<SDKLoginData> {
22
- throw new Error('Method not implemented.');
22
+ return new Promise((resolve, reject) => {
23
+ wx.login({
24
+ success: function (res: any) {
25
+ //console.warn(`获取code`, res);
26
+ resolve({ success: true, code: res.code })
27
+ },
28
+ fail: function (err) {
29
+ // console.error(`获取code失败`, err);
30
+ resolve({ success: false, code: "" })
31
+ }
32
+ });
33
+ })
23
34
  }
24
35
  public logout(): Promise<SDKStatus> {
25
36
  return null
@@ -30,20 +41,7 @@ export class WXSDK extends SDKBase {
30
41
 
31
42
  public showRewardedVideo(param: AdsCall) {
32
43
  this.adsCall = param;
33
- miniSDK.showRewardedVideoAd({
34
- onShow: () => {
35
- this.adsCall.show?.()
36
- },
37
- onClose: (success: boolean) => {
38
- if (success)
39
- this.adsCall.success?.()
40
- else
41
- this.adsCall.close?.()
42
- },
43
- onError: (res) => {
44
- this.adsCall.error?.(res)
45
- },
46
- })
44
+ miniSDK.showRewardedAd(param)
47
45
  }
48
46
 
49
47
 
@@ -87,6 +85,7 @@ export class WXSDK extends SDKBase {
87
85
  }
88
86
 
89
87
  public sendMessageToOpenData(params: { type: string, event: string }) {
88
+ console.log("发生", params);
90
89
  let openDataContext = wx.getOpenDataContext();
91
90
  openDataContext.postMessage(params)
92
91
  }
@@ -1,5 +1,8 @@
1
1
  import { EventTarget, Game, Node, Rect, Sprite, Texture2D, UITransform, game, rect, screen, sys, view } from 'cc';
2
2
  import { DEV } from 'cc/env';
3
+ import { AdsCall } from '../base/SDKEnum';
4
+ type StringCallback = (str?: string) => void;
5
+
3
6
 
4
7
  export interface IInit {
5
8
  // 视频广告ID
@@ -351,7 +354,8 @@ export class MiniSDK {
351
354
  this.log('rewardedVideoAd onClose', res);
352
355
  });
353
356
 
354
- this._rewardedVideoAd.onError(() => {
357
+ this._rewardedVideoAd.onError((res) => {
358
+ console.error("res", res)
355
359
  // 出错了
356
360
  this._rewardedVideoAdLoadState = 0;
357
361
  });
@@ -385,10 +389,10 @@ export class MiniSDK {
385
389
  this.emit('RewardedVideoAdLoad');
386
390
  this.log('loadRewardedVideoAd', 'success');
387
391
  })
388
- .catch(() => {
392
+ .catch((res) => {
389
393
  this._rewardedVideoAdLoadState = 0;
390
394
  this.emit('RewardedVideoAdError');
391
- this.log('loadRewardedVideoAd', 'error');
395
+ this.log('loadRewardedVideoAd', 'error', res);
392
396
  });
393
397
  }
394
398
 
@@ -430,6 +434,40 @@ export class MiniSDK {
430
434
  });
431
435
  }
432
436
 
437
+
438
+
439
+ private _onRewardedAdClose: (res) => void;
440
+ private _onRewardedAdError: (error) => void;
441
+ /** 展示激励视频广告 */
442
+ public showRewardedAd(call: AdsCall) {
443
+ if (!this._onRewardedAdClose) {
444
+ this._onRewardedAdClose = (res) => {
445
+ if (res.isEnded) {
446
+ call.success?.();
447
+ } else {
448
+ call.fail?.('未完整观看视频');
449
+ }
450
+ call.close?.(res);
451
+ }
452
+ this._onRewardedAdError = (err) => {
453
+ call.error?.(err);
454
+ }
455
+ }
456
+
457
+ let video = wx.createRewardedVideoAd({
458
+ adUnitId: this.videoID
459
+ });
460
+ video.offClose(this._onRewardedAdClose);
461
+ video.offError(this._onRewardedAdError);
462
+ video.onClose(this._onRewardedAdClose);
463
+ video.onError(this._onRewardedAdError);
464
+ video.load().then(() => {
465
+ video.show().then(() => {
466
+ call.show?.()
467
+ });
468
+ });
469
+ }
470
+
433
471
  /**************************** banner广告 ****************************/
434
472
  private _bannerAd = null;
435
473
  // banner是否加载完成
@@ -521,11 +521,11 @@ declare namespace wx {
521
521
  /** 监听激励视频错误事件*/
522
522
  onError(callback: (res: { errMsg: string, errCode: 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 }) => void): void;
523
523
  /** 取消监听激励视频错误事件*/
524
- offError(callback: () => void): void;
524
+ offError(callback: (res) => void): void;
525
525
  /** 监听用户点击 关闭广告 按钮的事件*/
526
526
  onClose(callback: (res: { isEnded: boolean }) => void);
527
527
  /** 取消监听用户点击 关闭广告 按钮的事件*/
528
- offClose(callback: () => void);
528
+ offClose(callback: (res) => void);
529
529
  }
530
530
 
531
531
  /**
package/index.ts CHANGED
@@ -1,6 +1,13 @@
1
1
  // 负责导出assets下的模块,如: export { default } from './assets/xxx.ts'
2
2
  export { } from './assets/ex/ExCommon';
3
- export { } from './assets/video/Interface';
4
- export { } from './assets/platform/Interface';
5
- export { ReferenceCollector } from './assets/core/ReferenceCollector';
3
+
4
+ export * from './assets/core/ViewModel';
5
+ export * from './assets/core/ReferenceComponent';
6
+ export * from './assets/core/BaseReference';
7
+ export * from './assets/core/BaseViewModelData';
8
+
9
+
10
+ export * from './assets/lib/tableView/TableView';
11
+ export * from './assets/lib/collectView/lib_collect/yx-collection-view';
12
+ export * from './assets/lib/collectView/lib_collect/yx-flow-layout';
6
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-ex-component",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",