12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import { _decorator, Component, Node } from "cc";
- import BaseUI from "../../scripts/base/BaseUI";
- import UserM, { GiftItemInfo } from "../../scripts/api/UserM";
- import { Tips } from "../../scripts/mgr/Tips";
- import GameM from "../../scripts/api/GameM";
- import { GoodsId } from "../../scripts/api/GoodsId";
- const { ccclass, property } = _decorator;
- @ccclass("PlayGamePassReward")
- export class PlayGamePassReward extends BaseUI {
- private data: GiftItemInfo;
- private gameId: number;
- private onClaimSuccess: () => void;
- async init(gameId: number, data: GiftItemInfo, onClaimSuccess: () => void) {
- this.data = data;
- this.gameId = gameId;
- this.onClaimSuccess = onClaimSuccess;
- this.setText("lbl_game_pass_reward", this.data.rewardMsg);
- this.FindNode("btn_game_pass_claim").active = this.data.canClaim > 0;
- }
- protected simpleOnBtnClick(name: string): void {
- switch (name) {
- case "btn_game_pass_claim":
- this.requestClaimGamePassGift();
- break;
- }
- }
- async requestClaimGamePassGift() {
- if (UserM.ins.getGamePassCount() <= 0) {
- Tips.show("Insufficient Game Pass");
- return;
- }
- let result = await GameM.ins.claimGamePassGift(
- this.gameId,
- this.data.giftId
- );
- if (result) {
- this.onClaimSuccess();
- }
- }
- }
|