Commit 796ec47e91f2ddfd02dc55a454267f282433f3b2
1 parent
6a23c5db
Exists in
master
1
Showing
17 changed files
with
50 additions
and
50 deletions
Show diff stats
images/sdk_021.png
images/sdk_022.png
images/sdk_023.png
images/sdk_024.png
images/sdk_025.png
images/sdk_026.png
29 KB
62.8 KB
183 KB
install.md
... | ... | @@ -85,7 +85,7 @@ |
85 | 85 | ZoneId: "1", // 分区ID,默认:1 |
86 | 86 | Mode: "game", // 支付的类型,不同的支付类型有各自额外要传的附加参数,默认:game |
87 | 87 | CurrencyType: "CNY", // 币种,默认:CNY |
88 | - Platform: '' // 申请接入时的平台,platform与应用id有关。默认:android(ios暂时没有开放,这里需要配置Platform,开放后,删掉此配置,sdk已经判断平台) | |
88 | + Platform: '' // 申请接入时的平台,platform与OfferId(米大师申请的应用id)有关,详情请阅读文档config.js参数MidasPay下的Platform配置 | |
89 | 89 | } |
90 | 90 | }; |
91 | 91 | ``` |
... | ... | @@ -193,7 +193,7 @@ |
193 | 193 | |
194 | 194 | CurrencyType:币种,默认:"CNY" |
195 | 195 | |
196 | - Platform:申请接入时的平台,platform与应用id有关。 | |
196 | + Platform:申请接入时的平台,platform与OfferId(米大师申请的应用id)有关。 | |
197 | 197 | |
198 | 198 | 1)接入了米大师,填写"android"(ios暂时没有开放) |
199 | 199 | ... | ... |
platform.md
... | ... | @@ -8,27 +8,18 @@ |
8 | 8 | |
9 | 9 | #### **此模块是参照微信小游戏提供的api进行封装的公用方法,提供了以下游戏中常用到的功能:** |
10 | 10 | |
11 | -**支付打点: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 | 13 | |
13 | -**打开客服消息:openCustomerServiceConversation** 整理[wx.openCustomerServiceConversation](https://developers.weixin.qq.com/minigame/dev/api/open-api/customer-message/wx.openCustomerServiceConversation.html) | |
14 | - | |
15 | -**检测版本更新:checkUpdate** 整理来自:[wx.getUpdateManager](https://developers.weixin.qq.com/minigame/dev/api/base/update/UpdateManager.html) | |
16 | - | |
17 | -**显示模态弹出框:showModal** 整理来自:[wx.showModal](https://developers.weixin.qq.com/minigame/dev/api/ui/interaction/wx.showModal.html) | |
18 | - | |
19 | -**复制文本:copy** 整理来自:[wx.setClipboardData](https://developers.weixin.qq.com/minigame/dev/api/device/clipboard/wx.setClipboardData.html) | |
20 | - | |
21 | -**长震动:vibrateLong** 整理来自:[wx.vibrateLong](https://developers.weixin.qq.com/minigame/dev/api/device/vibrate/wx.vibrateLong.html) | |
22 | - | |
23 | -**短震动:vibrateShort** 整理来自:[wx.vibrateShort](https://developers.weixin.qq.com/minigame/dev/api/device/vibrate/wx.vibrateShort.html) | |
24 | - | |
25 | -**更新转发属性:updateShareMenu** 整理来自:[wx.updateShareMenu](https://developers.weixin.qq.com/minigame/dev/api/share/wx.updateShareMenu.html) | |
26 | - | |
27 | -**微信小游戏推荐弹窗组件GamePortal:isGamePortalPlaying 与 gamePortalShow** 整理来自:[wx.createGamePortal](https://developers.weixin.qq.com/minigame/dev/api/game-portal/GameBanner.html) | |
28 | - | |
29 | -**微信小游戏推荐icon组件GameIcon:gameIconShow 与 gameIconDestroy** 整理来自:[wx.createGameIcon](https://developers.weixin.qq.com/minigame/dev/api/game-portal/wx.createGameIcon.html) | |
30 | - | |
31 | -**微信小游戏插屏广告组件InterstitialAd:isInterstitialPlaying 与 interstitialShow** 整理来自:[wx.createInterstitialAd](https://developers.weixin.qq.com/minigame/dev/api/ad/InterstitialAd.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) | |
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) | |
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) | |
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) | |
32 | 23 | |
33 | 24 | |
34 | 25 | |
... | ... | @@ -149,7 +140,6 @@ |
149 | 140 | ``` |
150 | 141 | 示例2:应用场景如进入客服会话跳转领取体力、钻石等等: 示例为跳转客服领取18888钻石奖励,success函数中记录数据状态(用于客服返回,执行onShow生命周期函数时逻辑判断)。 |
151 | 142 | <iframe height=498 width=740 src="https://dep.miso-lab.com/sdkword/sdk_video_001.mp4" frameborder=0 allowfullscreen></iframe> |
152 | - | |
153 | 143 | ```javascript |
154 | 144 | // 跳转客服领取18888钻石奖励,开发者可根据示例修改 |
155 | 145 | PCSDK.platform.openCustomerServiceConversation({ |
... | ... | @@ -169,20 +159,20 @@ |
169 | 159 | console.log("openCustomerServiceConversation fail: ", err); |
170 | 160 | } |
171 | 161 | }); |
172 | - | |
173 | - // 在游戏中全局注册的onShow事件监听中检测是 | |
162 | + | |
163 | + // 在游戏中全局注册的onShow事件监听中检测是 | |
174 | 164 | // 游戏入口:Main.cs |
175 | 165 | class Main { |
176 | 166 | constructor() { |
177 | 167 | this.init(); |
178 | 168 | } |
179 | - | |
180 | - private init() { | |
169 | + | |
170 | + private init() { | |
181 | 171 | PCSDK.event.add('app.show', this.onShow, this); // 等同于wx.onShow(this.onShow.bind(this)); |
182 | 172 | PCSDK.event.add('app.hide', this.onHide, this); // 等同于wx.onHide(this.onHide.bind(this)); |
183 | 173 | } |
184 | - | |
185 | - private onShow(opts) { | |
174 | + | |
175 | + private onShow(opts) { | |
186 | 176 | // 判断是否是来源于客服会话,上面的openCustomerServiceConversation的success设置的数据状态做判断 |
187 | 177 | let serviceRewardData = AppDataManager.I.get('service.reward.data'); |
188 | 178 | if (serviceRewardData && serviceRewardData.status === 1) { |
... | ... | @@ -190,15 +180,14 @@ |
190 | 180 | // 奖励发放,处理发放后的逻辑,比如每天只能领取一次的记录,防止重复刷奖励 |
191 | 181 | } |
192 | 182 | } |
193 | - | |
194 | - private onHide(){ | |
183 | + | |
184 | + private onHide(){ | |
195 | 185 | // 监听平台的onHide事件 |
196 | 186 | } |
197 | 187 | } |
198 | 188 | ``` |
199 | 189 | 示例3:应用场景例如进入客服会话,success函数中记录数据状态(用于客服返回,执行onShow生命周期函数时逻辑判断),点击右下角的充值按钮后,跳转充值,充值完成后在onShow中处理:需要后台提供api接口,验证充值合理性并发放奖励,**此接口需要后端支持**。 |
200 | 190 | <iframe height=498 width=740 src="https://dep.miso-lab.com/sdkword/sdk_video_002.mp4" frameborder=0 allowfullscreen></iframe> |
201 | - | |
202 | 191 | ```javascript |
203 | 192 | // 跳转客服充值,开发者可根据示例修改,sendMessagePath请严格按照示例中提供的参数 |
204 | 193 | /** |
... | ... | @@ -226,21 +215,21 @@ |
226 | 215 | } |
227 | 216 | }); |
228 | 217 | } |
229 | - | |
218 | + | |
230 | 219 | // 在游戏中全局注册的onShow事件监听中检测是 |
231 | - // 游戏入口:Main.cs | |
220 | + // 游戏入口:Main.cs | |
232 | 221 | class Main { |
233 | 222 | constructor() { |
234 | 223 | this.init(); |
235 | 224 | } |
236 | - | |
225 | + | |
237 | 226 | private init() { |
238 | - PCSDK.event.add('app.show', this.onShow, this); // 等同于wx.onShow(this.onShow.bind(this)); | |
227 | + PCSDK.event.add('app.show', this.onShow, this); // 等同于wx.onShow(this.onShow.bind(this)); | |
239 | 228 | PCSDK.event.add('app.hide', this.onHide, this); // 等同于wx.onHide(this.onHide.bind(this)); |
240 | 229 | } |
241 | - | |
230 | + | |
242 | 231 | private onShow(opts) { |
243 | - // 判断是否是来源于客服会话,上面的openCustomerServiceConversation的success设置的数据状态做判断 | |
232 | + // 判断是否是来源于客服会话,上面的openCustomerServiceConversation的success设置的数据状态做判断 | |
244 | 233 | let serviceRewardData = AppDataManager.I.get('service.pay.data'); |
245 | 234 | if (serviceRewardData && serviceRewardData.status === 1) { |
246 | 235 | AppDataManager.I.set('service.pay.data', null); |
... | ... | @@ -248,9 +237,9 @@ |
248 | 237 | // 请求后端接口验证奖励合理性 |
249 | 238 | } |
250 | 239 | } |
251 | - | |
240 | + | |
252 | 241 | private onHide(){ |
253 | - // 监听平台的onHide事件 | |
242 | + // 监听平台的onHide事件 | |
254 | 243 | } |
255 | 244 | } |
256 | 245 | ``` |
... | ... | @@ -284,6 +273,8 @@ |
284 | 273 | ``` |
285 | 274 | |
286 | 275 | 示例:在游戏入口类中检测是否有版本更新 |
276 | + | |
277 | + 1)、依照下面的示例接入checkUpdate api | |
287 | 278 | |
288 | 279 | ```javascript |
289 | 280 | class Main { |
... | ... | @@ -311,43 +302,52 @@ |
311 | 302 | } |
312 | 303 | |
313 | 304 | ``` |
305 | + 2)、接入代码完毕后,按照下图的操作本地开发工具调试是否接入成功。 | |
306 | + | |
307 | + I、选择:添加编译模式。 | |
308 | +  | |
309 | + II、选择:自定义模式名称、勾选下次编译时模拟更新、选择模拟成功还是失败状态,点击确定。 | |
310 | +  | |
311 | + III、开发工具会自动重新启动游戏,弹出更新框,看到弹出框接入成功。 | |
312 | +  | |
313 | + | |
314 | 314 | <div id="vibrate"></div> |
315 | 315 | 4.0 **vibrateShort** |
316 | - | |
316 | + | |
317 | 317 | ```javascript |
318 | 318 | PCSDK.platform.vibrateShort(): Promise<any> |
319 | 319 | ``` |
320 | 320 | |
321 | 321 | 定义:使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效 |
322 | - | |
322 | + | |
323 | 323 | 参数: |
324 | - | |
324 | + | |
325 | 325 | ```javascript |
326 | 326 | 无 |
327 | 327 | ``` |
328 | - | |
328 | + | |
329 | 329 | 示例: |
330 | - | |
330 | + | |
331 | 331 | ```javascript |
332 | 332 | PCSDK.platform.vibrateShort(); |
333 | 333 | |
334 | 334 | ``` |
335 | 335 | 4.1 **vibrateLong** |
336 | - | |
336 | + | |
337 | 337 | ```javascript |
338 | 338 | PCSDK.platform.vibrateShort(): Promise<any> |
339 | 339 | ``` |
340 | 340 | |
341 | 341 | 定义:使手机发生较长时间的振动(400 ms) |
342 | - | |
342 | + | |
343 | 343 | 参数: |
344 | - | |
344 | + | |
345 | 345 | ```javascript |
346 | 346 | 无 |
347 | 347 | ``` |
348 | - | |
348 | + | |
349 | 349 | 示例: |
350 | - | |
350 | + | |
351 | 351 | ```javascript |
352 | 352 | PCSDK.platform.vibrateLong(); |
353 | 353 | ... | ... |