Commit 24c3912e authored by haiyoucuv's avatar haiyoucuv

整理一下代码

parent 062ea016
......@@ -6,7 +6,7 @@ import { changeScene, showPanel, showToast } from "db://assets/Module/UIFast";
import GameMgr from "db://assets/Scripts/GameMgr";
import RulePanel from '../Panels/RulePanel';
import { getUrlParam } from '../Utils/Utils';
import { RankScene } from './RankScene';
import { RankScene } from './RankScene/RankScene';
import ShareCenter from '../ShareCenter';
import { RecordScene } from './RecordScene/RecordScene';
import { ChangeEquipPanel } from '../Panels/ChangeEquipPanel/ChangeEquipPanel';
......
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "83966994-6281-422c-a699-352bc57ccc27",
"files": [],
"subMetas": {},
"userData": {}
}
import { _decorator, Label, Node, view, Widget, UITransform, Prefab, instantiate, assetManager, ImageAsset, SpriteFrame, Texture2D, Sprite, UIOpacity } from "cc";
import Scene from "db://assets/Module/Scene";
import { changeScene } from "db://assets/Module/UIFast";
import { HomeScene } from "./HomeScene";
import { ScrollList, SCROLL_VERTICAL } from "../ScrollList/ScrollList";
import { strFormat } from "../Utils/Utils";
import { sendWebNet, WebNetName } from "../Utils/WebNet/WebNet";
import { HomeScene } from "db://assets/Scripts/Scenes/HomeScene";
import { ScrollList, SCROLL_VERTICAL } from "db://assets/Scripts/ScrollList/ScrollList";
import { strFormat } from "db://assets/Scripts/Utils/Utils";
import { sendWebNet, WebNetName } from "db://assets/Scripts/Utils/WebNet/WebNet";
const { ccclass, property } = _decorator;
@ccclass("RankScene")
......
import { _decorator, Component, Node, Label } from 'cc';
import { strFormat } from '../Utils/Utils';
import { ScrollListItem } from './ScrollListItem';
import { strFormat } from 'db://assets/Scripts/Utils/Utils';
import { ScrollListItem } from 'db://assets/Scripts/ScrollList/ScrollListItem';
const { ccclass, property } = _decorator;
@ccclass("RankScrollListItem")
......
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "4b902be0-0dfb-4071-b305-fed78a2e239b",
"files": [],
"subMetas": {},
"userData": {}
}
import {
_decorator,
Node,
UIOpacity,
Prefab,
} from 'cc';
import Scene from "db://assets/Module/Scene";
import { changeScene } from "db://assets/Module/UIFast";
import { ScrollList, SCROLL_VERTICAL } from "db://assets/Scripts/ScrollList/ScrollList";
import { sendWebNet, WebNetName } from 'db://assets/Scripts/Utils/WebNet/WebNet';
import { HomeScene } from 'db://assets/Scripts/Scenes/HomeScene';
const {ccclass, property} = _decorator;
@ccclass("RecordScene")
export class RecordScene extends Scene {
static skin: string = "RecordScene";
static group: string[] = ["RecordScene"];
/** 明细页类别 */
private _type: string = "1";
get type() {
return this._type;
}
set type(type: string) {
this._type = type;
}
@property({type: ScrollList, tooltip: "竖行滚动容器"})
private vScroll: ScrollList;
@property(Node)
RecordBox: Node = null;
@property(Node)
gameBg: Node = null;
@property(Node)
countBg: Node = null;
start() {
this.getCountRecordInfo();
}
/** 获取次数明细 */
async getCountRecordInfo() {
const res = await sendWebNet(WebNetName.changeDetails);
if (res?.success) {
this.recordRender(res?.data || []);
}
}
/** 获取游戏记录 */
async getGameRecordInfo() {
const res = await sendWebNet(WebNetName.gameRecord);
if (res?.success) {
this.recordRender(res?.data || []);
}
}
/** 明细渲染 */
recordRender(recordInfo = []) {
this.vScroll.setDataList(recordInfo, SCROLL_VERTICAL, [0, 0, 0]);
this.vScroll.scrollToTop(0);
if (recordInfo.length <= 0) {
this.node.getChildByName("Empty").getComponent(UIOpacity).opacity = 255;
} else {
this.node.getChildByName("Empty").getComponent(UIOpacity).opacity = 0;
}
}
/** 切换tab */
handleClickTab(event, data) {
this.type = data;
if (data == "1") {
this.countBg.active = true;
this.gameBg.active = false;
this.getCountRecordInfo();
} else if (data == "2") {
this.countBg.active = false;
this.gameBg.active = true;
this.getGameRecordInfo();
}
}
/** 返回首页 */
handleClickBackBtn() {
changeScene(HomeScene);
}
update(deltaTime: number) {
}
}
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "88be9277-d3c9-4ddb-b1f9-98c0ab63e711",
"files": [],
"subMetas": {},
"userData": {}
}
import { _decorator, Component, Node, Label, Color } from 'cc';
import { dateFormatter, strFormat } from 'db://assets/Scripts/Utils/Utils';
import { ScrollListItem } from 'db://assets/Scripts/ScrollList/ScrollListItem';
const { ccclass, property } = _decorator;
@ccclass("RecordScrollListItem")
export class RecordScrollListItem extends ScrollListItem {
start() {}
onItemRender(data, ...param: any[]) {
if (Object.keys(data).includes("ifGetPrize")) {
this.node.getChildByName("Title").getComponent(Label).string = `获得${data?.score || 0}游园积分`;
this.node.getChildByName("Time").getComponent(Label).string = `${dateFormatter(data?.timestamp, "yyyy.MM.dd hh:mm")}`;
if(!!data?.ifGetPrize) {
this.node.getChildByName("Desc").getComponent(Label).color = new Color(255, 5, 0, 255);
this.node.getChildByName("Desc").getComponent(Label).string = `获得宝箱`;
} else {
this.node.getChildByName("Desc").getComponent(Label).string = `未获得宝箱`;
this.node.getChildByName("Desc").getComponent(Label).color = new Color(16, 168, 73, 255);
}
} else {
this.node.getChildByName("Title").getComponent(Label).string = strFormat(data?.source, 30);
this.node.getChildByName("Time").getComponent(Label).string = `${dateFormatter(data?.timestamp, "yyyy.MM.dd hh:mm")}`;
this.node.getChildByName("Desc").getComponent(Label).string = `挑战次数${data?.type || ""}${data?.num}`;
if (data?.type == "-") {
this.node.getChildByName("Desc").getComponent(Label).color = new Color(16, 168, 73, 255);
} else {
this.node.getChildByName("Desc").getComponent(Label).color = new Color(255, 5, 0, 255);
}
}
}
}
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "4f6618e5-878b-4af3-91b7-4af8f8fa0a9f",
"files": [],
"subMetas": {},
"userData": {}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment