first commit

This commit is contained in:
2026-03-30 09:39:59 +08:00
parent 6c52425fca
commit 5ac73d3c6d
4484 changed files with 1144395 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
import { _decorator, Asset, ImageAsset, Node, ScrollView, Sprite, SpriteFrame, Texture2D } from 'cc';
import BaseView from '../../../../../../extensions/app/assets/base/BaseView';
import { Tools } from 'db://assets/res-native/tools/Tools';
import { LANG_ENUM, LANG_SET } from 'db://assets/res-native/setting/LangSet';
const { ccclass, property } = _decorator;
@ccclass('PageRewardhistory')
export class PageRewardhistory extends BaseView {
@property(Node)
rw_item: Node = null!;
@property(ScrollView)
rw_list: ScrollView = null!;
private now_index: number = 0;
private _create_time_min : string = "";
private _create_time_max : string = "";
// 初始化的相关逻辑写在这
onLoad() {}
// 界面打开时的相关逻辑写在这(onShow可被多次调用-它与onHide不成对)
onShow(params: any) {
this.now_index = 1
this.initRw()
this.rw_list.node.on(ScrollView.EventType.SCROLL_TO_BOTTOM, this.nextPage, this)
// 计算一周内的时间范围
const now = new Date()
const oneWeekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000)
// 转换为北京时间 (使用toLocaleString指定时区)
const getTimeString = (date: Date) => {
return date.toLocaleString('sv-SE', {
timeZone: 'Asia/Shanghai',
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
});
};
this._create_time_min = getTimeString(oneWeekAgo)
this._create_time_max = getTimeString(now)
}
// 界面关闭时的相关逻辑写在这(已经关闭的界面不会触发onHide)
onHide(result: undefined) {
// app.manager.ui.show<PageRewardhistory>({name: 'PageRewardhistory', onHide:(result) => { 接收到return的数据并且有类型提示 }})
this.rw_list.node.off(ScrollView.EventType.SCROLL_TO_BOTTOM, this.nextPage, this)
return result;
}
nextPage() {
this.now_index += 1
this.initRw()
}
initRw() {
if (this.now_index == 1) this.rw_list.content.removeAllChildren()
Tools.httpReq("user/playGameRecord", {
"page": this.now_index,
"limit": 20,
"create_time_min": this._create_time_min,
"create_time_max": this._create_time_max
}, (res:any)=>{
for (let i = 0; i < res.list.length; i++) {
let d = res.list[i]
let item = Tools.AddChild(this.rw_list.content, this.rw_item, "item" + i);
item.active = true;
this.loadSprite(d.win_coin >= 0 ? "rehis_bg_get" : "rehis_bg_lost", item)
let lang_str = LANG_ENUM[LANG_SET.langIndex]
Tools.ActChild(item, "win_" + lang_str, d.win_coin > 0)
if (d.win_coin > 0) Tools.SetChildText(item, "win_" + lang_str + "/lab", Math.trunc(d.win_coin).toString())
Tools.ActChild(item, "lose_" + lang_str, d.win_coin < 0)
if (d.win_coin < 0) Tools.SetChildText(item, "lose_" + lang_str + "/lab", Math.abs(Math.trunc(d.win_coin)).toString())
Tools.ActChild(item, "more", d.win_coin == 0)
Tools.SetChildText(item, "time", d.create_time)
}
})
}
loadSprite(pic: string, node: Node){
this.loadRes(pic, Asset, (res: ImageAsset)=>{
let sp = new SpriteFrame()
let tex = new Texture2D();
tex.image = res;
sp.texture = tex
node.getComponent(Sprite).spriteFrame = sp
});
}
}