| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /**收获界面数据类 */
- import { RateConfig } from "../../../game/data/AdData";
- import Guide from "../../../game/module/guide/Guide";
- import { Data } from "../../../mk/data/Data";
- const { ccclass } = cc._decorator;
- @ccclass
- export default class HarvestData extends Data {
- configID = null;
- plantID = null;
- config = null;
- call = null;
- //领取类型 0 普通领取 1 超级加倍
- getType = 0;
- init_reward = false;
- node_fly: cc.Node = null;
- openPanel(configID, plantID, call, node) {
- this.configID = configID;
- this.plantID = plantID;
- this.call = call;
- this.node_fly = node;
- this.config = gData.gameData.getProductMap(this.plantID);
- let isTeaching = mk.guide.isGuiding();
- let rand = Math.random();
- let rate = gData.adData.getPerByEcpm(RateConfig.RC_superDouble);
- if (!isTeaching && rand <= rate) {
- mk.ui.openPanel('game/prefab/uiPanel/HarvestPanel');
- } else {
- this.getNormalReward();
- }
- }
- setAdData(data) {
- mk.console.logSingle('HarvestData addata ', this.adData);
- super.setAdData(data);
- //奖励弹窗
- //gData.reward.adData = gData.harvestData.adData;
- gData.reward.data = gData.harvestData.adData.videoRedMoney.videoRewardList;
- gData.reward.callback = gData.harvestData.call;
- let world_Pos = this.node_fly.parent.convertToWorldSpaceAR(this.node_fly.getPosition());
- gData.reward.getReward(world_Pos);
- //mk.ui.openPanel('module/reward/reward');
- gData.harvestData.call = null;
- }
- async getNormalReward() {
- let data = { id: this.config.id };
- let response = await mk.http.sendData('redMoney/addRedMoneyByFarm', data);
- if (response && response.errcode != 0) {
- return;
- }
- //奖励弹窗
- if (response.data.redMoneyAddition <= 0) {
- console.log('返回奖励为0')
- }
- else {
- this.getType = 0;
- let rewardData = [{ rewardType: 1, rewardNum: response.data.redMoneyAddition }];
- gData.reward.data = rewardData;
- gData.reward.callback = this.call;
- let world_Pos = this.node_fly.parent.convertToWorldSpaceAR(this.node_fly.getPosition());
- gData.reward.getReward(world_Pos);
- //mk.ui.openPanel('module/reward/reward');
- }
- }
- }
|