@cc-component/cc-ex-component 1.2.6 → 1.2.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 (84) hide show
  1. package/assets/core/ReferenceComponent.ts +24 -17
  2. package/assets/core/ViewModel.ts +50 -6
  3. package/package.json +1 -1
  4. package/assets/platform/Interface.ts +0 -80
  5. package/assets/platform/Interface.ts.meta +0 -9
  6. package/assets/platform/android/AndroidModule.ts +0 -12
  7. package/assets/platform/android/AndroidModule.ts.meta +0 -9
  8. package/assets/platform/android/AndroidSDK.ts +0 -186
  9. package/assets/platform/android/AndroidSDK.ts.meta +0 -1
  10. package/assets/platform/android/AnyThinkAds/ATBanner.ts +0 -266
  11. package/assets/platform/android/AnyThinkAds/ATBanner.ts.meta +0 -9
  12. package/assets/platform/android/AnyThinkAds/ATInterstitial.ts +0 -185
  13. package/assets/platform/android/AnyThinkAds/ATInterstitial.ts.meta +0 -9
  14. package/assets/platform/android/AnyThinkAds/ATInterstitialAuto.ts +0 -180
  15. package/assets/platform/android/AnyThinkAds/ATInterstitialAuto.ts.meta +0 -9
  16. package/assets/platform/android/AnyThinkAds/ATNative.ts +0 -256
  17. package/assets/platform/android/AnyThinkAds/ATNative.ts.meta +0 -9
  18. package/assets/platform/android/AnyThinkAds/ATRewardedAutoVideo.ts +0 -175
  19. package/assets/platform/android/AnyThinkAds/ATRewardedAutoVideo.ts.meta +0 -9
  20. package/assets/platform/android/AnyThinkAds/ATRewardedVideo.ts +0 -243
  21. package/assets/platform/android/AnyThinkAds/ATRewardedVideo.ts.meta +0 -9
  22. package/assets/platform/android/AnyThinkAds/ATSDK.ts +0 -222
  23. package/assets/platform/android/AnyThinkAds/ATSDK.ts.meta +0 -9
  24. package/assets/platform/android/AnyThinkAds/ATSplash.ts +0 -155
  25. package/assets/platform/android/AnyThinkAds/ATSplash.ts.meta +0 -9
  26. package/assets/platform/android/AnyThinkAds/Android/ATAndroidBannerTS.ts +0 -71
  27. package/assets/platform/android/AnyThinkAds/Android/ATAndroidBannerTS.ts.meta +0 -9
  28. package/assets/platform/android/AnyThinkAds/Android/ATAndroidInterstitialAutoTS.ts +0 -52
  29. package/assets/platform/android/AnyThinkAds/Android/ATAndroidInterstitialAutoTS.ts.meta +0 -9
  30. package/assets/platform/android/AnyThinkAds/Android/ATAndroidInterstitialTS.ts +0 -41
  31. package/assets/platform/android/AnyThinkAds/Android/ATAndroidInterstitialTS.ts.meta +0 -9
  32. package/assets/platform/android/AnyThinkAds/Android/ATAndroidNativeTS.ts +0 -47
  33. package/assets/platform/android/AnyThinkAds/Android/ATAndroidNativeTS.ts.meta +0 -9
  34. package/assets/platform/android/AnyThinkAds/Android/ATAndroidRewardedVideoAutoTS.ts +0 -52
  35. package/assets/platform/android/AnyThinkAds/Android/ATAndroidRewardedVideoAutoTS.ts.meta +0 -9
  36. package/assets/platform/android/AnyThinkAds/Android/ATAndroidRewardedVideoTS.ts +0 -41
  37. package/assets/platform/android/AnyThinkAds/Android/ATAndroidRewardedVideoTS.ts.meta +0 -9
  38. package/assets/platform/android/AnyThinkAds/Android/ATAndroidSplashTS.ts +0 -42
  39. package/assets/platform/android/AnyThinkAds/Android/ATAndroidSplashTS.ts.meta +0 -9
  40. package/assets/platform/android/AnyThinkAds/Android/ATAndroidTS.ts +0 -73
  41. package/assets/platform/android/AnyThinkAds/Android/ATAndroidTS.ts.meta +0 -9
  42. package/assets/platform/android/AnyThinkAds/Android.meta +0 -9
  43. package/assets/platform/android/AnyThinkAds/iOS/ATiOSBannerTS.ts +0 -66
  44. package/assets/platform/android/AnyThinkAds/iOS/ATiOSBannerTS.ts.meta +0 -9
  45. package/assets/platform/android/AnyThinkAds/iOS/ATiOSInterstitiaAutolTS.ts +0 -54
  46. package/assets/platform/android/AnyThinkAds/iOS/ATiOSInterstitiaAutolTS.ts.meta +0 -9
  47. package/assets/platform/android/AnyThinkAds/iOS/ATiOSInterstitialTS.ts +0 -43
  48. package/assets/platform/android/AnyThinkAds/iOS/ATiOSInterstitialTS.ts.meta +0 -9
  49. package/assets/platform/android/AnyThinkAds/iOS/ATiOSNativeTS.ts +0 -47
  50. package/assets/platform/android/AnyThinkAds/iOS/ATiOSNativeTS.ts.meta +0 -9
  51. package/assets/platform/android/AnyThinkAds/iOS/ATiOSRewardedAutoVideoTS.ts +0 -55
  52. package/assets/platform/android/AnyThinkAds/iOS/ATiOSRewardedAutoVideoTS.ts.meta +0 -9
  53. package/assets/platform/android/AnyThinkAds/iOS/ATiOSRewardedVideoTS.ts +0 -43
  54. package/assets/platform/android/AnyThinkAds/iOS/ATiOSRewardedVideoTS.ts.meta +0 -9
  55. package/assets/platform/android/AnyThinkAds/iOS/ATiOSSplashTS.ts +0 -47
  56. package/assets/platform/android/AnyThinkAds/iOS/ATiOSSplashTS.ts.meta +0 -9
  57. package/assets/platform/android/AnyThinkAds/iOS/ATiOSTS.ts +0 -76
  58. package/assets/platform/android/AnyThinkAds/iOS/ATiOSTS.ts.meta +0 -9
  59. package/assets/platform/android/AnyThinkAds/iOS.meta +0 -9
  60. package/assets/platform/android/AnyThinkAds.meta +0 -9
  61. package/assets/platform/android/iOSSDK.ts +0 -14
  62. package/assets/platform/android/iOSSDK.ts.meta +0 -1
  63. package/assets/platform/android.meta +0 -11
  64. package/assets/platform/base/EditorSDK.ts +0 -30
  65. package/assets/platform/base/EditorSDK.ts.meta +0 -1
  66. package/assets/platform/base/PlatfprmModule.ts +0 -152
  67. package/assets/platform/base/PlatfprmModule.ts.meta +0 -9
  68. package/assets/platform/base/SDKBase.ts +0 -59
  69. package/assets/platform/base/SDKBase.ts.meta +0 -9
  70. package/assets/platform/base/SDKEnum.ts +0 -127
  71. package/assets/platform/base/SDKEnum.ts.meta +0 -9
  72. package/assets/platform/base/TTSDK.ts +0 -366
  73. package/assets/platform/base/TTSDK.ts.meta +0 -9
  74. package/assets/platform/base/WXSDK.ts +0 -149
  75. package/assets/platform/base/WXSDK.ts.meta +0 -1
  76. package/assets/platform/base.meta +0 -9
  77. package/assets/platform/wx/MiniSDK.ts +0 -1039
  78. package/assets/platform/wx/MiniSDK.ts.meta +0 -9
  79. package/assets/platform/wx/lib.douyin.d.ts +0 -168
  80. package/assets/platform/wx/lib.douyin.d.ts.meta +0 -9
  81. package/assets/platform/wx/wxmini.d.ts +0 -2452
  82. package/assets/platform/wx/wxmini.d.ts.meta +0 -9
  83. package/assets/platform/wx.meta +0 -9
  84. package/assets/platform.meta +0 -9
