| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- /**
- * @description 福袋界面类
- * @author kaka
- */
- import JsbSystem from "../../../mk/system/JsbSystem";
- import SetGray from "../../component/SetGray";
- import TableView from "../../component/TableView";
- import { VideoAdType } from "../../data/GameData";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class BlessingBag extends cc.Component {
- @property(cc.RichText)
- txtRemaindAdNum: cc.RichText = null;
- @property(cc.Prefab)
- blassingBagItem: cc.Prefab = null;
- @property(cc.Node)
- itemContent: cc.Node = null;
- @property(cc.Node)
- btnAd: cc.Node = null;
- @property(cc.Node)
- adIcon: cc.Node = null;
- @property(cc.Node)
- node_xiabiao: cc.Node = null;
- @property(TableView)
- tableview: TableView = null;
- @property(cc.Button)
- video_btn: cc.Button = null;
- private scroll_view: cc.ScrollView = null!;
- /**红包页面类型 1 大额 2 任务*/
- private rbPanelType: number = 0;
- private adrbArray = [];
- private isPlayInitAni = true;
- onLoad() {
- }
- onEnable() {
- this.isPlayAni = false;
- this.isPlayInitAni = true;
- gData.blessingBag.isPlayAniUpdate = false;
- gData.blessingBag.init_videoRbData = true;
- }
- update(dt) {
- this.PlayMoneyAniUpdate(dt);
- if (gData.blessingBag.init_videoRbData) {
- this.UpdateInfo();
- }
- if (gData.blessingBag.init_openRb) {
- //this.OpenRbPanel(gData.blessingBag.taskRbId, gData.blessingBag.rbNum);
- if (cc.sys.isNative) {
- if (!gData.loginData.isAuth) {
- // JsbSystem.WxAuth();
- gData.gameData.authUIType = 0;
- mk.ui.openPanel('module/authUI/authUI');
- return;
- }
- }
- gData.blessingBag.HttpCashTask();
- }
- }
- lateUpdate() {
- gData.blessingBag.init_videoRbData = false;
- gData.blessingBag.init_openRb = false;
- }
- UpdateInfo() {
- let data = gData.blessingBag.videoRbData;
- if (!data) {
- return
- }
- let isAllComplete = true;
- for (let i = 0; i != data.welFareTaskList.length; ++i) {
- if (data.welFareTaskList[i].progressRate < 1) {
- isAllComplete = false;
- break;
- }
- }
- //if(isAllComplete || data.leftVideoTimes <= 0)
- if (isAllComplete) {
- this.video_btn.interactable = false;
- let cmp = this.video_btn.getComponent(SetGray);
- if (cmp) {
- cmp.setGray(true);
- }
- }
- {
- if (!isAllComplete && !this.video_btn.interactable) {
- this.video_btn.interactable = true;
- let cmp = this.video_btn.getComponent(SetGray);
- if (cmp) {
- cmp.setGray(false);
- }
- }
- }
- this.txtRemaindAdNum.string = "<color=#FDFCF5>今日剩余次数:</c><color=#FFE533>" + data.leftVideoTimes + "</color>";
- this.adIcon.active = data.isVideo != 1;
- if (this.adrbArray.length < 4) {
- this.adrbArray = [];
- for (let i = 0; i < data.welFareTaskList.length; i++) {
- let obj = {
- data: data.welFareTaskList[i],
- isPlayAniUpdate: gData.blessingBag.isPlayAniUpdate,
- isPlayInitAni: this.isPlayInitAni
- }
- this.adrbArray.push(obj);
- }
- this.itemContent.emit('srollview-init', this.adrbArray);
- this.scroll_view = this.itemContent.getComponent(cc.ScrollView);
- this.scroll_view.vertical = false;
- cc.tween(this.node).delay(0.1).call(() => {
- let allItem = this.tableview.getFrontPositionItemByCount(5);
- for (let i = 0; i != allItem.length; ++i) {
- //allItem[i].active = true;
- let posY = allItem[i].position.y
- allItem[i].y = posY - 600;
- cc.tween(allItem[i]).delay(i * 0.1).to(0.3, { y: posY }, cc.easeSineOut()).start();
- }
- }).start();
- } else {
- this.adrbArray = [];
- for (let i = 0; i < data.welFareTaskList.length; i++) {
- let obj = {
- data: data.welFareTaskList[i],
- isPlayAniUpdate: gData.blessingBag.isPlayAniUpdate,
- isPlayInitAni: this.isPlayInitAni
- }
- this.adrbArray.push(obj);
- }
- //刷新
- this.itemContent.emit('srollview-update', this.adrbArray);
- }
- this.isPlayInitAni = false;
- gData.blessingBag.isPlayAniUpdate = false;
- }
- private isPlayAni = false;
- targetProgress: number = 0;
- delta: number = 0;
- curValue: number = 0;
- curTime: number = 0;
- totalTime: number = 0;
- lastNum: number = 0;
- PlayMoneyAni(time) {
- this.totalTime = time;
- this.delta = (this.targetProgress - this.lastNum) / time;
- this.curValue = this.lastNum;
- this.curTime = 0;
- console.log("--->Update Time: " + time + " delta: " + this.delta + " curValue: " + this.curValue + " lastNum: " + this.lastNum);
- this.isPlayAni = true;
- }
- PlayMoneyAniUpdate(dt) {
- if (this.isPlayAni) {
- if (this.curTime < this.totalTime) {
- this.curTime += dt;
- this.curValue += this.delta * dt;
- if (this.curValue >= this.targetProgress) {
- this.isPlayAni = false;
- this.curValue = this.targetProgress;
- this.lastNum = this.targetProgress;
- }
- console.log("-->CurValue:" + this.curValue);
- } else {
- this.isPlayAni = false;
- this.curTime = this.totalTime;
- this.curValue = this.targetProgress;
- this.lastNum = this.targetProgress;
- }
- }
- }
- Click_AdProgressBtn() {
- mk.audio.playEffect("button");
- if (gData.blessingBag.videoRbData.isVideo == 1) {
- //免费加进度
- gData.blessingBag.addProgress();
- } else {
- // if (cc.sys.isNative && !gData.loginData.isAuth) {
- // // JsbSystem.WxAuth();
- // mk.ui.openPanel('module/authUI/authUI');
- // return;
- // }
- if (gData.blessingBag.videoRbData.leftVideoTimes > 0) {
- mk.ad.videoAdType = VideoAdType.video_init_15;
- mk.ad.watchAd(async (success: boolean) => {
- mk.console.log("watchAD:" + success);
- if (success) {
- await gData.adData.watchVideo(null);
- gData.blessingBag.addProgress();
- }
- });
- } else {
- mk.tip.pop('今日观看次数已用完');
- }
- }
- console.log("--->You Click AdProgressBtn ", gData.blessingBag.videoRbData);
- }
- /**
- * 打开红包页面
- * @param type 打开红包类型 1 大额红包 2 任务红包
- * @param num 红包金额
- */
- OpenRbPanel(type: number, num: number) {
- //this.rbPanelType = type;
- // this.txtRbNum.string = num + "元";
- // this.nodeRb.active = true;
- // this.rbOpenBtn.active = true;
- //把打开原来的红包界面操作取消掉,直接提现
- if (cc.sys.isNative) {
- if (!gData.loginData.isAuth) {
- // JsbSystem.WxAuth();
- gData.gameData.authUIType = 0;
- mk.ui.openPanel('module/authUI/authUI');
- return;
- }
- }
- gData.blessingBag.HttpCashTask();
- }
- CheckCashRedCode() {
- let data = gData.blessingBag.videoRbData;
- if (data.redMoneyCode.length > 0) {
- for (let i = 0; i < data.redMoneyCode.length; i++) {
- if (data.preLargeAmountCashId == data.redMoneyCode[i].RedMoneyId) {
- if (data.redMoneyCode[i].RedMoneyCode != "") {
- gData.redCodeData.openRedCode(data.redMoneyCode[i].VideoCashBig, data.redMoneyCode[i].RedMoneyCode);
- } else {
- mk.tip.pop('提现成功');
- }
- return;
- }
- }
- }
- mk.tip.pop('请先完成提现任务');
- }
- async Click_CashBtn() {
- console.log("--->You Click CashBtn");
- mk.audio.playEffect("button");
- if (gData.blessingBag.videoRbData.cumulativeAmount >= gData.blessingBag.videoRbData.requestAmount) {
- let response = await gData.blessingBag.HttpCashBig();
- if (response && response.data.code == 1) {
- //弹红包码界面
- this.CheckCashRedCode();
- gData.cashNormal.getRecord();// 请求新的提现记录
- } else {
- mk.tip.pop('请先完成提现任务');
- }
- } else {
- mk.tip.pop("累计到" + gData.blessingBag.videoRbData.requestAmount + "元才可提现");
- }
- }
- /** 点击帮助回调 */
- clickHelpCallBack() {
- let des = "1、观看大量视频可以快速增加提现进度。\n\n2、提现进度到100%,可以提现对应档位的红包。\n\n3、余额累计满一定金额,可以申请大额提现。";
- gData.help.des = des;
- }
- Click_InitData() {
- mk.audio.playEffect("button");
- gData.blessingBag.HttpInitAdRbData();
- }
- /** 点击关闭 */
- onClickClose() {
- }
- onDisable() {
- gData.adData.checkShowFullInter(4);
- }
- }
|