| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- import JsbSystem from "../../../mk/system/JsbSystem";
- import TableView from "../../component/TableView";
- import { AdFun } from "../../data/AdData";
- import { DataEventId, 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();
- if (index > 0)
- index -= 1;
- //index = 4;
- this.tableview.contentMoveByIndex(index, 0.01);
- cc.tween(this.node).delay(0.1).call(()=>{
- this.scroll_view.vertical = false;
- }).call(()=>{
- let allItem = this.tableview.getItemByIndexAndCount(index, 3);
- allItem && allItem.sort((a, b)=>{
- return a.index - b.index;
- })
- let len = allItem.length;
- for(let i = 0; i != len; ++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();
- }
- }).delay(0.7).call(()=>{
- this.scroll_view.vertical = true;
- }).start();
-
- }
- 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.playerProp.isSignInToday == 1) return;
- if (!gData.sign.haveSignDay()) return;
- //const index_old = gData.sign.getItemIndexByCanSign();
- const index_old = gData.gameData.playerProp.signInDay;
- if(cc.sys.isNative)
- {
- if (gData.sign.c_sign[index_old].rewardType === RewardType.rmb) {
- if (!gData.loginData.isAuth) {
- // JsbSystem.WxAuth();
- gData.gameData.authUIType = 0;
- mk.ui.openPanel('module/authUI/authUI');
- return;
- }
- }
- }
-
- mk.ad.videoAdType = VideoAdType.video_init_4;
- // 看广告
- mk.ad.watchAd((success: boolean) => {
- mk.console.log("watchAD:" + success);
- if (success) {
- gData.adData.watchVideo(AdFun.sign);
- //FC:埋点
- if (gData.sign.c_sign[index_old].rewardType === RewardType.rmb) {
- mk.data.sendDataEvent(DataEventId.Sundry, "签到提现成功");
- }
- mk.ad.destroyNativeAd();
- }
- });
- }
- /**
- * 拿奖励
- */
- private getReward() {
- const index_old = gData.sign.getItemIndexByCanSign();
- // 完成展示
- gData.sign.signComplete();
- // 指定条目数据刷新
- this.tableview.resetItemData(index_old, gData.sign.list_data[index_old]);
- // 打开奖励界面
- // to do
- }
- /**
- * 初始化按钮样式
- */
- private initBtnStyle() {
- if (gData.gameData.playerProp.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.audio.playEffect("button");
- //mk.ad.destroyNativeAd();
- }
- }
|