提交 a187ad1b 作者: 王进

增加用户点击上报接口

上级 11bbde88
/**
* 鲸鱼游戏微信小游戏接入库
* @author 推广技术部
* @time: 2018-09-19
* @time: 2019-09-25
*/
class WechatSDK {
private sdkVersion: string = '2.2'
private sdkVersion: string = '2.4'
public constructor() {
this.sdkInit()
this.timerInit();
......@@ -546,6 +546,32 @@ class WechatSDK {
const obj = this.heartParams;
const tmp = Date.parse(new Date().toString()).toString() // 获取请求的时间戳秒
obj.time = obj.gentime = tmp.substr(0, 10);
obj.action = 'heartBeat';
obj.content.click_times = null;
this.reportEncode(obj);
setTimeout(function () {
_selt.heartBeat();
_selt.clickReport();
}, 60000);
}
// 上报点击
private clickCounter = 0 // 当前用户点击次数
public userClickEvent() {
this.clickCounter++;
console.log("--SDK当前点击次数", this.clickCounter);
}
private async clickReport() {
if(this.clickCounter > 0) {
const obj = this.heartParams;
const tmp = Date.parse(new Date().toString()).toString() // 获取请求的时间戳秒
obj.time = obj.gentime = tmp.substr(0, 10);
obj.action = 'userappclick';
obj.content.click_times = this.clickCounter;
await this.reportEncode(obj);
}
this.clickCounter = 0; // 上报后归零
}
private reportEncode(obj) {
let keys = Object.keys(obj).sort();
let key_url = "";
for (let i = 0; i < keys.length; i++) {
......@@ -553,9 +579,6 @@ class WechatSDK {
}
obj.sign = md5(key_url + 'BA886FF52827126DCD18E73E0E16420C')
this.request(Links.heartReport, obj, 'POST');
setTimeout(function () {
_selt.heartBeat();
}, 60000);
}
// 上报激活
public ActiReport() {
......@@ -1042,7 +1065,9 @@ class WechatSDK {
wifiname: ""
},
source: "weixinmp-api",
content: ""
content: {
click_times: 0
}
}
// 统计上报参数
private ReportParams = {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论