模拟数据:技师的简要数据

This commit is contained in:
chen wei bo
2025-09-02 16:38:38 +08:00
parent cf32944f64
commit 29554bb0c8
4 changed files with 88 additions and 27 deletions
@@ -4,6 +4,11 @@ import Utils from "db://assets/Scripts/Main/Common/Utils";
import { GButton } from "db://assets/Scripts/Main/Common/GButton";
import { GirlListItem } from "../../uiitems/GirlListItem";
import { ConfigManager } from "../../manager/ConfigManager";
import { GirlService } from "db://assets/Scripts/chat18x/network/services/GirlService";
import { DataManager, DataId } from "../../data/DataManager";
import { GirlData } from "../../data/GirlData";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
const { ccclass, property } = _decorator;
@ccclass("GirlListPanel")
@@ -28,22 +33,34 @@ export class GirlListPanel extends li_BaseView {
this.refresh(this.category);
}
refresh(category: number) {
async refresh(category: number) {
if (this.cache) {
for (let i = this.cache.length - 1; i >= 0; i--) {
this.cache[i].node.destroy();
}
}
const GirlsData = ConfigManager.tables.TbGirls.getDataList();
const config = GirlsData.filter((value) => value.category == category);
for (let i = 0; i < config.length; i++) {
const cfg = config[i];
let newNode = instantiate(this.itemInst.node);
let item = newNode.getComponent(GirlListItem);
item.refreshData(cfg, this.node);
newNode.active = true;
this.cache.push(item);
this.content.addChild(newNode);
// 请求列表
const reqData = {
category,
page: 1,
limit: 10,
};
let res = await GirlService.I.reqGetGirlList(reqData);
if (res && res.code === proto.cs.EnmRetCode.SUCCESS) {
// 保存数据
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
girlData.setGirlBriefs(category.toString(), res.data);
// 根据数据,刷新界面
const allId = girlData.getGirlIds(category.toString());
for (let id of allId) {
let newNode = instantiate(this.itemInst.node);
let item = newNode.getComponent(GirlListItem);
item.refreshData(category, id, this.node);
newNode.active = true;
this.cache.push(item);
this.content.addChild(newNode);
}
}
}
@@ -74,7 +74,7 @@ export class ThemePanel extends li_BaseView {
// 保存数据
const themeData = DataManager.I.getDataById<ThemeData>(DataId.Theme);
themeData.themes = res.data;
// 根据数据,构建界面显示
// 根据数据,刷新界面
const themeIds = themeData.themeIds;
for (let id of themeIds) {
let newNode = instantiate(this.itemInst.node);
@@ -94,7 +94,7 @@ export class ThemePanel extends li_BaseView {
if (res2 && res2.code === proto.cs.EnmRetCode.SUCCESS) {
const girlData = DataManager.I.getDataById<GirlData>(DataId.Girl);
girlData.setDailyRecommend(res2.data);
// 根据数据,构建界面显示
// 根据数据,刷新界面
this.recId = girlData.getRecommendGrilId(0);
this.rectNameKey = girlData.getRecommendGrilName(0);
let avatarPath = girlData.getRecommendGrilAvatar(0);