| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- /** 订单抽奖界面 */
- import { AdFun } from "../../../game/data/AdData";
- import { GameProp, VideoAdType } from "../../../game/data/GameData";
- import Util from "../../util/Util";
- import OrderDrawItem from "../uiItem/OrderDrawItem";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class OrderDrawPanel extends cc.Component {
- @property({ type: OrderDrawItem, displayName: '抽奖item' })
- itemsArr: OrderDrawItem[] = [];
- private dis = 8;
- private endIndex = 0;
- private maxNum: number = 0;
- private curSelItem: OrderDrawItem;
- private lastSelItem: OrderDrawItem;
- private changeA: any = {};
- private go = 0;
- private listData = null;
- private cashData = null;
- private clickCool = false;
- async onLoad() {
- let data = {};
- let response = await mk.http.sendData('orderTaskTree/getOrderLuckyReward', data);
- if (response.errcode != 0) {
- return null;
- }
- this.listData = response.data;
- let len = this.listData.length;
- mk.console.logSingle('listData ', this.listData);
- this.go = 0;
- for (var i = 0; i < len; i++) {
- this.itemsArr[i].init(this.listData[i]);
- }
- }
- clickDraw() {
- if (this.clickCool) {
- return;
- }
- console.log('aaaaaaaa 111 ');
- this.clickCool = true;
- mk.ad.videoAdType = VideoAdType.video_init_22;
- mk.ad.watchAd((success: boolean) => {
- if (success) {
- gData.gameData.isOrderVideo = true;
- gData.adData.watchVideo(AdFun.harvest, async () => {
- console.log('aaaaaaaa 222 ');
- let data = {};
- let response = await mk.http.sendData('orderTaskTree/receiveRewardNewCash', data);
- console.log('aaaaaaaa ', response.errcode);
- mk.console.logSingle('receiveRewardNewCash ', response);
- gData.gameData.isOrderVideo = false;
- if (response.errcode != 0) {
- this.clickCool = false;
- return null;
- }
- //当前订单种植数据清空
- gData.gameData.setProp(GameProp.orderPlantTimes, {});
- this.cashData = response.data;
- mk.data.sendDataEvent('Orderreward', this.cashData.orderLuckyRedMoney);
- mk.console.logSingle('receiveRewardNewCash cashData ', response);
- this.endIndex = 0;
- for (var i = 0; i < this.listData.length; i++) {
- if (this.listData[i].amount == this.cashData.orderLuckyRedMoney) {
- this.endIndex = i;
- break;
- }
- }
- this.dis = 8;
- let startIndex = Util.rnd(0, this.dis - 1);
- this.maxNum = this.dis * 3 + this.endIndex;
- this.changeA.startIndex = startIndex;
- cc.tween(this.changeA).to(5, { startIndex: this.maxNum }, cc.easeOut(3)).call(() => {
- this.go = 2;
- }).start();
- if (this.lastSelItem) {
- this.lastSelItem.setSelect(false);
- }
- this.curSelItem = this.itemsArr[startIndex];
- this.curSelItem.setSelect(true);
- this.go = 1;
- });
- }
- else {
- this.clickCool = false;
- console.log('aaaaaaaa fail ');
- }
- })
- }
- protected update(dt: number): void {
- if (this.go == 1) {
- this.lastSelItem = this.curSelItem;
- this.lastSelItem.setSelect(false);
- console.log(Math.round(this.changeA.startIndex) % this.dis)
- this.curSelItem = this.itemsArr[Math.round(this.changeA.startIndex) % this.dis];
- this.curSelItem.setSelect(true);
- }
- else if (this.go == 2) {
- this.go = 0;
- this.scheduleOnce(() => {
- //奖品类型(1:红包币 2:现金)
- if (this.cashData.orderLuckyType == 1) {
- // gData.gameData.playerProp.redMoney += this.cashData.orderLuckyRedMoney;
- let rewardData = [{ rewardType: 1, rewardNum: this.cashData.orderLuckyRedMoney }];
- gData.reward.data = rewardData;
- mk.ui.openPanel("module/reward/reward");
- gData.gameData.playerProp.orderData = this.cashData.userOrderTaskInfo;
- gData.reward.closeUICallBack = gData.gameData.gameStyle.getRewardCallBack.bind(gData.gameData.gameStyle);
- gData.gameData.gameStyle.showRefreshLogic();
- }
- else if (this.cashData.orderLuckyType == 2) {
- gData.receiptNotice.receip_rmb = this.cashData.orderLuckyRedMoney;
- mk.ui.openPanel('module/newNotice/newNotice');
- gData.gameData.playerProp.orderData = this.cashData.userOrderTaskInfo;
- gData.safeDepositBoxData.setCashRecordDataLength();
- //处理提现逻辑
- gData.cashPro.isOrderCashOut = true;
- gData.cashPro.callBack = gData.gameData.gameStyle.getRewardCallBack.bind(gData.gameData.gameStyle);
- gData.gameData.gameStyle.showRefreshLogic();
- }
- mk.ui.closePanel(this.node.name);
- }, 1);
- }
- }
- }
|