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.
154 lines
4.8 KiB
154 lines
4.8 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
import User from "../../FrameWork/User/User";
|
|
import AppPlatform from "../../FrameWork/Util/AppPlatform";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
import TaskManager from "../JuQingChat/TaskManager";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class selectButton extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
button1: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
button2: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
button3: cc.Node = null;
|
|
|
|
callfunc1: any;
|
|
callfunc2: any;
|
|
isvideo1: any;
|
|
isvideo2: any;
|
|
callfunc3: any;
|
|
|
|
// @property
|
|
// text: string = 'hello';
|
|
|
|
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
init(str1, str2, callfunc1, callfunc2, isvideo1?, isvideo2?, isNoSelect?, callfunc3?) {
|
|
let lab1 = this.button1.getChildByName("lab").getComponent(cc.Label)
|
|
lab1.string = str1
|
|
lab1["_forceUpdateRenderData"](true);
|
|
let lab1size = lab1.node.getContentSize()
|
|
this.button1.setContentSize(cc.size(lab1size.width + 80, this.button1.getContentSize().height))
|
|
this.button1.getChildByName("播放").getComponent(cc.Widget).updateAlignment()
|
|
if (!isvideo1) {
|
|
this.button1.getChildByName("播放").active = false
|
|
lab1.node.setPosition(cc.v3(0, 0, 0))
|
|
}
|
|
|
|
let lab2 = this.button2.getChildByName("lab").getComponent(cc.Label)
|
|
lab2.string = str2
|
|
lab2["_forceUpdateRenderData"](true);
|
|
let lab2size = lab2.node.getContentSize()
|
|
this.button2.setContentSize(cc.size(lab2size.width + 80, this.button2.getContentSize().height))
|
|
this.button2.getChildByName("播放").getComponent(cc.Widget).updateAlignment()
|
|
if (!isvideo2) {
|
|
this.button2.getChildByName("播放").active = false
|
|
lab2.node.setPosition(cc.v3(0, 0, 0))
|
|
}
|
|
|
|
this.isvideo1 = isvideo1
|
|
this.isvideo2 = isvideo2
|
|
this.callfunc1 = callfunc1
|
|
this.callfunc2 = callfunc2
|
|
|
|
if (isNoSelect) {
|
|
this.button3.active = true
|
|
this.callfunc3 = callfunc3
|
|
} else {
|
|
this.button3.active = false
|
|
}
|
|
}
|
|
|
|
onTouch1() {
|
|
if (this.isvideo1) {
|
|
let tab = {
|
|
onClose: (finish) => {
|
|
if (finish) {
|
|
User.setShowAdNum(User.getShowAdNum() + 1)
|
|
Common5.ReportDY("inLevel", `任务${TaskManager.getCurUnLockMainTaskId()}-AD-剧情选择按钮观看视频`)
|
|
// Common5.ReportDY("inLevel", '开矿山-AD-刷新开采证');
|
|
if (this.callfunc1) {
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
this.callfunc1()
|
|
}
|
|
}
|
|
else {
|
|
Common5.showTips_custom("广告未观看完");
|
|
}
|
|
}, onFailed: () => {
|
|
|
|
}
|
|
}
|
|
AppPlatform.playVideo_custom(tab)
|
|
} else {
|
|
if (this.callfunc1) {
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
this.callfunc1()
|
|
}
|
|
}
|
|
}
|
|
|
|
onTouch2() {
|
|
if (this.isvideo2) {
|
|
let tab = {
|
|
onClose: (finish) => {
|
|
if (finish) {
|
|
User.setShowAdNum(User.getShowAdNum() + 1)
|
|
Common5.ReportDY("inLevel", `任务${TaskManager.getCurUnLockMainTaskId()}-AD-剧情选择按钮观看视频`)
|
|
// Common5.ReportDY("inLevel", '开矿山-AD-刷新开采证');
|
|
if (this.callfunc2) {
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
this.callfunc2()
|
|
}
|
|
}
|
|
else {
|
|
Common5.showTips_custom("广告未观看完");
|
|
}
|
|
}, onFailed: () => {
|
|
|
|
}
|
|
}
|
|
AppPlatform.playVideo_custom(tab)
|
|
} else {
|
|
if (this.callfunc2) {
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
this.callfunc2()
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
onTouch3() {
|
|
if (this.callfunc3) {
|
|
this.node.removeFromParent()
|
|
this.node.destroy()
|
|
this.callfunc3()
|
|
}
|
|
|
|
}
|
|
// update (dt) {}
|
|
}
|
|
|