提交 7a9096ea 作者: 王进

增加隐藏分享对局回放按钮接口

上级 9f652f58
...@@ -561,14 +561,14 @@ class WechatSDK { ...@@ -561,14 +561,14 @@ class WechatSDK {
// console.log("--SDK当前点击次数", this.clickCounter); // console.log("--SDK当前点击次数", this.clickCounter);
} }
private async clickReport() { private async clickReport() {
if(this.clickCounter > 0) { if (this.clickCounter > 0) {
const obj = this.heartParams; const obj = this.heartParams;
const tmp = Date.parse(new Date().toString()).toString() // 获取请求的时间戳秒 const tmp = Date.parse(new Date().toString()).toString() // 获取请求的时间戳秒
obj.time = obj.gentime = tmp.substr(0, 10); obj.time = obj.gentime = tmp.substr(0, 10);
obj.action = 'userappclick'; obj.action = 'userappclick';
obj.content.click_times = this.clickCounter; obj.content.click_times = this.clickCounter;
await this.reportEncode(obj); await this.reportEncode(obj);
} }
this.clickCounter = 0; // 上报后归零 this.clickCounter = 0; // 上报后归零
} }
private reportEncode(obj) { private reportEncode(obj) {
...@@ -967,7 +967,7 @@ class WechatSDK { ...@@ -967,7 +967,7 @@ class WechatSDK {
const _self = this; const _self = this;
try { try {
this.GameRecorder = (wx as any).getGameRecorder(); this.GameRecorder = (wx as any).getGameRecorder();
if(!this.GameRecorder.isFrameSupported()) { if (!this.GameRecorder.isFrameSupported()) {
if (cpCallback) cpCallback({ status: 0, msg: '设备不支持录屏功能.' }); if (cpCallback) cpCallback({ status: 0, msg: '设备不支持录屏功能.' });
return; return;
} }
...@@ -996,11 +996,13 @@ class WechatSDK { ...@@ -996,11 +996,13 @@ class WechatSDK {
public stopGameRecorder(shareInfo) { public stopGameRecorder(shareInfo) {
try { try {
this.GameRecorder.stop(); this.GameRecorder.stop();
this.createRecorderShareButton(shareInfo); if (this.recorderBtn) this.recorderBtn.show();
else this.createRecorderShareButton(shareInfo);
} catch (err) { } catch (err) {
console.log("$$SDK录屏异常::gameRecorder", err); console.log("$$SDK录屏异常::gameRecorder", err);
} }
} }
private recorderBtn = null // 对局回放分享按钮对象
private createRecorderShareButton(shareInfo) { private createRecorderShareButton(shareInfo) {
const _selt = this; const _selt = this;
let recorderShareInfo = { let recorderShareInfo = {
...@@ -1014,19 +1016,24 @@ class WechatSDK { ...@@ -1014,19 +1016,24 @@ class WechatSDK {
paddingLeft: shareInfo.paddingLeft, paddingLeft: shareInfo.paddingLeft,
paddingRight: shareInfo.paddingRight paddingRight: shareInfo.paddingRight
}, },
image: shareInfo.image, icon: shareInfo.icon || '',
image: shareInfo.image || '',
text: shareInfo.text || '',
share: { share: {
query: 'fromOpenId=' + _selt.ReportParams.openId + '&from=share&tag=0&' + (shareInfo.query ? shareInfo.query : ''), query: 'fromOpenId=' + _selt.ReportParams.openId + '&from=share&tag=0&' + (shareInfo.query ? shareInfo.query : ''),
bgm: shareInfo.bgm, bgm: shareInfo.bgm,
timeRange: shareInfo.timeRange timeRange: shareInfo.timeRange
} }
}; };
let recorderBtn = (wx as any).createGameRecorderShareButton(recorderShareInfo); this.recorderBtn = (wx as any).createGameRecorderShareButton(recorderShareInfo);
recorderBtn.onTap(res => { // 当分享出现异常时才会触发点击回调
this.recorderBtn.onTap(res => {
console.log('--录屏异常:', res); console.log('--录屏异常:', res);
recorderBtn.hide();
}); });
} }
public hideGameRecorderShareButton() {
if(this.recorderBtn) this.recorderBtn.hide();
}
private heartParams = { private heartParams = {
action: "heartbeat", action: "heartbeat",
appid: SDKConfig.productCode, appid: SDKConfig.productCode,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论