44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { _decorator, Component, Node, Label } from "cc";
|
|
import { Item } from "./ItemList";
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass("ItemTemplate")
|
|
export class ItemTemplate extends Component {
|
|
@property(Label)
|
|
public bctype: Label | null = null;
|
|
@property(Label)
|
|
public num: Label | null = null;
|
|
@property(Label)
|
|
public type: Label | null = null;
|
|
@property(Label)
|
|
public price: Label | null = null;
|
|
@property(Label)
|
|
public time: Label | null = null;
|
|
|
|
start() {}
|
|
init(data) {
|
|
this.bctype.string = "金币";
|
|
this.num.string = data.num;
|
|
this.type.string = data.name;
|
|
this.price.string = data.price;
|
|
this.time.string = this.formatDateTime(data.time);
|
|
}
|
|
formatDateTime(timeStamp) {
|
|
var date = new Date();
|
|
date.setTime(timeStamp * 1000);
|
|
var y = date.getFullYear();
|
|
var m = date.getMonth() + 1;
|
|
let _m = m < 10 ? "0" + m : m;
|
|
var d = date.getDate();
|
|
let _d = d < 10 ? "0" + d : d;
|
|
var h = date.getHours();
|
|
let _h = h < 10 ? "0" + h : h;
|
|
let minute = date.getMinutes();
|
|
var second = date.getSeconds();
|
|
let _minute = minute < 10 ? "0" + minute : minute;
|
|
let _second = second < 10 ? "0" + second : second;
|
|
return y + "-" + _m + "-" + _d + " " + _h + ":" + _minute + ":" + _second;
|
|
}
|
|
update(deltaTime: number) {}
|
|
}
|