Commit 903847c20766edafc0e4275ed852bc9f73b8adc5
1 parent
796ec47e
Exists in
master
1
Showing
3 changed files
with
272 additions
and
22 deletions
Show diff stats
SUMMARY.md
| @@ -19,6 +19,9 @@ | @@ -19,6 +19,9 @@ | ||
| 19 | * [检测自动更新](platform.md#checkUpdate) | 19 | * [检测自动更新](platform.md#checkUpdate) |
| 20 | * [打开客服消息](platform.md#service) | 20 | * [打开客服消息](platform.md#service) |
| 21 | * [震动接口](platform.md#vibrate) | 21 | * [震动接口](platform.md#vibrate) |
| 22 | + * [小游戏推荐弹窗组件GamePortal](platform.md#gamePortal) | ||
| 23 | + * [小游戏插屏广告组件InterstitialAd](platform.md#interstitialAd) | ||
| 24 | + * [小游戏推荐icon组件GameIcon](platform.md#gameicon) | ||
| 22 | * [数据模块](data.md) | 25 | * [数据模块](data.md) |
| 23 | * [事件模块](event.md) | 26 | * [事件模块](event.md) |
| 24 | * [FAQ❎](faq.md) | 27 | * [FAQ❎](faq.md) |
| 25 | \ No newline at end of file | 28 | \ No newline at end of file |
book.json
| @@ -30,8 +30,6 @@ | @@ -30,8 +30,6 @@ | ||
| 30 | "include-csv@^0.1.0", | 30 | "include-csv@^0.1.0", |
| 31 | "puml@^1.0.1", | 31 | "puml@^1.0.1", |
| 32 | "musicxml@^1.0.2", | 32 | "musicxml@^1.0.2", |
| 33 | - "klipse@^1.2.0", | ||
| 34 | - "versions-select@^0.1.1", | ||
| 35 | "graph@^0.1.0", | 33 | "graph@^0.1.0", |
| 36 | "chart@^0.2.0", | 34 | "chart@^0.2.0", |
| 37 | "popup" | 35 | "popup" |
platform.md
| @@ -9,17 +9,16 @@ | @@ -9,17 +9,16 @@ | ||
| 9 | #### **此模块是参照微信小游戏提供的api进行封装的公用方法,提供了以下游戏中常用到的功能:** | 9 | #### **此模块是参照微信小游戏提供的api进行封装的公用方法,提供了以下游戏中常用到的功能:** |
| 10 | 10 | ||
| 11 | 1. **支付打点:logPay** (此模块保留logPay调用只是为了兼容已经接入的游戏,该api已经归类到【统计模块】下面的[支付打点](stat_pay.md)栏)。 | 11 | 1. **支付打点:logPay** (此模块保留logPay调用只是为了兼容已经接入的游戏,该api已经归类到【统计模块】下面的[支付打点](stat_pay.md)栏)。 |
| 12 | -2. **打开客服消息:openCustomerServiceConversation** 整理[wx.openCustomerServiceConversation](https://developers.weixin.qq.com/minigame/dev/api/open-api/customer-message/wx.openCustomerServiceConversation.html) | 12 | +2. **打开客服消息:openCustomerServiceConversation** 整理来自[wx.openCustomerServiceConversation](https://developers.weixin.qq.com/minigame/dev/api/open-api/customer-message/wx.openCustomerServiceConversation.html) |
| 13 | 13 | ||
| 14 | 3. **检测版本更新:checkUpdate** 整理来自:[wx.getUpdateManager](https://developers.weixin.qq.com/minigame/dev/api/base/update/UpdateManager.html) | 14 | 3. **检测版本更新:checkUpdate** 整理来自:[wx.getUpdateManager](https://developers.weixin.qq.com/minigame/dev/api/base/update/UpdateManager.html) |
| 15 | 4. **显示模态弹出框:showModal** 整理来自:[wx.showModal](https://developers.weixin.qq.com/minigame/dev/api/ui/interaction/wx.showModal.html) | 15 | 4. **显示模态弹出框:showModal** 整理来自:[wx.showModal](https://developers.weixin.qq.com/minigame/dev/api/ui/interaction/wx.showModal.html) |
| 16 | 5. **复制文本:copy** 整理来自:[wx.setClipboardData](https://developers.weixin.qq.com/minigame/dev/api/device/clipboard/wx.setClipboardData.html) | 16 | 5. **复制文本:copy** 整理来自:[wx.setClipboardData](https://developers.weixin.qq.com/minigame/dev/api/device/clipboard/wx.setClipboardData.html) |
| 17 | 6. **长震动:vibrateLong** 整理来自:[wx.vibrateLong](https://developers.weixin.qq.com/minigame/dev/api/device/vibrate/wx.vibrateLong.html) | 17 | 6. **长震动:vibrateLong** 整理来自:[wx.vibrateLong](https://developers.weixin.qq.com/minigame/dev/api/device/vibrate/wx.vibrateLong.html) |
| 18 | 7. **短震动:vibrateShort** 整理来自:[wx.vibrateShort](https://developers.weixin.qq.com/minigame/dev/api/device/vibrate/wx.vibrateShort.html) | 18 | 7. **短震动:vibrateShort** 整理来自:[wx.vibrateShort](https://developers.weixin.qq.com/minigame/dev/api/device/vibrate/wx.vibrateShort.html) |
| 19 | -8. **更新转发属性:updateShareMenu** 整理来自:[wx.updateShareMenu](https://developers.weixin.qq.com/minigame/dev/api/share/wx.updateShareMenu.html) | ||
| 20 | 9. **微信小游戏推荐弹窗组件GamePortal:isGamePortalPlaying 与 gamePortalShow** 整理来自:[wx.createGamePortal](https://developers.weixin.qq.com/minigame/dev/api/game-portal/GameBanner.html) | 19 | 9. **微信小游戏推荐弹窗组件GamePortal:isGamePortalPlaying 与 gamePortalShow** 整理来自:[wx.createGamePortal](https://developers.weixin.qq.com/minigame/dev/api/game-portal/GameBanner.html) |
| 21 | -10. **微信小游戏推荐icon组件GameIcon:gameIconShow 与 gameIconDestroy** 整理来自:[wx.createGameIcon](https://developers.weixin.qq.com/minigame/dev/api/game-portal/wx.createGameIcon.html) | ||
| 22 | -11. **微信小游戏插屏广告组件InterstitialAd:isInterstitialPlaying 与 interstitialShow** 整理来自:[wx.createInterstitialAd](https://developers.weixin.qq.com/minigame/dev/api/ad/InterstitialAd.html) | 20 | +10. **微信小游戏插屏广告组件InterstitialAd:isInterstitialPlaying 与 interstitialShow** 整理来自:[wx.createInterstitialAd](https://developers.weixin.qq.com/minigame/dev/api/ad/InterstitialAd.html) |
| 21 | +11. **微信小游戏推荐icon组件GameIcon:gameIconShow 与 gameIconDestroy** 整理来自:[wx.createGameIcon](https://developers.weixin.qq.com/minigame/dev/api/game-portal/wx.createGameIcon.html) | ||
| 23 | 22 | ||
| 24 | 23 | ||
| 25 | 24 | ||
| @@ -32,6 +31,12 @@ | @@ -32,6 +31,12 @@ | ||
| 32 | | PCSDK.platform.checkUpdate | 检测版本是否有更新,如果版本更新会弹出确认框 | | 31 | | PCSDK.platform.checkUpdate | 检测版本是否有更新,如果版本更新会弹出确认框 | |
| 33 | | PCSDK.platform.vibrateShort | 使手机发生较短时间的振动(15 ms) | | 32 | | PCSDK.platform.vibrateShort | 使手机发生较短时间的振动(15 ms) | |
| 34 | | PCSDK.platform.vibrateLong | 使手机发生较长时间的振动(400 ms) | | 33 | | PCSDK.platform.vibrateLong | 使手机发生较长时间的振动(400 ms) | |
| 34 | +| PCSDK.platform.gamePortalShow | 传入adUnitId创建并展示小游戏推荐弹窗组件 | | ||
| 35 | +| PCSDK.platform.isGamePortalPlaying | 是否正在加载小游戏推荐弹窗组件 | | ||
| 36 | +| PCSDK.platform.interstitialShow | 传入adUnitId创建并展示小游戏插屏广告组件 | | ||
| 37 | +| PCSDK.platform.isInterstitialPlaying | 是否正在加载小游戏插屏广告组件 | | ||
| 38 | +| PCSDK.platform.gameIconShow | 创建并显示小游戏推荐icon组件 | | ||
| 39 | +| PCSDK.platform.gameIconDestroy | 销毁正在展示的小游戏推荐icon组件 | | ||
| 35 | 40 | ||
| 36 | 41 | ||
| 37 | 42 | ||
| @@ -159,19 +164,18 @@ | @@ -159,19 +164,18 @@ | ||
| 159 | console.log("openCustomerServiceConversation fail: ", err); | 164 | console.log("openCustomerServiceConversation fail: ", err); |
| 160 | } | 165 | } |
| 161 | }); | 166 | }); |
| 162 | - | ||
| 163 | - // 在游戏中全局注册的onShow事件监听中检测是 | 167 | + // 在游戏中全局注册的onShow事件监听中检测是 |
| 164 | // 游戏入口:Main.cs | 168 | // 游戏入口:Main.cs |
| 165 | class Main { | 169 | class Main { |
| 166 | constructor() { | 170 | constructor() { |
| 167 | this.init(); | 171 | this.init(); |
| 168 | } | 172 | } |
| 169 | - | 173 | + |
| 170 | private init() { | 174 | private init() { |
| 171 | PCSDK.event.add('app.show', this.onShow, this); // 等同于wx.onShow(this.onShow.bind(this)); | 175 | PCSDK.event.add('app.show', this.onShow, this); // 等同于wx.onShow(this.onShow.bind(this)); |
| 172 | PCSDK.event.add('app.hide', this.onHide, this); // 等同于wx.onHide(this.onHide.bind(this)); | 176 | PCSDK.event.add('app.hide', this.onHide, this); // 等同于wx.onHide(this.onHide.bind(this)); |
| 173 | } | 177 | } |
| 174 | - | 178 | + |
| 175 | private onShow(opts) { | 179 | private onShow(opts) { |
| 176 | // 判断是否是来源于客服会话,上面的openCustomerServiceConversation的success设置的数据状态做判断 | 180 | // 判断是否是来源于客服会话,上面的openCustomerServiceConversation的success设置的数据状态做判断 |
| 177 | let serviceRewardData = AppDataManager.I.get('service.reward.data'); | 181 | let serviceRewardData = AppDataManager.I.get('service.reward.data'); |
| @@ -180,7 +184,7 @@ | @@ -180,7 +184,7 @@ | ||
| 180 | // 奖励发放,处理发放后的逻辑,比如每天只能领取一次的记录,防止重复刷奖励 | 184 | // 奖励发放,处理发放后的逻辑,比如每天只能领取一次的记录,防止重复刷奖励 |
| 181 | } | 185 | } |
| 182 | } | 186 | } |
| 183 | - | 187 | + |
| 184 | private onHide(){ | 188 | private onHide(){ |
| 185 | // 监听平台的onHide事件 | 189 | // 监听平台的onHide事件 |
| 186 | } | 190 | } |
| @@ -217,7 +221,7 @@ | @@ -217,7 +221,7 @@ | ||
| 217 | } | 221 | } |
| 218 | 222 | ||
| 219 | // 在游戏中全局注册的onShow事件监听中检测是 | 223 | // 在游戏中全局注册的onShow事件监听中检测是 |
| 220 | - // 游戏入口:Main.cs | 224 | + // 游戏入口:Main.cs |
| 221 | class Main { | 225 | class Main { |
| 222 | constructor() { | 226 | constructor() { |
| 223 | this.init(); | 227 | this.init(); |
| @@ -249,7 +253,6 @@ | @@ -249,7 +253,6 @@ | ||
| 249 | ```javascript | 253 | ```javascript |
| 250 | PCSDK.platform.checkUpdate( params?: _ShowModalObject ): void | 254 | PCSDK.platform.checkUpdate( params?: _ShowModalObject ): void |
| 251 | ``` | 255 | ``` |
| 252 | - | ||
| 253 | 定义:检测版本是否有更新,如果版本有更新会弹出确认框,参数可不传递,不传递有版本更新会弹出下图的默认确认框;开发者可自定义弹出框的显示样式,参数与[wx.showModal](https://developers.weixin.qq.com/minigame/dev/api/ui/interaction/wx.showModal.html)一模一样。 | 256 | 定义:检测版本是否有更新,如果版本有更新会弹出确认框,参数可不传递,不传递有版本更新会弹出下图的默认确认框;开发者可自定义弹出框的显示样式,参数与[wx.showModal](https://developers.weixin.qq.com/minigame/dev/api/ui/interaction/wx.showModal.html)一模一样。 |
| 254 | 建议此api在游戏的入口调用。 | 257 | 建议此api在游戏的入口调用。 |
| 255 |  | 258 |  |
| @@ -310,45 +313,291 @@ | @@ -310,45 +313,291 @@ | ||
| 310 |  | 313 |  |
| 311 | III、开发工具会自动重新启动游戏,弹出更新框,看到弹出框接入成功。 | 314 | III、开发工具会自动重新启动游戏,弹出更新框,看到弹出框接入成功。 |
| 312 |  | 315 |  |
| 316 | +<div id="vibrate"></div> | ||
| 317 | +4. **vibrateShort** | ||
| 318 | +```javascript | ||
| 319 | + PCSDK.platform.vibrateShort(): Promise<any> | ||
| 320 | +``` | ||
| 321 | +定义:使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效 | ||
| 322 | +参数: | ||
| 323 | + | ||
| 324 | + ```javascript | ||
| 325 | + 无 | ||
| 326 | +``` | ||
| 327 | +示例: | ||
| 328 | + | ||
| 329 | + ```javascript | ||
| 330 | + PCSDK.platform.vibrateShort(); | ||
| 331 | + | ||
| 332 | + ``` | ||
| 333 | +5. **vibrateLong** | ||
| 313 | 334 | ||
| 314 | -<div id="vibrate"></div> | ||
| 315 | -4.0 **vibrateShort** | 335 | + ```javascript |
| 336 | + PCSDK.platform.vibrateLong(): Promise<any> | ||
| 337 | + ``` | ||
| 338 | + 定义:使手机发生较长时间的振动(400 ms) | ||
| 339 | + 参数: | ||
| 340 | + ```javascript | ||
| 341 | + 无 | ||
| 342 | + ``` | ||
| 343 | + 示例: | ||
| 344 | + ```javascript | ||
| 345 | + PCSDK.platform.vibrateLong(); | ||
| 346 | + ``` | ||
| 347 | +<div id="gamePortal"></div> | ||
| 348 | +6. **gamePortalShow** | ||
| 349 | + ```javascript | ||
| 350 | + PCSDK.platform.gamePortalShow(adUnitId: string): Promise<any> | ||
| 351 | + ``` | ||
| 352 | + 定义:传入adUnitId创建并展示小游戏推荐弹窗组件,Promise resolve创建展示成功回调,reject创建失败回调。 | ||
| 353 | + | ||
| 354 | + 参数: | ||
| 355 | + ```javascript | ||
| 356 | + adUnitId string 必传 小游戏推荐弹窗组件推荐单元id | ||
| 357 | + ``` | ||
| 358 | + 返回值: | ||
| 359 | + ```javascript | ||
| 360 | + Promise<any> | ||
| 361 | + Promise resolve创建展示成功回调,reject创建失败回到 | ||
| 362 | + ``` | ||
| 363 | + 示例: | ||
| 364 | + ```javascript | ||
| 365 | + // 例子1:显示弹窗组件 | ||
| 366 | + let adUnitId: string = 'PBgAAgPWNXGtCwcA'; | ||
| 367 | + PCSDK.platform.gamePortalShow(adUnitId); | ||
| 368 | + | ||
| 369 | + // 例子2:显示推荐弹窗组件,如果显示不成功,则显示小游戏插屏广告,插屏广告api使用请继续往下看。 | ||
| 370 | + let adUnitId: string = 'PBgAAgPWNXGtCwcA'; | ||
| 371 | + PCSDK.platform.gamePortalShow(adUnitId).catch(err => { | ||
| 372 | + // 推荐弹窗组件显示不成功显示插屏广告 | ||
| 373 | + adUnitId = 'adunit-4da0ec77513f8eea'; | ||
| 374 | + PCSDK.platform.interstitialShow(adUnitId); | ||
| 375 | + }); | ||
| 376 | + | ||
| 377 | + ``` | ||
| 378 | +7. **isGamePortalPlaying** | ||
| 316 | 379 | ||
| 317 | ```javascript | 380 | ```javascript |
| 318 | - PCSDK.platform.vibrateShort(): Promise<any> | 381 | + PCSDK.platform.isGamePortalPlaying(): boolean |
| 319 | ``` | 382 | ``` |
| 320 | 383 | ||
| 321 | - 定义:使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效 | 384 | + 定义:是否正在加载小游戏推荐弹窗组件;在PCSDK.platform.gamePortalShow api内部,如果正在创建弹窗组件会在Promise reject返回错误提示信息。 |
| 322 | 385 | ||
| 323 | 参数: | 386 | 参数: |
| 324 | 387 | ||
| 325 | ```javascript | 388 | ```javascript |
| 326 | 无 | 389 | 无 |
| 327 | ``` | 390 | ``` |
| 391 | + 返回值: | ||
| 392 | + | ||
| 393 | + ```javascript | ||
| 394 | + boolean | ||
| 395 | + ``` | ||
| 328 | 396 | ||
| 329 | 示例: | 397 | 示例: |
| 330 | 398 | ||
| 331 | ```javascript | 399 | ```javascript |
| 332 | - PCSDK.platform.vibrateShort(); | 400 | + let isPlaying = PCSDK.platform.isGamePortalPlaying(); |
| 333 | 401 | ||
| 334 | ``` | 402 | ``` |
| 335 | -4.1 **vibrateLong** | 403 | +<div id="interstitialAd"></div> |
| 404 | +8. **interstitialShow** | ||
| 336 | 405 | ||
| 337 | ```javascript | 406 | ```javascript |
| 338 | - PCSDK.platform.vibrateShort(): Promise<any> | 407 | + PCSDK.platform.interstitialShow(adUnitId: string): Promise<any> |
| 339 | ``` | 408 | ``` |
| 340 | 409 | ||
| 341 | - 定义:使手机发生较长时间的振动(400 ms) | 410 | + 定义:传入adUnitId创建并展示小游戏插屏广告组件,Promise resolve创建展示成功回调,reject创建失败回调 |
| 411 | + | ||
| 412 | + 参数: | ||
| 413 | + | ||
| 414 | + ```javascript | ||
| 415 | + adUnitId string 必传 小游戏插屏广告组件广告单元id | ||
| 416 | + ``` | ||
| 417 | + 返回值: | ||
| 418 | + | ||
| 419 | + ```javascript | ||
| 420 | + Promise<any> | ||
| 421 | + Promise resolve创建展示成功回调,reject创建失败回到 | ||
| 422 | + ``` | ||
| 423 | + | ||
| 424 | + 示例: | ||
| 425 | + | ||
| 426 | + ```javascript | ||
| 427 | + // 例子1:显示插屏广告组件 | ||
| 428 | + let adUnitId: string = 'adunit-4da0ec77513f8eea'; | ||
| 429 | + PCSDK.platform.interstitialShow(adUnitId); | ||
| 430 | + | ||
| 431 | + // 例子2:显示插屏广告组件,如果显示不成功,则显示小游戏推荐弹窗组件。 | ||
| 432 | + let adUnitId: string = 'adunit-4da0ec77513f8eea'; | ||
| 433 | + PCSDK.platform.interstitialShow(adUnitId).catch( err => { | ||
| 434 | + // 加载不成功显示小游戏推荐弹窗组件 | ||
| 435 | + adUnitId = 'PBgAAgPWNXGtCwcA'; | ||
| 436 | + PCSDK.platform.gamePortalShow(adUnitId); | ||
| 437 | + }); | ||
| 438 | + ``` | ||
| 439 | +9. **isInterstitialPlaying** | ||
| 440 | + | ||
| 441 | + ```javascript | ||
| 442 | + PCSDK.platform.isInterstitialPlaying(): boolean | ||
| 443 | + ``` | ||
| 444 | + | ||
| 445 | + 定义:是否正在加载小游戏插屏广告组件;在PCSDK.platform.interstitialShow如果正在创建插屏广告会在Promise reject返回错误提示信息。 | ||
| 342 | 446 | ||
| 343 | 参数: | 447 | 参数: |
| 344 | 448 | ||
| 345 | ```javascript | 449 | ```javascript |
| 346 | 无 | 450 | 无 |
| 347 | ``` | 451 | ``` |
| 452 | + 返回值: | ||
| 453 | + | ||
| 454 | + ```javascript | ||
| 455 | + boolean | ||
| 456 | + ``` | ||
| 348 | 457 | ||
| 349 | 示例: | 458 | 示例: |
| 350 | 459 | ||
| 351 | ```javascript | 460 | ```javascript |
| 352 | - PCSDK.platform.vibrateLong(); | 461 | + let isPlaying = PCSDK.platform.isInterstitialPlaying(); |
| 462 | + | ||
| 463 | + ``` | ||
| 464 | +<div id="gameicon"></div> | ||
| 465 | +10. **gameIconShow** | ||
| 466 | + ```javascript | ||
| 467 | + PCSDK.platform.gameIconShow(adUnitId: string, opts: { count: number, style: Array<_GameIconStyleItem> }): Promise<any> | ||
| 468 | + ``` | ||
| 469 | + | ||
| 470 | + 定义:创建并显示小游戏推荐icon组件。 | ||
| 471 | + | ||
| 472 | + 参数: | ||
| 473 | + | ||
| 474 | + ```javascript | ||
| 475 | + adUnitId string 必传 小游戏推荐icon组件广告单元id | ||
| 476 | + opts object 必传 扩展参数,目前支持count和style两个属性值 | ||
| 477 | + { | ||
| 478 | + count number 必传 游戏icon的数量,请注意,正式版下面渲染出来的icon数量会小于等于count,请注册做好样式兼容 | ||
| 479 | + style Array<_GameIconStyleItem> 必传 数组的每一项可以针对对应的icon设置位置和样式等信息,style的每一项称为_GameIconStyleItem | ||
| 480 | + } | ||
| 481 | + | ||
| 482 | + Object _GameIconStyleItem:单个游戏icon的位置和样式信息 | ||
| 483 | + { | ||
| 484 | + appNameHidden boolean 必传 游戏名称是否隐藏 | ||
| 485 | + color string 必传 游戏名称的颜色色值 | ||
| 486 | + size number 必传 游戏icon的宽高值 | ||
| 487 | + borderWidth number 必传 游戏icon的border尺寸 | ||
| 488 | + borderColor string 必传 游戏icon的border颜色色值 | ||
| 489 | + left number 必传 游戏icon的X轴坐标 | ||
| 490 | + top number 必传 游戏icon的Y轴坐标 | ||
| 491 | + } | ||
| 492 | + ``` | ||
| 493 | + 返回值: | ||
| 494 | + | ||
| 495 | + ```javascript | ||
| 496 | + Promise<any> | ||
| 497 | + Promise resolve创建展示成功回调,reject创建失败回到 | ||
| 498 | + ``` | ||
| 499 | + | ||
| 500 | + 示例: | ||
| 501 | + | ||
| 502 | + ```javascript | ||
| 503 | + // 显示1个推荐icon组件 | ||
| 504 | + private showGameIcon(){ | ||
| 505 | + let adUnitId: string = 'PBgAAgPWNXGkQ4p0'; | ||
| 506 | + let {windowWidth} = PCSDK.platform.getSystemData(); | ||
| 507 | + PCSDK.platform.gameIconShow(adUnitId, { | ||
| 508 | + count: 1, | ||
| 509 | + style: [ | ||
| 510 | + { | ||
| 511 | + appNameHidden: false, | ||
| 512 | + color: "#FF0000", | ||
| 513 | + size: 50, | ||
| 514 | + borderWidth: 0, | ||
| 515 | + borderColor: "#FF0000", | ||
| 516 | + left: (windowWidth / 750) * 550, | ||
| 517 | + top: (windowWidth / 750) * 150 | ||
| 518 | + } | ||
| 519 | + ] | ||
| 520 | + }) | ||
| 521 | + .then(() => { | ||
| 522 | + // console.warn('显示GameIcon成功'); | ||
| 523 | + }) | ||
| 524 | + .catch((err) => { | ||
| 525 | + // console.warn('显示GameIcon失败'); | ||
| 526 | + }); | ||
| 527 | + } | ||
| 528 | + | ||
| 529 | + ``` | ||
| 530 | +11. **gameIconDestroy** | ||
| 531 | + | ||
| 532 | + ```javascript | ||
| 533 | + PCSDK.platform.gameIconDestroy(): void | ||
| 534 | + ``` | ||
| 535 | + | ||
| 536 | + 定义:销毁正在展示的小游戏推荐icon组件。展示推荐icon组件广告后,请记得在页面关闭时候调用此api销毁GameIcon。 | ||
| 537 | + | ||
| 538 | + 参数: | ||
| 539 | + | ||
| 540 | + ```javascript | ||
| 541 | + 无 | ||
| 542 | + ``` | ||
| 543 | + 返回值: | ||
| 544 | + | ||
| 545 | + ```javascript | ||
| 546 | + void | ||
| 547 | + ``` | ||
| 548 | + | ||
| 549 | + 示例: | ||
| 550 | + | ||
| 551 | + ```javascript | ||
| 552 | + | ||
| 553 | + private open(){ | ||
| 554 | + super.open(); | ||
| 555 | + this.showGameIcon(); | ||
| 556 | + } | ||
| 557 | + | ||
| 558 | + private close(){ | ||
| 559 | + super.close(); | ||
| 560 | + this.destoryGameIcon(); | ||
| 561 | + } | ||
| 562 | + | ||
| 563 | + // 显示2个推荐icon组件 | ||
| 564 | + private showGameIcon(){ | ||
| 565 | + let adUnitId: string = 'PBgAAgPWNXGkQ4p0'; | ||
| 566 | + let {windowWidth} = PCSDK.platform.getSystemData(); | ||
| 567 | + PCSDK.platform.gameIconShow(adUnitId, { | ||
| 568 | + count: 2, | ||
| 569 | + style: [ | ||
| 570 | + { | ||
| 571 | + appNameHidden: false, | ||
| 572 | + color: "#FF0000", | ||
| 573 | + size: 50, | ||
| 574 | + borderWidth: 0, | ||
| 575 | + borderColor: "#FF0000", | ||
| 576 | + left: (windowWidth / 750) * 450, | ||
| 577 | + top: (windowWidth / 750) * 150 | ||
| 578 | + }, | ||
| 579 | + { | ||
| 580 | + appNameHidden: false, | ||
| 581 | + color: "#FF0000", | ||
| 582 | + size: 50, | ||
| 583 | + borderWidth: 0, | ||
| 584 | + borderColor: "#FF0000", | ||
| 585 | + left: (windowWidth / 750) * 550, | ||
| 586 | + top: (windowWidth / 750) * 150 | ||
| 587 | + } | ||
| 588 | + ] | ||
| 589 | + }) | ||
| 590 | + .then(() => { | ||
| 591 | + // console.warn('显示GameIcon成功'); | ||
| 592 | + }) | ||
| 593 | + .catch((err) => { | ||
| 594 | + // console.warn('显示GameIcon失败'); | ||
| 595 | + }); | ||
| 596 | + } | ||
| 597 | + | ||
| 598 | + // 销毁展示创建的GameIcon组件 | ||
| 599 | + private destoryGameIcon(){ | ||
| 600 | + PCSDK.platform.gameIconDestroy(); | ||
| 601 | + } | ||
| 353 | 602 | ||
| 354 | ``` | 603 | ``` |
| 355 | \ No newline at end of file | 604 | \ No newline at end of file |