RedBagCodeItem.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import JsbSystem from "../../../mk/system/JsbSystem";
  2. import { TCashList } from "../../data/module/CashNormalData";
  3. const { ccclass, property } = cc._decorator;
  4. /**
  5. * 红包码条目
  6. * @author 薛鸿潇
  7. */
  8. @ccclass
  9. export default class RedBagCodeItem extends cc.Component {
  10. @property({ displayName: 'lbl红包码', type: cc.Label })
  11. private lbl_code: cc.Label = null;
  12. @property({ displayName: 'lbl时间', type: cc.Label })
  13. private lbl_time: cc.Label = null;
  14. @property({ displayName: 'lbl毛币', type: cc.Label })
  15. private lbl_rmb: cc.Label = null;
  16. private item_data: TCashList = null;
  17. /**
  18. * 初始化数据
  19. */
  20. public async setItemData(item_data) {
  21. await this.initItem(item_data);
  22. }
  23. /**
  24. * 初始化样式
  25. */
  26. private initItem(item_data: TCashList) {
  27. this.item_data = item_data;
  28. this.lbl_rmb.string = ((item_data.amount / 100).toFixed(2)) + '元';
  29. this.lbl_time.string = mk.time.getNowDayString(item_data.applyTime * 1000);
  30. this.lbl_code.string = item_data.withdrawalCode ? '红包码:' + item_data.withdrawalCode : '';
  31. }
  32. /**
  33. * 复制按钮
  34. */
  35. private clickCopy() {
  36. JsbSystem.setClipboard(this.item_data.withdrawalCode)
  37. mk.tip.pop('复制成功')
  38. }
  39. // update (dt) {}
  40. }