@@ -1,59 +0,0 @@
1
- import { ICreateUserInfoButton } from "../wx/MiniSDK";
2
- import { AdsCall, AdsData, PositonData, SDKBuyParam, SDKLoginData, SDKStatus, TTData, UserInfoData } from "./SDKEnum";
3
- import { Node } from "cc";
4
-
5
- export abstract class SDKBase {
6
- protected readonly ONLINE_ADDRESS = "https://daluosi.wyx.cn/";
7
- protected readonly TEST_1_ADDRESS = "http://192.168.1.253:9999/"
8
- protected readonly DEV_NET_ADDRESS = "http://192.168.6.17:9999/";
9
- protected readonly CDN_ADDRESS = "remote/bundles/story/video/";
10
- protected readonly LOGIN_URL: string = "app/v1/player/login";
11
- platformId = 'feizhu'
12
- client_version = '1.0'
13
-
14
- protected _userInfo?: any;
15
- public get userInfo() { return this._userInfo; }
16
- abstract init(): Promise<boolean>;
17
- /**登录 */
18
- public abstract login(data?: string): Promise<SDKLoginData>;
19
- /**登出 */
20
- public abstract logout(): Promise<SDKStatus>;
21
-
22
- // /**上报数据 */
23
- // public abstract report(name: string, param: any): Promise<void>
24
- //#region 广告相关
25
- /**初始化广告 */
26
- public abstract initRewardedVideo(param: AdsData)
27
- /**显示广告 */
28
- public abstract showRewardedVideo(param: AdsCall)
29
-
30
- public abstract toPosition(node: Node): PositonData;
31
- /**支付 */
32
- public pay(param: SDKBuyParam): Promise<SDKStatus> { return null }
33
- //开放数据域
34
- public initOpenDataLayout(params: { x: number, y: number, width: number, height: number }) { }
35
- public sendMessageToOpenData(params: { type: string, event: string }) { }
36
- /** 更新微信开放数据榜单数据 */
37
- public updateCloudRank(key: string, score: number): Promise<boolean> { return null }
38
- public showRank(keyList: string[], openId?: string) { }
39
- //#region 微信相关 =========
40
- public createUserInfoButton(param: ICreateUserInfoButton, callBack: (userInfo: UserInfoData) => void) { return null };
41
- public createGameClubButton(node: Node) { return null }
42
- /**检查是否显示隐私条约 */
43
- public checkShowPrivacy(): Promise<boolean> { return null }
44
- public openPrivacyCUrl(): void { }
45
- //#region 抖音相关 =========
46
- /**添加到桌面 */
47
- public addShortcut(): Promise<boolean> { return Promise.resolve(false) };
48
- /**抖音订阅视频流回调 */
49
- public requestFeedSubscribe: (success: boolean) => void;
50
- public reportScene() { };
51
- public reportFeed(contentID: string, scene: number) { };
52
- public storeFeedData(data: TTData): Promise<boolean> { return Promise.resolve(false) };
53
- public getFeedData(contentID: string, scene: number): Promise<boolean> { return Promise.resolve(false) };
54
- public navigateToScene(param?: { scene?: string, callBack?: () => void }) { }
55
- public checkFeedSubscribeStatus(): Promise<boolean> { return null }
56
- public async checkScene(): Promise<boolean> { return new Promise((resolve) => resolve(false)); }
57
-
58
- }
59
-
@@ -1,9 +0,0 @@
1
- {
2
- "ver": "4.0.24",
3
- "importer": "typescript",
4
- "imported": true,
5
- "uuid": "ba7be552-4fb8-4dc0-bccd-20800aea4ddf",
6
- "files": [],
7
- "subMetas": {},
8
- "userData": {}
9
- }
@@ -1,127 +0,0 @@
1
- export enum SDKStatus {
2
- /**没有 */
3
- none = -2,
4
- /**系统错误 */
5
- error = -1,
6
- /**失败 */
7
- fail = 0,
8
- /**成功 */
9
- success = 1,
10
- /**未准备好 */
11
- unready = 2,
12
-
13
- }
14
-
15
-
16
- export interface AdsCall {
17
- /** 观看视频完成 */
18
- success: Function;
19
- /** 未完整观看视频 */
20
- fail?: (errorInfo: any) => void;
21
- /** 视频开始展示 */
22
- show?: Function;
23
- /** 视频关闭 */
24
- close?: Function;
25
- /** 点击视频 */
26
- click?: Function;
27
- /** 加载视频失败 */
28
- error?: (errorInfo: any) => void;
29
- }
30
-
31
- export enum SDKEnum {
32
- Init = "Init",
33
- Login = "Login",
34
- Logout = "Logout",
35
- LoginSuccess = 'LoginSuccess',
36
- LoginFailed = 'LoginFailed',
37
- DeviceInfo = "DeviceInfo",
38
- PseudoID = "PseudoID",
39
- Buy = "Buy",
40
- }
41
-
42
- export interface SDKLoginData { success: boolean, code: string }
43
-
44
-
45
- export interface SDKInitParam {
46
- gameId: string
47
- deviceId: string
48
- deviceOs: string
49
- region: string
50
- mac: string
51
- oaid: string
52
- idfa: string
53
- androidid: string
54
- ip: string
55
- /**自己服务器的玩家id */
56
- gameRoleID: string
57
- /**sdk返回的玩家id */
58
- userId: string
59
- }
60
-
61
- export interface SDKBuyParam {
62
- /**描述 */
63
- description: string,
64
- /**角色id */
65
- gameRoleID: string,
66
- /**角色名称 */
67
- gameRoleName: string,
68
- /**角色等级 */
69
- gameRoleGrade: string,
70
- /**区服id */
71
- serverFlag: string,
72
- /**回传地址,我们自己服务器给的url 服务器给的*/
73
- url: string,
74
- /**我们自己服务器返回的玩家sdk id -服务器给的*/
75
- userId: string,
76
- /**商品id */
77
- item: string,
78
- /**商品价格 */
79
- price: number,
80
- /**商品数量 */
81
- count: string,
82
- /**商品订单--服务器给的 */
83
- order: string
84
- }
85
-
86
- export interface TTBaseData {
87
- /**抖音后台的配置ID */
88
- contentID: string,
89
- /**场景ID */
90
- scene: number,
91
- }
92
- export interface TTData extends TTBaseData {
93
- /**扩展字段 */
94
- ext: string,
95
- /**倒计时毫秒 */
96
- time: number
97
- }
98
-
99
- export interface AdsData {
100
- /**广告位id */
101
- adUnitId: string
102
- /**广告id */
103
- appId?: string
104
- /**广告key */
105
- appKey?: string
106
- /**场景id */
107
- sceneId?: string
108
- }
109
- export interface PositonData { x: number, y: number, width: number, height: number }
110
-
111
- export interface UserInfoData {
112
- /** 用户昵称*/
113
- nickName: string;
114
- /** 用户头像图片的 URL。URL 最后一个数值代表正方形头像大小(有 0、46、64、96、132 数值可选,0 代表 640x640 的正方形头像,46 表示 46x46 的正方形头像,剩余数值以此类推。默认132),用户没有头像时该项为空。若用户更换头像,原有头像 URL 将失效。*/
115
- avatarUrl: string;
116
- }
117
-
118
- export interface ButtonTouch {
119
- /**抖音添加到桌面按钮 */
120
- tt_button: boolean;
121
- /**抖音订阅 消息id ,值:MSG1738838137157339868090924108072*/
122
- tt_button_subscribe: string;
123
- /**抖音订阅视频流 */
124
- tt_button_feedsubscribe: boolean;
125
- /**微信订阅 */
126
- wx_button_subscribe: boolean;
127
- }
@@ -1,9 +0,0 @@
1
- {
2
- "ver": "4.0.24",
3
- "importer": "typescript",
4
- "imported": true,
5
- "uuid": "172dee1b-f34d-4e18-9a9d-a7cd4ce991e1",
6
- "files": [],
7
- "subMetas": {},
8
- "userData": {}
9
- }
@@ -1,366 +0,0 @@
1
- import { _decorator, Component, Node } from 'cc';
2
- import { SDKBase } from './SDKBase';
3
- import { AdsCall, AdsData, PositonData, SDKLoginData, SDKStatus, TTData } from './SDKEnum';
4
- const { ccclass, property } = _decorator;
5
-
6
- @ccclass('TTSDK')
7
- export class TTSDK extends SDKBase {
8
- videoAds: any;
9
- videoAdsLoadResolve: any = null
10
- adsCall: AdsCall;
11
- sidebarCall: Function;
12
- init(): Promise<boolean> {
13
- const windowInfo = tt.getSystemInfoSync();
14
- var options = tt.getLaunchOptionsSync();
15
- const scene: string = options.scene;
16
- const query: any = options.query;
17
- const self = this
18
- let enter_game = false;
19
- //直播伴侣进入小游戏
20
- if (scene === '029003') {
21
-
22
- }
23
- //用于判断是否为推荐流直出场景(xx为可变的数字,判断后四位是 3041 即可确认为推荐流直出)
24
- if (scene.includes("3041")) {
25
- //console.log("1启动参数:", options)
26
- const feed_game_scene = options.query.feed_game_scene
27
- const feed_game_channel = options.query.feed_game_channel//1.复访用户,2.获客用户
28
- const feed_game_extra = options.query.feed_game_extra//开发者自定义字段,可通过 推荐流直出能力 OpenAPI 接入文档 接口的 extra 字段进行赋值
29
- if (feed_game_extra === "1" || feed_game_extra === "2" || feed_game_channel === 2) {
30
- enter_game = true
31
- }
32
- tt.onFeedStatusChange(({ type }) => {
33
- if (type === 'feedEnter') {
34
- console.log('触发从Feed流进入小游戏事件回调')
35
- }
36
- if (type === 'feedExit') {
37
- console.log('触发从小游戏退回到Feed流事件回调')
38
- }
39
- })
40
- }
41
- //console.log("1启动参数:", options)
42
- tt.onShow((res) => {
43
- //从侧边栏进入小游戏
44
- if (res.scene == "021036" && res.launch_from == "homepage" && res.location == "sidebar_card") {
45
- setTimeout(() => {
46
- self.sidebarCall?.()
47
- self.sidebarCall = null;
48
- }, 200);
49
- }
50
- // console.log("启动参数:", res.query);
51
- // console.log("来源信息:", res.refererInfo);
52
- // console.log("场景值:", res.scene);
53
- // console.log("启动场景字段:", res.launch_from, ", ", res.location);
54
- });
55
- tt.onHide(() => { });
56
- this.bindTouchEnd();
57
- return Promise.resolve(true);
58
- }
59
-
60
- public login(data?: string): Promise<SDKLoginData> {
61
- return new Promise<SDKLoginData>((resolve, reject) => {
62
- tt.login({
63
- success: function (res: any) {
64
- resolve({ success: true, code: res.code })
65
- },
66
- fail: function (err) {
67
- console.log(`获取code失败`, err);
68
- resolve({ success: false, code: "" })
69
- }
70
- });
71
- });
72
- }
73
- public logout(): Promise<SDKStatus> {
74
- return null
75
- }
76
-
77
- // 在 class 中定义
78
- private _boundOnError: any = null;
79
- private _boundOnClose: any = null;
80
- public initRewardedVideo(param: AdsData) {
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);
97
- }
98
-
99
- public showRewardedVideo(param: AdsCall) {
100
- this.adsCall = param;
101
- this.videoAds.show().then(() => {
102
- console.log("视频广告展示");
103
- this.adsCall.show?.();
104
- });
105
- }
106
-
107
- initTTScene() {
108
- this.reportScene()
109
- // setInterval(() => {
110
- // SDKManager.instance.getFeedData("CONTENT13014381058", 1)
111
- // }, 1000);
112
- }
113
-
114
- reportScene() {
115
- tt.reportScene({
116
- sceneId: 7001,
117
- costTime: 350,
118
- dimension: {
119
- d1: '2.1.0', // value仅支持传入String类型。若value表示Boolean,请将值处理为'0'、'1'进行上报;若value为Number,请转换为String进行上报
120
- },
121
- metric: {
122
- m1: '546', // value仅支持传入数值且需要转换为String类型进行上报
123
- },
124
- success(res) {
125
- // 上报接口执行完成后的回调,用于检查上报数据是否符合预期
126
- //console.log('成功', res)
127
- },
128
- fail(res) {
129
- // 上报报错时的回调,用于查看上报错误的原因:如参数类型错误等
130
- console.log('失败', res)
131
- }
132
- })
133
- }
134
-
135
- // ttOther(data: TTData) {
136
- // this.storeFeedData("CONTENT12694320898", 2, "2", 1000 * 60 * 10)
137
- // }
138
-
139
- // ttOffline(data: TTData) {
140
- // this.storeFeedData("CONTENT13014381058", 1, "1", 1000 * 60 * 1)
141
- // }
142
-
143
- storeFeedData(data: TTData) {
144
- return new Promise<boolean>((resolve, reject) => {
145
- tt.storeFeedData({
146
- scene: data.scene,
147
- contentID: data.contentID,
148
- leftValue: 'timeStampMs',
149
- operator: '>=',
150
- rightValue: ((new Date().getTime()) + data.time).toString(),
151
- status: 1,
152
- extra: data.ext,
153
- success(res) {
154
- resolve(true)
155
- },
156
- fail(res) {
157
- console.error('视频流失败:', res)
158
- resolve(false)
159
- },
160
- })
161
- });
162
- }
163
-
164
- getFeedData(contentID: string, scene: number) {
165
- return new Promise<boolean>((resolve, reject) => {
166
- tt.getFeedData({
167
- scene: scene, // 体力恢复
168
- contentID: contentID,
169
- success(res) {
170
- console.log('getFeedData success', res, res.status, res.extra);
171
- resolve(true)
172
- },
173
- fail(res) {
174
- console.log('getFeedData fail', res)
175
- resolve(false)
176
- },
177
- })
178
- });
179
- }
180
-
181
-
182
- public checkFeedSubscribeStatus() {
183
- return new Promise<boolean>((resolve, reject) => {
184
- if (tt.canIUse("checkFeedSubscribeStatus.object.allScene")) {
185
- tt.checkFeedSubscribeStatus({
186
- type: "play",
187
- allScene: true,
188
- success(res) {
189
- // 若返回字段 status = true,表示已订阅,不展示订阅引导入口
190
- // 若返回字段 status = false,表示未订阅,展示订阅引导入口
191
- console.log(res.status)
192
- resolve(res.status);
193
- },
194
- fail(res) {
195
- console.log("订阅报错了:", res.errMsg)
196
- resolve(false)
197
- },
198
- })
199
- } else {
200
- console.log("订阅失败了")
201
- resolve(false)
202
- }
203
- });
204
-
205
- }
206
-
207
- addShortcut() {
208
- return new Promise<boolean>((resolve, reject) => {
209
- tt.addShortcut({
210
- success() {
211
- resolve(true)
212
- },
213
- fail(err) {
214
- console.log("添加桌面失败", err);
215
- resolve(false)
216
- },
217
- });
218
- });
219
- }
220
-
221
-
222
- onError(res: any) {
223
- this.adsCall.error?.(res)
224
- }
225
-
226
- onClose(res: any): void {
227
- if (res.isEnded) {
228
- this.adsCall.success?.()
229
-
230
- } else {
231
- this.adsCall.fail?.('未完整观看视频')
232
- }
233
- this.adsCall.close?.(res)
234
- // console.log("视频广告关闭:", res, res.isEnded);
235
- }
236
-
237
-
238
- bindTouchEnd() {
239
- PlatfprmModule.buttonTouch.tt_button = false
240
- PlatfprmModule.buttonTouch.tt_button_subscribe = null
241
- PlatfprmModule.buttonTouch.tt_button_feedsubscribe = false
242
-
243
- tt.offTouchEnd(this.onTouchEnd)
244
- tt.onTouchEnd(this.onTouchEnd)
245
- // tt.showModal({
246
- // title: "订阅完成",
247
- // content: '',
248
- // });
249
- }
250
- onTouchEnd() {
251
- const self = this;
252
- if (PlatfprmModule.buttonTouch.tt_button) {
253
- PlatfprmModule.buttonTouch.tt_button = false
254
- tt.addShortcut({
255
- success() {
256
- console.log("添加桌面成功");
257
- },
258
- fail(err) {
259
- console.log("添加桌面失败", err);
260
- },
261
- });
262
- }
263
- else if (PlatfprmModule.buttonTouch.tt_button_subscribe) {
264
- const msg = PlatfprmModule.buttonTouch.tt_button_subscribe//'MSG1738838137157339868090924108072'
265
- PlatfprmModule.buttonTouch.tt_button_subscribe = null
266
- const tmplIds = [msg];
267
- tt.requestSubscribeMessage({
268
- tmplIds: tmplIds,
269
- complete: (res) => {
270
- if (res[msg] === "accept") {
271
-
272
- } else {
273
- }
274
- console.log('订阅', JSON.stringify(res))
275
- },
276
- });
277
- }
278
- else if (PlatfprmModule.buttonTouch.tt_button_feedsubscribe) {
279
- PlatfprmModule.buttonTouch.tt_button_feedsubscribe = false
280
- tt.requestFeedSubscribe({
281
- type: "play",
282
- allScene: true,
283
- success(res) {
284
- console.log(res.success)
285
- self.requestFeedSubscribe?.(res.success)
286
- },
287
- fail(res) {
288
- console.log(res)
289
- self.requestFeedSubscribe?.(false)
290
- },
291
- })
292
- }
293
- else {
294
- // console.log('没有点击');
295
- }
296
- }
297
-
298
-
299
- public navigateToScene(param?: { scene?: string; callBack?: () => void }) {
300
- this.sidebarCall = param?.callBack;
301
- tt.navigateToScene({
302
- scene: "sidebar",
303
- success: () => {
304
- },
305
- fail: () => {
306
- },
307
- });
308
- }
309
-
310
- toPosition(node: Node) {
311
- const pos: PositonData = { x: 0, y: 0, width: 0, height: 0 }
312
- return pos
313
- }
314
-
315
- //开放数据域
316
- public initOpenDataLayout(params: { x: number, y: number, width: number, height: number }) {
317
- let data = {
318
- type: "engine",
319
- event: "viewport",
320
- ...params
321
- }
322
- this.sendMessageToOpenData(data)
323
- }
324
-
325
- public sendMessageToOpenData(params: { type: string, event: string }) {
326
- let openDataContext = tt.getOpenDataContext();
327
- openDataContext.postMessage(params)
328
- }
329
-
330
- /** 更新微信开放数据榜单数据 */
331
- public updateCloudRank(key: string, score: number) {
332
- return new Promise<boolean>((resolve, reject) => {
333
- let data = {
334
- ttgame: {
335
- score: score,
336
- update_time: Math.floor(Date.now() / 1000)
337
- }
338
- }
339
- tt.setUserCloudStorage({
340
- KVDataList: [{
341
- key: key,
342
- value: JSON.stringify(data)
343
- }],
344
- success: () => {
345
- resolve(true)
346
- },
347
- fail: (res) => {
348
- console.error('开放数据更新失败', res)
349
- resolve(false)
350
- }
351
- })
352
- })
353
- }
354
-
355
- public showRank(keyList: string[], openId?: string) {
356
- let data = {
357
- type: "game",
358
- event: "showRank",
359
- keyList: keyList,
360
- openId: openId
361
- }
362
- this.sendMessageToOpenData(data)
363
- }
364
- }
365
-
366
-
@@ -1,9 +0,0 @@
1
- {
2
- "ver": "4.0.24",
3
- "importer": "typescript",
4
- "imported": true,
5
- "uuid": "cc11fdbb-76ca-4ab5-ba51-299226e65af6",
6
- "files": [],
7
- "subMetas": {},
8
- "userData": {}
9
- }