FamilyMemberItem.ts 673 B

123456789101112131415161718192021
  1. import { _decorator, Component, Node } from "cc";
  2. import BaseUI from "../../scripts/base/BaseUI";
  3. import Utils from "../../scripts/utils/Utils";
  4. import { FamilyMember } from "../../scripts/api/FamilyM";
  5. const { ccclass, property } = _decorator;
  6. @ccclass("FamilyMemberItem")
  7. export class FamilyMemberItem extends BaseUI {
  8. init(pd: FamilyMember) {
  9. this.setText("lbl_user_name", pd.userName);
  10. let totalXp = pd.totalXp;
  11. if (totalXp < pd.dailyXp) {
  12. totalXp = pd.dailyXp;
  13. }
  14. let expStr = `today:${Utils.formatNumber(
  15. Number(pd.dailyXp),
  16. 1
  17. )} total:${Utils.formatNumber(Number(totalXp), 1)}`;
  18. this.setText("lbl_exp", expStr);
  19. }
  20. }