12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- import { _decorator, Component, Node } from "cc";
- import { Hall } from "../hall/Hall";
- import BaseUI from "../../scripts/base/BaseUI";
- import WalletM from "../../scripts/api/WalletM";
- import UserM from "../../scripts/api/UserM";
- import { instantiate } from "cc";
- import { ScrollView } from "cc";
- import AB from "../../scripts/base/AB";
- import { Prefab } from "cc";
- import { BadgeItem } from "../item/BadgeItem";
- const { ccclass, property } = _decorator;
- @ccclass("BadgeDetailLayer")
- export class BadgeDetailLayer extends BaseUI {
- static TYPE_RANK = 1;
- static TYPE_GAME_PASS = 2;
- static async show(type: number) {
- let layer = await Hall.ins.showLayer("prefab/layer/BadgeDetailLayer");
- layer.getComponent(BadgeDetailLayer).init(type);
- }
- private scrollView: ScrollView = null;
- protected onLoad(): void {
- super.onLoad();
- this.scrollView = this.FindAs("ScrollView", ScrollView);
- }
- private _type: number = 0;
- async init(type: number) {
- this._type = type;
- let tpl: Prefab = await AB.ins.loadPrefab("prefab/item/BadgeItem");
- let list = await UserM.ins.getBadgeList();
- if (!list || !list.badgeList || list.badgeList.length == 0) {
- this.FindNode("NoData").active = true;
- return;
- }
- this.FindNode("NoData").active = false;
- for (let i = 0; i < list.badgeList.length; i++) {
- let item = list.badgeList[i];
- let itemNode = instantiate(tpl);
- itemNode.getComponent(BadgeItem).init(item);
- this.scrollView.content.addChild(itemNode);
- }
- }
- }
|