73 lines
2.0 KiB
TypeScript
73 lines
2.0 KiB
TypeScript
import { _decorator, Component, Label, Node, Sprite, UITransform } from "cc";
|
|
import { Config18x } from "db://assets/Scripts/Main/Config/Config18x";
|
|
import { ViewManager } from "db://assets/Scripts/Main/Manager/ViewManager";
|
|
import ResManager from "db://assets/Scripts/Main/Manager/ResManager";
|
|
import Utils from "db://assets/Scripts/Main/Common/Utils";
|
|
import { NavigationManager } from "../../manager/NavigationManager";
|
|
import { Girl, PriceType } from "../../../schema/schema";
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass("GirlListItem")
|
|
export class GirlListItem extends Component {
|
|
@property(Sprite)
|
|
avatar: Sprite;
|
|
@property(Label)
|
|
girlName: Label;
|
|
@property(Label)
|
|
tags: Label;
|
|
@property(Label)
|
|
price: Label;
|
|
@property(Node)
|
|
freeNode: Node;
|
|
@property(Node)
|
|
tryNode: Node;
|
|
@property(Node)
|
|
chatBtn: Node;
|
|
@property(Node)
|
|
starParent: Node;
|
|
|
|
id: number = -1;
|
|
|
|
baseNode: Node;
|
|
refreshData(data: Girl, baseNode: Node) {
|
|
this.baseNode = baseNode;
|
|
this.id = data.id;
|
|
this.girlName.string = data.name;
|
|
let desc = "";
|
|
for (let i = 0; i < data.tag.length; i++) {
|
|
if (i != 0) desc += "&";
|
|
desc += data.tag[i];
|
|
}
|
|
this.tags.string = desc;
|
|
this.price.node.active = data.priceType == PriceType.pay;
|
|
this.freeNode.active = data.priceType == PriceType.free;
|
|
this.tryNode.active = data.priceType == PriceType.first_time_free;
|
|
|
|
ResManager.I.changeBundleSpriteFrame(
|
|
this.avatar,
|
|
data.avatarPath,
|
|
"Chat18x",
|
|
() => {
|
|
let sizeTran = this.avatar.node.parent.getComponent(UITransform);
|
|
Utils.adjustBgPixelRatioToSize(
|
|
sizeTran.contentSize,
|
|
this.avatar.node,
|
|
2
|
|
);
|
|
}
|
|
);
|
|
|
|
for (let i = 0; i < 5; i++) {
|
|
this.starParent.children[i].active = i < data.starCount;
|
|
}
|
|
}
|
|
|
|
onClickDetail() {
|
|
NavigationManager.Instance.navigateToGirlDetail(this.id);
|
|
ViewManager.I.closeView(this.baseNode);
|
|
}
|
|
|
|
update(deltaTime: number) {}
|
|
}
|