Files
fc/dev/project/library/imports/81/81cbe488-7205-4f74-a606-2a8a9ec9f67b.js
T
2026-05-24 10:21:26 +08:00

57 lines
1.6 KiB
JavaScript

"use strict";
cc._RF.push(module, '81cbeSIcgVPdKYGKoqeyfZ7', 'cmp.trace.click');
// Scripts/nx/mods/trace/cmps/cmp.trace.click.js
"use strict";
/******************************************************************
* Copyright(C) 2019 - 2020 Nx Studio
*
* 埋点组件:点击
*
* 2018.05.18
******************************************************************/
var TDefine = require("trace.define");
cc.Class({
"extends": cc.Component,
properties: {
idType: {
"default": 0,
type: TDefine.TraceType,
displayName: "埋点类型"
},
btnName: {
"default": "",
displayName: "按钮名"
}
},
// 编辑器特性
editor: {
// 允许当前组件在编辑器模式下运行
executeInEditMode: false,
// requireComponent 参数用来指定当前组件的依赖组件
requireComponent: cc.Button,
// 当本组件添加到节点上后,禁止同类型(含子类)的组件再添加到同一个节点,防止逻辑发生冲突
disallowMultiple: true,
// menu 用来将当前组件添加到组件菜单中,方便用户查找
menu: "Nx/埋点|按钮点击"
},
// 显示
onEnable: function onEnable() {
this.node.on("click", this.onCatchClicked, this);
},
// 隐藏
onDisable: function onDisable() {
this.node.off("click", this.onCatchClicked, this);
},
// 点击
onCatchClicked: function onCatchClicked() {
if (!nx.mTrace || !nx.dt.numPositive(this.idType, false) || nx.dt.strEmpty(this.btnName)) {
return;
}
nx.mTrace.trace(this.idType, this.btnName);
}
});
cc._RF.pop();