Files
18xchat/assets/Scripts/chat18x/ui/panels/GirlListItem.ts
T

73 lines
1.9 KiB
TypeScript
Raw Normal View History

2025-08-11 16:08:59 +08:00
import { _decorator, Component, Label, Node, Sprite, UITransform } from "cc";
import { Config18x, GirlInfo } from "db://assets/Scripts/Main/Config/Config18x";
2025-07-30 21:52:26 +08:00
import PriceType = Config18x.PriceType;
2025-08-11 16:08:59 +08:00
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
2025-08-01 18:28:36 +08:00
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
import Utils from "db://assets/Scripts/Main/Common/Utils";
2025-08-11 16:08:59 +08:00
import { NavigationManager } from "../../manager/NavigationManager";
2025-07-30 21:52:26 +08:00
2025-07-22 16:43:10 +08:00
const { ccclass, property } = _decorator;
@ccclass("GirlListItem")
export class GirlListItem extends Component {
@property(Sprite)
avatar: Sprite;
@property(Label)
girlName: Label;
@property(Label)
2025-07-30 21:52:26 +08:00
tags: Label;
2025-07-22 16:43:10 +08:00
@property(Label)
price: Label;
@property(Node)
2025-07-30 21:52:26 +08:00
freeNode: Node;
@property(Node)
tryNode: Node;
@property(Node)
2025-07-22 16:43:10 +08:00
chatBtn: Node;
2025-07-30 21:52:26 +08:00
@property(Node)
2025-08-11 16:08:59 +08:00
starParent: Node;
2025-07-22 16:43:10 +08:00
id: number = -1;
2025-07-25 18:27:30 +08:00
baseNode: Node;
2025-08-11 16:08:59 +08:00
refreshData(data: GirlInfo, baseNode: Node) {
2025-07-30 21:52:26 +08:00
this.baseNode = baseNode;
2025-07-25 15:20:02 +08:00
this.id = data.id;
this.girlName.string = data.name;
2025-08-11 16:08:59 +08:00
let desc = "";
2025-07-30 21:52:26 +08:00
for (let i = 0; i < data.tag.length; i++) {
2025-08-11 16:08:59 +08:00
if (i != 0) desc += "&";
2025-08-01 18:28:36 +08:00
desc += data.tag[i];
2025-07-30 21:52:26 +08:00
}
this.tags.string = desc;
2025-08-11 16:08:59 +08:00
this.price.node.active = data.priceType == PriceType.Coin;
2025-07-30 21:52:26 +08:00
this.freeNode.active = data.priceType == PriceType.Free;
this.tryNode.active = data.priceType == PriceType.Try;
2025-08-11 16:08:59 +08:00
ResManager.I.changeBundleSpriteFrame(
this.avatar,
data.pic.url,
"Chat18x",
() => {
let sizeTran = this.avatar.node.parent.getComponent(UITransform);
Utils.adjustBgPixelRatioToSize(
sizeTran.contentSize,
this.avatar.node,
2
);
}
);
2025-08-01 18:28:36 +08:00
2025-08-11 16:08:59 +08:00
for (let i = 0; i < 5; i++) {
this.starParent.children[i].active = i < data.starCount;
2025-07-30 21:52:26 +08:00
}
2025-07-25 15:20:02 +08:00
}
2025-07-22 16:43:10 +08:00
onClickDetail() {
2025-08-11 16:08:59 +08:00
NavigationManager.Instance.navigateToGirlDetail(this.id);
2025-07-30 21:52:26 +08:00
ViewManager.I.closeView(this.baseNode);
2025-07-22 16:43:10 +08:00
}
update(deltaTime: number) {}
}