153 lines
4.9 KiB
Plaintext
153 lines
4.9 KiB
Plaintext
import { _decorator, Color, Label, Node, Sprite, view } from 'cc';
|
|
import { GButton } from '../../Main/Common/GButton';
|
|
import Utils from '../../Main/Common/Utils';
|
|
import li_BaseView from '../../Main/Common/li_BaseView';
|
|
import HttpUnit from '../../Main/Common/HttpUnit';
|
|
import SubManager from '../SubManager';
|
|
import GameManager from '../../Main/Manager/GameManager';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/**广告、分享的用途类型 */
|
|
export enum E_AD_TARGET {
|
|
/**加相亲次数 */
|
|
xiangqin = 1,
|
|
/**加聊天次数 */
|
|
liaotian = 2,
|
|
}
|
|
|
|
//关卡内看广告弹窗界面
|
|
@ccclass('TalkAdDialog')
|
|
export class TalkAdDialog extends li_BaseView {
|
|
|
|
private _nodeTab: any = {};
|
|
private _data;
|
|
|
|
//----重写父类接口---------------------------------------
|
|
onLoadCT() {
|
|
this.registerListenner();
|
|
Utils.parseNode(this.node, this._nodeTab)
|
|
|
|
}
|
|
openUIDataCT(data: any): void {
|
|
this._data = data || {};
|
|
}
|
|
|
|
|
|
registerListenner() {
|
|
// Utils.addInnerEL(InnerMsgCode.GM_UI_Close, this, this.resiveGMClose)
|
|
}
|
|
|
|
|
|
start() {
|
|
GButton.BandClick(this._nodeTab.mask, ()=>{
|
|
if (this._data.closeCallback) {
|
|
this._data.closeCallback();
|
|
}
|
|
this.onClose();
|
|
}, this, 0, null, null, false);
|
|
|
|
GButton.BandClick(this._nodeTab.btnClose, ()=>{
|
|
if (this._data.closeCallback) {
|
|
this._data.closeCallback();
|
|
}
|
|
this.onClose();
|
|
}, this);
|
|
|
|
GButton.BandClick(this._nodeTab.btnShare, ()=>{
|
|
if (this._data.type == E_AD_TARGET.liaotian) {
|
|
let levelData = GameManager.CurLevelData
|
|
if (levelData && levelData.share_num <= 0) {
|
|
SubManager.ShowPrompt("今日分享次数已用完");
|
|
return;
|
|
}
|
|
}
|
|
if (this._data.type == E_AD_TARGET.xiangqin && HttpUnit.GetXiangqinShareNum() <= 0) {
|
|
SubManager.ShowPrompt("今日分享次数已用完");
|
|
return;
|
|
}
|
|
|
|
if (this._data.shareCallback) {
|
|
this._data.shareCallback();
|
|
}
|
|
this.onClose();
|
|
}, this);
|
|
|
|
GButton.BandClick(this._nodeTab.btnAD, ()=>{
|
|
if (this._data.type == E_AD_TARGET.liaotian) {
|
|
let levelData = GameManager.CurLevelData
|
|
if (levelData && levelData.ad_num <= 0) {
|
|
SubManager.ShowPrompt("今日广告次数已用完");
|
|
return;
|
|
}
|
|
}
|
|
if (this._data.type == E_AD_TARGET.xiangqin && HttpUnit.GetXiangqinAdNum() <= 0) {
|
|
SubManager.ShowPrompt("今日广告次数已用完");
|
|
return;
|
|
}
|
|
|
|
if (this._data.adCallback) {
|
|
this._data.adCallback();
|
|
}
|
|
this.onClose();
|
|
}, this);
|
|
|
|
Utils.setString(this._nodeTab.labContent, this._data.content);
|
|
|
|
//关卡内聊天不再显示分享按钮
|
|
if (this._data.type == E_AD_TARGET.liaotian) {
|
|
this._nodeTab.btnShare.active = false;
|
|
}
|
|
|
|
//次数用完后置灰按钮
|
|
this.refreshBtnState()
|
|
}
|
|
|
|
//刷新按钮状态
|
|
private refreshBtnState() {
|
|
//分享按钮
|
|
let shareGray = false
|
|
if (this._data.type == E_AD_TARGET.liaotian) {
|
|
let levelData = GameManager.CurLevelData
|
|
if (levelData && levelData.share_num <= 0) {
|
|
shareGray = true
|
|
}
|
|
} else if (this._data.type == E_AD_TARGET.xiangqin && HttpUnit.GetXiangqinShareNum() <= 0) {
|
|
shareGray = true
|
|
}
|
|
if (shareGray) {
|
|
let shareSpt: Sprite = this._nodeTab.btnShare.getComponent(Sprite);
|
|
shareSpt.grayscale = true;
|
|
shareSpt.color = new Color(173, 173, 173, 255);
|
|
|
|
}
|
|
|
|
//广告按钮
|
|
let adGray = false
|
|
if (this._data.type == E_AD_TARGET.liaotian) {
|
|
let levelData = GameManager.CurLevelData
|
|
if (levelData && levelData.ad_num <= 0) {
|
|
Utils.setNodeGray(this._nodeTab.btnAD, true);
|
|
adGray = true
|
|
}
|
|
} else if (this._data.type == E_AD_TARGET.xiangqin && HttpUnit.GetXiangqinAdNum() <= 0) {
|
|
Utils.setNodeGray(this._nodeTab.btnAD, true);
|
|
adGray = true
|
|
}
|
|
if (adGray) {
|
|
let adSpt: Sprite = this._nodeTab.btnAD.getComponent(Sprite);
|
|
adSpt.grayscale = true;
|
|
let adSpt1: Sprite = this._nodeTab.adSpt1.getComponent(Sprite);
|
|
adSpt1.color = new Color(255, 255, 255, 130);
|
|
let labYes: Label = this._nodeTab.labYes.getComponent(Label);
|
|
labYes.color = new Color(173, 173, 173, 255);
|
|
}
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|