Files
18xchat/assets/Scripts/Sub/Item/CommAdDialog.ts
T

80 lines
2.1 KiB
TypeScript
Raw Normal View History

2025-07-17 17:18:21 +08:00
import { _decorator, Component, Node, Sprite } from 'cc';
import { GButton } from '../../Main/Common/GButton';
import Utils from '../../Main/Common/Utils';
const { ccclass, property } = _decorator;
//通用广告弹窗
@ccclass('CommAdDialog')
export class CommAdDialog extends Component {
private _nodeTab: any = {};
private _data;
private inited: boolean = false;
onLoad() {
Utils.parseNode(this.node, this._nodeTab)
}
start() {
// GButton.BandClick(this._nodeTab.mask, ()=>{
// }, this, 0, null, null, false);
//关闭
GButton.BandClick(this._nodeTab.btnClose, ()=>{
if (this._data && this._data.closeCallback) {
this._data.closeCallback();
}
this.node.removeFromParent()
}, this);
//左 取消
GButton.BandClick(this._nodeTab.btnLeft, ()=>{
if (this._data && this._data.leftCallback) {
this._data.leftCallback();
}
this.node.removeFromParent()
}, this);
//右 看广告
GButton.BandClick(this._nodeTab.btnAD, ()=>{
if (this._data && this._data.adCallback) {
this._data.adCallback();
}
this.node.removeFromParent()
}, this);
this.inited = true;
this.refreshUI();
}
update(deltaTime: number) {
}
/**设置显示参数 */
setParam(data: any) {
this._data = data;
this.refreshUI();
}
private refreshUI() {
if (!this.inited || !this._data) return;
//内容
Utils.setString(this._nodeTab.labContent, this._data.content);
//确认按钮文本
if (this._data.strAd) {
Utils.setString(this._nodeTab.labAd, this._data.strAd);
}
//取消按钮文本
if (this._data.strLeft) {
Utils.setString(this._nodeTab.labLeft, this._data.strLeft);
}
//隐藏取消按钮
if (this._data.hideLeft == true) {
this._nodeTab.btnLeft.active = false;
}
}
}