diff --git a/SUMMARY.md b/SUMMARY.md
index 8716b3b..7f461b9 100644
--- a/SUMMARY.md
+++ b/SUMMARY.md
@@ -19,6 +19,9 @@
* [检测自动更新](platform.md#checkUpdate)
* [打开客服消息](platform.md#service)
* [震动接口](platform.md#vibrate)
+ * [小游戏推荐弹窗组件GamePortal](platform.md#gamePortal)
+ * [小游戏插屏广告组件InterstitialAd](platform.md#interstitialAd)
+ * [小游戏推荐icon组件GameIcon](platform.md#gameicon)
* [数据模块](data.md)
* [事件模块](event.md)
* [FAQ❎](faq.md)
\ No newline at end of file
diff --git a/book.json b/book.json
index 6201203..5054dde 100644
--- a/book.json
+++ b/book.json
@@ -30,8 +30,6 @@
"include-csv@^0.1.0",
"puml@^1.0.1",
"musicxml@^1.0.2",
- "klipse@^1.2.0",
- "versions-select@^0.1.1",
"graph@^0.1.0",
"chart@^0.2.0",
"popup"
diff --git a/platform.md b/platform.md
index c085693..c7bc1c0 100644
--- a/platform.md
+++ b/platform.md
@@ -9,17 +9,16 @@
#### **此模块是参照微信小游戏提供的api进行封装的公用方法,提供了以下游戏中常用到的功能:**
1. **支付打点:logPay** (此模块保留logPay调用只是为了兼容已经接入的游戏,该api已经归类到【统计模块】下面的[支付打点](stat_pay.md)栏)。
-2. **打开客服消息:openCustomerServiceConversation** 整理[wx.openCustomerServiceConversation](https://developers.weixin.qq.com/minigame/dev/api/open-api/customer-message/wx.openCustomerServiceConversation.html)
+2. **打开客服消息:openCustomerServiceConversation** 整理来自[wx.openCustomerServiceConversation](https://developers.weixin.qq.com/minigame/dev/api/open-api/customer-message/wx.openCustomerServiceConversation.html)
3. **检测版本更新:checkUpdate** 整理来自:[wx.getUpdateManager](https://developers.weixin.qq.com/minigame/dev/api/base/update/UpdateManager.html)
4. **显示模态弹出框:showModal** 整理来自:[wx.showModal](https://developers.weixin.qq.com/minigame/dev/api/ui/interaction/wx.showModal.html)
5. **复制文本:copy** 整理来自:[wx.setClipboardData](https://developers.weixin.qq.com/minigame/dev/api/device/clipboard/wx.setClipboardData.html)
6. **长震动:vibrateLong** 整理来自:[wx.vibrateLong](https://developers.weixin.qq.com/minigame/dev/api/device/vibrate/wx.vibrateLong.html)
7. **短震动:vibrateShort** 整理来自:[wx.vibrateShort](https://developers.weixin.qq.com/minigame/dev/api/device/vibrate/wx.vibrateShort.html)
-8. **更新转发属性:updateShareMenu** 整理来自:[wx.updateShareMenu](https://developers.weixin.qq.com/minigame/dev/api/share/wx.updateShareMenu.html)
9. **微信小游戏推荐弹窗组件GamePortal:isGamePortalPlaying 与 gamePortalShow** 整理来自:[wx.createGamePortal](https://developers.weixin.qq.com/minigame/dev/api/game-portal/GameBanner.html)
-10. **微信小游戏推荐icon组件GameIcon:gameIconShow 与 gameIconDestroy** 整理来自:[wx.createGameIcon](https://developers.weixin.qq.com/minigame/dev/api/game-portal/wx.createGameIcon.html)
-11. **微信小游戏插屏广告组件InterstitialAd:isInterstitialPlaying 与 interstitialShow** 整理来自:[wx.createInterstitialAd](https://developers.weixin.qq.com/minigame/dev/api/ad/InterstitialAd.html)
+10. **微信小游戏插屏广告组件InterstitialAd:isInterstitialPlaying 与 interstitialShow** 整理来自:[wx.createInterstitialAd](https://developers.weixin.qq.com/minigame/dev/api/ad/InterstitialAd.html)
+11. **微信小游戏推荐icon组件GameIcon:gameIconShow 与 gameIconDestroy** 整理来自:[wx.createGameIcon](https://developers.weixin.qq.com/minigame/dev/api/game-portal/wx.createGameIcon.html)
@@ -32,6 +31,12 @@
| PCSDK.platform.checkUpdate | 检测版本是否有更新,如果版本更新会弹出确认框 |
| PCSDK.platform.vibrateShort | 使手机发生较短时间的振动(15 ms) |
| PCSDK.platform.vibrateLong | 使手机发生较长时间的振动(400 ms) |
+| PCSDK.platform.gamePortalShow | 传入adUnitId创建并展示小游戏推荐弹窗组件 |
+| PCSDK.platform.isGamePortalPlaying | 是否正在加载小游戏推荐弹窗组件 |
+| PCSDK.platform.interstitialShow | 传入adUnitId创建并展示小游戏插屏广告组件 |
+| PCSDK.platform.isInterstitialPlaying | 是否正在加载小游戏插屏广告组件 |
+| PCSDK.platform.gameIconShow | 创建并显示小游戏推荐icon组件 |
+| PCSDK.platform.gameIconDestroy | 销毁正在展示的小游戏推荐icon组件 |
@@ -159,19 +164,18 @@
console.log("openCustomerServiceConversation fail: ", err);
}
});
-
- // 在游戏中全局注册的onShow事件监听中检测是
+ // 在游戏中全局注册的onShow事件监听中检测是
// 游戏入口:Main.cs
class Main {
constructor() {
this.init();
}
-
+
private init() {
PCSDK.event.add('app.show', this.onShow, this); // 等同于wx.onShow(this.onShow.bind(this));
PCSDK.event.add('app.hide', this.onHide, this); // 等同于wx.onHide(this.onHide.bind(this));
}
-
+
private onShow(opts) {
// 判断是否是来源于客服会话,上面的openCustomerServiceConversation的success设置的数据状态做判断
let serviceRewardData = AppDataManager.I.get('service.reward.data');
@@ -180,7 +184,7 @@
// 奖励发放,处理发放后的逻辑,比如每天只能领取一次的记录,防止重复刷奖励
}
}
-
+
private onHide(){
// 监听平台的onHide事件
}
@@ -217,7 +221,7 @@
}
// 在游戏中全局注册的onShow事件监听中检测是
- // 游戏入口:Main.cs
+ // 游戏入口:Main.cs
class Main {
constructor() {
this.init();
@@ -249,7 +253,6 @@
```javascript
PCSDK.platform.checkUpdate( params?: _ShowModalObject ): void
```
-
定义:检测版本是否有更新,如果版本有更新会弹出确认框,参数可不传递,不传递有版本更新会弹出下图的默认确认框;开发者可自定义弹出框的显示样式,参数与[wx.showModal](https://developers.weixin.qq.com/minigame/dev/api/ui/interaction/wx.showModal.html)一模一样。
建议此api在游戏的入口调用。

@@ -310,45 +313,291 @@

III、开发工具会自动重新启动游戏,弹出更新框,看到弹出框接入成功。

+
+4. **vibrateShort**
+```javascript
+ PCSDK.platform.vibrateShort(): Promise
+```
+定义:使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
+参数:
+
+ ```javascript
+ 无
+```
+示例:
+
+ ```javascript
+ PCSDK.platform.vibrateShort();
+
+ ```
+5. **vibrateLong**
-
-4.0 **vibrateShort**
+ ```javascript
+ PCSDK.platform.vibrateLong(): Promise
+ ```
+ 定义:使手机发生较长时间的振动(400 ms)
+ 参数:
+ ```javascript
+ 无
+ ```
+ 示例:
+ ```javascript
+ PCSDK.platform.vibrateLong();
+ ```
+
+6. **gamePortalShow**
+ ```javascript
+ PCSDK.platform.gamePortalShow(adUnitId: string): Promise
+ ```
+ 定义:传入adUnitId创建并展示小游戏推荐弹窗组件,Promise resolve创建展示成功回调,reject创建失败回调。
+
+ 参数:
+ ```javascript
+ adUnitId string 必传 小游戏推荐弹窗组件推荐单元id
+ ```
+ 返回值:
+ ```javascript
+ Promise
+ Promise resolve创建展示成功回调,reject创建失败回到
+ ```
+ 示例:
+ ```javascript
+ // 例子1:显示弹窗组件
+ let adUnitId: string = 'PBgAAgPWNXGtCwcA';
+ PCSDK.platform.gamePortalShow(adUnitId);
+
+ // 例子2:显示推荐弹窗组件,如果显示不成功,则显示小游戏插屏广告,插屏广告api使用请继续往下看。
+ let adUnitId: string = 'PBgAAgPWNXGtCwcA';
+ PCSDK.platform.gamePortalShow(adUnitId).catch(err => {
+ // 推荐弹窗组件显示不成功显示插屏广告
+ adUnitId = 'adunit-4da0ec77513f8eea';
+ PCSDK.platform.interstitialShow(adUnitId);
+ });
+
+ ```
+7. **isGamePortalPlaying**
```javascript
- PCSDK.platform.vibrateShort(): Promise
+ PCSDK.platform.isGamePortalPlaying(): boolean
```
- 定义:使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
+ 定义:是否正在加载小游戏推荐弹窗组件;在PCSDK.platform.gamePortalShow api内部,如果正在创建弹窗组件会在Promise reject返回错误提示信息。
参数:
```javascript
无
```
+ 返回值:
+
+ ```javascript
+ boolean
+ ```
示例:
```javascript
- PCSDK.platform.vibrateShort();
+ let isPlaying = PCSDK.platform.isGamePortalPlaying();
```
-4.1 **vibrateLong**
+
+8. **interstitialShow**
```javascript
- PCSDK.platform.vibrateShort(): Promise
+ PCSDK.platform.interstitialShow(adUnitId: string): Promise
```
- 定义:使手机发生较长时间的振动(400 ms)
+ 定义:传入adUnitId创建并展示小游戏插屏广告组件,Promise resolve创建展示成功回调,reject创建失败回调
+
+ 参数:
+
+ ```javascript
+ adUnitId string 必传 小游戏插屏广告组件广告单元id
+ ```
+ 返回值:
+
+ ```javascript
+ Promise
+ Promise resolve创建展示成功回调,reject创建失败回到
+ ```
+
+ 示例:
+
+ ```javascript
+ // 例子1:显示插屏广告组件
+ let adUnitId: string = 'adunit-4da0ec77513f8eea';
+ PCSDK.platform.interstitialShow(adUnitId);
+
+ // 例子2:显示插屏广告组件,如果显示不成功,则显示小游戏推荐弹窗组件。
+ let adUnitId: string = 'adunit-4da0ec77513f8eea';
+ PCSDK.platform.interstitialShow(adUnitId).catch( err => {
+ // 加载不成功显示小游戏推荐弹窗组件
+ adUnitId = 'PBgAAgPWNXGtCwcA';
+ PCSDK.platform.gamePortalShow(adUnitId);
+ });
+ ```
+9. **isInterstitialPlaying**
+
+ ```javascript
+ PCSDK.platform.isInterstitialPlaying(): boolean
+ ```
+
+ 定义:是否正在加载小游戏插屏广告组件;在PCSDK.platform.interstitialShow如果正在创建插屏广告会在Promise reject返回错误提示信息。
参数:
```javascript
无
```
+ 返回值:
+
+ ```javascript
+ boolean
+ ```
示例:
```javascript
- PCSDK.platform.vibrateLong();
+ let isPlaying = PCSDK.platform.isInterstitialPlaying();
+
+ ```
+
+10. **gameIconShow**
+ ```javascript
+ PCSDK.platform.gameIconShow(adUnitId: string, opts: { count: number, style: Array<_GameIconStyleItem> }): Promise
+ ```
+
+ 定义:创建并显示小游戏推荐icon组件。
+
+ 参数:
+
+ ```javascript
+ adUnitId string 必传 小游戏推荐icon组件广告单元id
+ opts object 必传 扩展参数,目前支持count和style两个属性值
+ {
+ count number 必传 游戏icon的数量,请注意,正式版下面渲染出来的icon数量会小于等于count,请注册做好样式兼容
+ style Array<_GameIconStyleItem> 必传 数组的每一项可以针对对应的icon设置位置和样式等信息,style的每一项称为_GameIconStyleItem
+ }
+
+ Object _GameIconStyleItem:单个游戏icon的位置和样式信息
+ {
+ appNameHidden boolean 必传 游戏名称是否隐藏
+ color string 必传 游戏名称的颜色色值
+ size number 必传 游戏icon的宽高值
+ borderWidth number 必传 游戏icon的border尺寸
+ borderColor string 必传 游戏icon的border颜色色值
+ left number 必传 游戏icon的X轴坐标
+ top number 必传 游戏icon的Y轴坐标
+ }
+ ```
+ 返回值:
+
+ ```javascript
+ Promise
+ Promise resolve创建展示成功回调,reject创建失败回到
+ ```
+
+ 示例:
+
+ ```javascript
+ // 显示1个推荐icon组件
+ private showGameIcon(){
+ let adUnitId: string = 'PBgAAgPWNXGkQ4p0';
+ let {windowWidth} = PCSDK.platform.getSystemData();
+ PCSDK.platform.gameIconShow(adUnitId, {
+ count: 1,
+ style: [
+ {
+ appNameHidden: false,
+ color: "#FF0000",
+ size: 50,
+ borderWidth: 0,
+ borderColor: "#FF0000",
+ left: (windowWidth / 750) * 550,
+ top: (windowWidth / 750) * 150
+ }
+ ]
+ })
+ .then(() => {
+ // console.warn('显示GameIcon成功');
+ })
+ .catch((err) => {
+ // console.warn('显示GameIcon失败');
+ });
+ }
+
+ ```
+11. **gameIconDestroy**
+
+ ```javascript
+ PCSDK.platform.gameIconDestroy(): void
+ ```
+
+ 定义:销毁正在展示的小游戏推荐icon组件。展示推荐icon组件广告后,请记得在页面关闭时候调用此api销毁GameIcon。
+
+ 参数:
+
+ ```javascript
+ 无
+ ```
+ 返回值:
+
+ ```javascript
+ void
+ ```
+
+ 示例:
+
+ ```javascript
+
+ private open(){
+ super.open();
+ this.showGameIcon();
+ }
+
+ private close(){
+ super.close();
+ this.destoryGameIcon();
+ }
+
+ // 显示2个推荐icon组件
+ private showGameIcon(){
+ let adUnitId: string = 'PBgAAgPWNXGkQ4p0';
+ let {windowWidth} = PCSDK.platform.getSystemData();
+ PCSDK.platform.gameIconShow(adUnitId, {
+ count: 2,
+ style: [
+ {
+ appNameHidden: false,
+ color: "#FF0000",
+ size: 50,
+ borderWidth: 0,
+ borderColor: "#FF0000",
+ left: (windowWidth / 750) * 450,
+ top: (windowWidth / 750) * 150
+ },
+ {
+ appNameHidden: false,
+ color: "#FF0000",
+ size: 50,
+ borderWidth: 0,
+ borderColor: "#FF0000",
+ left: (windowWidth / 750) * 550,
+ top: (windowWidth / 750) * 150
+ }
+ ]
+ })
+ .then(() => {
+ // console.warn('显示GameIcon成功');
+ })
+ .catch((err) => {
+ // console.warn('显示GameIcon失败');
+ });
+ }
+
+ // 销毁展示创建的GameIcon组件
+ private destoryGameIcon(){
+ PCSDK.platform.gameIconDestroy();
+ }
```
\ No newline at end of file
--
libgit2 0.21.0