消除我特牛
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

164 lines
4.9 KiB

4 weeks ago
/*
* @Descripttion:
* @version: 1.0.0
* @Author: YeeChan
* @Date: 2020-07-09 18:54:38
*/
import AppPlatform from "./AppPlatform";
import { LogUtils } from "./LogUtils";
export enum ALDEventDef {
None_custom = "",
ReportAdClickSuccess_custom = "广告导出成功",
ReportAdClickFail_custom = "广告导出失败",
ReportLaunchOptions_custom = "用户启动参数",
//todo:添加你自己的阿拉丁事件
}
//阿拉丁相关接口FD
export default class ALD {
/**
* openid
* @param openid
*/
public static aldSendOpenId_custom(openid: string) {
if (AppPlatform.is_WECHAT_GAME_custom()) {
window["wx"].aldSendOpenid(openid);
LogUtils.log_custom("ALD 上报 openid : ", openid);
} else if (AppPlatform.is_QQ_PLAY_custom()) {
window["qq"].aldSendOpenid(openid);
LogUtils.log_custom("ALD 上报 openid : ", openid);
}
}
/**
*
* @param event
* @param data
*/
public static aldSendEvent_custom(event: ALDEventDef | string, data: any) {
var eventName: string = event;
if (AppPlatform.is_WECHAT_GAME_custom()) {
window["wx"].aldSendEvent(eventName, data);
} else if (AppPlatform.is_QQ_PLAY_custom()) {
window["qq"].aldSendEvent(eventName, data);
}
}
/**
*
* @param data
*/
public static aldSendReportAdClickSuccess_custom(data: any) {
var type = ALDEventDef.ReportAdClickSuccess_custom + " " + data.title + ":" + String(data.appid)
ALD.aldSendEvent_custom(type,
{
"导出成功": data.title + ":" + String(data.appid)
})
}
/**
*
* @param data
*/
public static aldSendReportAdClickFail_custom(data: any) {
var type = ALDEventDef.ReportAdClickFail_custom + " " + data.title + ":" + String(data.appid)
ALD.aldSendEvent_custom(type,
{
"导出失败": data.title + ":" + String(data.appid)
})
}
/**
* IP
* @param sceneid
* @param ip
* @param location
*/
public static aldSendReportLaunchOptions_custom(sceneid: string, ip: string, location: Object) {
var type = ALDEventDef.ReportLaunchOptions_custom;
ALD.aldSendEvent_custom(type,
{
"场景值:": String(sceneid),
"Ip:": String(ip),
"地区:": JSON.stringify(location)
})
}
/**
*
*
* @param levelId id
*/
public static aldLevelStart(levelId: number) {
if (AppPlatform.is_WECHAT_GAME_custom()) {
window["wx"].aldStage.onStart({
stageId: levelId + "",
stageName: "关卡" + levelId,
});
} else if (AppPlatform.is_QQ_PLAY_custom()) {
window["qq"].aldStage.onStart({
stageId: levelId + "",
stageName: "关卡" + levelId,
});
}
}
/**
*
* @param levelId
* @param event
* @param params
*/
public static aldLevelRunning(levelId: number, event: string = "operation", params: any) {
if (AppPlatform.is_WECHAT_GAME_custom()) {
window["wx"].aldStage.onRunning({
stageId: levelId + "",
stageName: "关卡" + levelId,
event: event,
params: params //params中必须含有itemName字段
});
} else if (AppPlatform.is_QQ_PLAY_custom()) {
window["11"].aldStage.onRunning({
stageId: levelId + "",
stageName: "关卡" + levelId,
event: event,
params: params //params中必须含有itemName字段
});
}
}
/**
*
* event字段必须是规定字符串使completefail
* @param levelId
* @param event
* @param desc
*/
public static aldLevelEnd(levelId: number, event: string = "complete", desc: string = "关卡结束") {
if (AppPlatform.is_WECHAT_GAME_custom()) {
window["wx"].aldStage.onEnd({
stageId: levelId + "",
stageName: "关卡" + levelId,
event: event,
params: {
desc: desc
}
});
} else if (AppPlatform.is_QQ_PLAY_custom()) {
window["qq"].aldStage.onEnd({
stageId: levelId + "",
stageName: "关卡" + levelId,
event: event,
params: {
desc: desc
}
});
}
}
}