| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { _decorator, Component, Node, Label, RichText, utils } from 'cc';
- const { ccclass, property } = _decorator;
- @ccclass('WithdrawaGTlItem')
- export class WithdrawaGTlItem extends Component {
- @property({ tooltip: "记录类型", type: Node })
- public withdrawType: Node;
- @property({ tooltip: "记录时间", type: Node })
- public withdrawTime: Node;
- @property({ tooltip: "记录金额", type: Node })
- public money: Node;
- start() {
- }
- /**
- * 初始化ui
- * @param type 记录类型
- * @param time 记录时间
- * @param money 金额
- */
- public onDataChange(data: any) {
- // this.withdrawType.getComponent(Label).string = data.type == 1 ? "提现申请" : "贡献红包";
- this.withdrawType.getComponent(Label).string = "提现申请";
- this.withdrawTime.getComponent(Label).string = this.dateFormat(data.createTime * 1000);
- let color = data.value < 0 ? 'ff0000' : '238e23';
- this.money.getComponent(RichText).string = "<color=#" + color + ">¥ " + data.value / 10000 + "元</color>";
- }
- /**
- * 时间格式
- */
- public dateFormat(time: number): string {
- let dt = new Date(time);
- let y = dt.getFullYear();
- let _m = dt.getMonth() + 1;
- let m = _m < 10 ? "0" + _m : _m;
- let _d = dt.getDate();
- let d = _d < 10 ? "0" + _d : _d;
- let _h = dt.getHours();
- let h = _h < 10 ? "0" + _h : _h;
- let _minutes = dt.getMinutes();
- let minutes = _minutes < 10 ? "0" + _minutes : _minutes;
- let _s = dt.getSeconds();
- let s = _s < 10 ? "0" + _s : _s;
- return y + "年" + m + "月" + d + "日" + " " + h + "时" + minutes + "分" + s + "秒";
- }
- }
|