| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- import JsbSystem from "../../../mk/system/JsbSystem";
- import TableView from "../../component/TableView";
- import { AdFun } from "../../data/AdData";
- import { DataEventId, GameProp, RewardType, VideoAdType } from "../../data/GameData";
- /**
- * 签到界面
- * - 每天第一次上线默认弹出一次【除首日】。待处理
- * - 全部签完后,不可再签到。此处需要判断上次签到天数。
- * - 滑动列表需要滚动到对应签到条目的高度,待处理。
- * @author 薛鸿潇
- */
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class Sign extends cc.Component {
- @property({ type: cc.ScrollView, displayName: '滚动视图' })
- private scroll_view: cc.ScrollView = null!;
- @property({ type: cc.Animation, displayName: '按钮_动画' })
- private anim_btn: cc.Animation = null!;
- private tableview: TableView = null;
- onLoad() {
- }
- start() {
- mk.ad.showNative(4);
- // gData.sign.sign_can = gData.gameData.getProp(GameProp.sign_can);
- gData.sign.initListData();
- gData.sign.init_data = true;
- this.initScollView();
- }
- /**
- * 初始化滚动视图
- */
- private initScollView() {
- let list_data = gData.sign.list_data;
- this.scroll_view.node.emit('srollview-init', list_data)
- this.tableview = this.scroll_view.node.getComponent('TableView')
- let index = gData.sign.getItemIndexByCanSign();
- this.scheduleOnce(() => {
- this.tableview.contentMoveByIndex(index)
- }, 0.1)
- }
- update(dt) {
- if (gData.sign.init_data) {
- this.initBtnStyle();
- return;
- }
- if (gData.sign.adData) {
- // 展示奖励
- this.getReward();
- }
- }
- lateUpdate() {
- gData.sign.adData = null;
- }
- /**
- * 点击领取按钮
- */
- private clickReceiveReward() {
- mk.audio.playEffect("button");
- if (gData.gameData.gameData.isSignInToday == 1) return;
- if (!gData.sign.haveSignDay()) return;
- const index = gData.gameData.gameData.signInDay;
- if (gData.sign.c_sign[index].rewardType === RewardType.rmb) {
- if (!gData.loginData.isAuth) {
- JsbSystem.WxAuth();
- return;
- }
- }
- mk.ad.videoAdType = VideoAdType.Sign;
- // 看广告
- mk.ad.watchAd((success: boolean) => {
- mk.console.log("watchAD:" + success);
- if (success) {
- gData.adData.watchVideo(AdFun.sign);
- //FC:埋点
- if (gData.sign.c_sign[index].rewardType === RewardType.rmb) {
- mk.data.sendDataEvent(DataEventId.signWithDrawal, "签到提现成功");
- }
- mk.ad.destroyNativeAd();
- }
- });
- }
- /**
- * 拿奖励
- */
- private async getReward() {
- // 完成展示
- await gData.sign.signComplete();
- const index_old = gData.sign.getItemIndexByCanSign();
- // 指定条目数据刷新
- this.tableview.resetItemData(index_old, gData.sign.list_data[index_old]);
- }
- /**
- * 初始化按钮样式
- */
- private initBtnStyle() {
- if (gData.gameData.gameData.isSignInToday == 0 && gData.sign.haveSignDay()) {
- this.anim_btn.play();
- // this.anim_btn.getComponent(SetGray).setGray(false);
- this.anim_btn.getComponent(mk.component.setGray).setGray(false)
- } else {
- this.anim_btn.stop();
- this.anim_btn.node.scale = 1;
- // this.anim_btn.getComponent('SetGray').setGray(true);
- this.anim_btn.getComponent(mk.component.setGray).setGray(true)
- }
- gData.sign.init_data = false;
- }
- onClickClose() {
- mk.ad.destroyNativeAd();
- mk.ad.checkShowInterByChance();
- }
- onDisable() {
- let showGuide = false;
- if (gData.sign.success) {
- gData.sign.success = false;
- gData.safeDepositBoxData.creatPacketAnim(2);
- gData.cashNormal.checkGuideBank();
- }
- if (!showGuide) {
- const isAutoOpenPanel = gData.gameData.getProp(GameProp.isAutoOpenPanel);
- if (isAutoOpenPanel === 1) {
- gData.guideToWxData.checkPop();
- gData.gameData.setProp(GameProp.isAutoOpenPanel, 2);
- }
- }
- }
- }
|