代码结构整理
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import { _decorator, Component, Label, Node, Sprite, UITransform } from "cc";
|
||||
import { Config18x, GirlInfo } from "db://assets/Scripts/Main/Config/Config18x";
|
||||
import PriceType = Config18x.PriceType;
|
||||
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";
|
||||
|
||||
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: GirlInfo, 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.Coin;
|
||||
this.freeNode.active = data.priceType == PriceType.Free;
|
||||
this.tryNode.active = data.priceType == PriceType.Try;
|
||||
|
||||
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
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
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) {}
|
||||
}
|
||||
Reference in New Issue
Block a user