推荐列表实现虚拟+无限循环
This commit is contained in:
@@ -29,7 +29,15 @@ export class RecomandItem extends Component {
|
||||
|
||||
private id: number;
|
||||
|
||||
// 标记是否已初始化(用于虚拟列表复用)
|
||||
public _initialized: boolean = false;
|
||||
|
||||
// 兼容原有调用方式的 init 方法
|
||||
init() {
|
||||
if (this._initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
Utils.parseNode(this.node, this._nodeTab);
|
||||
|
||||
this.recPic = this._nodeTab.recPic.getComponent(Sprite);
|
||||
@@ -45,6 +53,14 @@ export class RecomandItem extends Component {
|
||||
this.chatBtn = this._nodeTab.chatBtn;
|
||||
GButton.BandClick(this.chatBtn, this.chatToHer, this);
|
||||
GButton.BandClick(this._nodeTab.detailBtn, this.gotoDetail, this);
|
||||
|
||||
this._initialized = true;
|
||||
}
|
||||
|
||||
// 节点回收到对象池时调用,重置状态
|
||||
reset(): void {
|
||||
this.id = -1;
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
refresh(girlId: number) {
|
||||
@@ -72,7 +88,7 @@ export class RecomandItem extends Component {
|
||||
});
|
||||
|
||||
const star = girlData.getStar(category.toString(), this.id);
|
||||
logger.log("好感度:" + star);
|
||||
//logger.log("好感度:" + star);
|
||||
for (let i = 0; i < this.hearts.length; i++) {
|
||||
const element = this.hearts[i];
|
||||
if (star > i) {
|
||||
@@ -100,11 +116,16 @@ export class RecomandItem extends Component {
|
||||
const currentPanel = NavigationManager.Instance.getCurrentActivePanelNode();
|
||||
if (currentPanel) {
|
||||
const chatData = { girlId: this.id, base: currentPanel };
|
||||
NavigationManager.Instance.openSubPanel("ChatPanel", currentPanel, chatData, {
|
||||
openAnimation: PageTransitionType.SLIDE_LEFT,
|
||||
closeAnimation: PageTransitionType.SLIDE_RIGHT,
|
||||
hideBasePanel: true,
|
||||
});
|
||||
NavigationManager.Instance.openSubPanel(
|
||||
"ChatPanel",
|
||||
currentPanel,
|
||||
chatData,
|
||||
{
|
||||
openAnimation: PageTransitionType.SLIDE_LEFT,
|
||||
closeAnimation: PageTransitionType.SLIDE_RIGHT,
|
||||
hideBasePanel: true,
|
||||
}
|
||||
);
|
||||
} else {
|
||||
logger.warn("[RecomandItem] 无法获取当前激活的主页面");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user