RedCodeItem.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /** 红包码item */
  2. import { RecordTYPE } from "../datas/CommonData";
  3. import AdM from "../manager/AdM";
  4. import GameM, { AUDIO_TYPE } from "../manager/GameM";
  5. const { ccclass, property } = cc._decorator;
  6. @ccclass
  7. export default class RedCodeItem extends cc.Component {
  8. @property(cc.Label)
  9. labMoney: cc.Label = null;
  10. @property(cc.Label)
  11. labTime: cc.Label = null;
  12. @property(cc.Label)
  13. labRedCode: cc.Label = null;
  14. date: number
  15. code = ''
  16. start() {
  17. }
  18. /**
  19. *
  20. * @param money 金额
  21. * @param date 日期
  22. * @param withdrawalCode 红包码
  23. * @param cashType 提现类型,主要区分是否是裂变
  24. */
  25. init(money, date, withdrawalCode, cashType = 0) {
  26. this.date = date
  27. this.code = withdrawalCode
  28. if (cashType == 50) {
  29. this.labTime.string = date
  30. } else {
  31. let tdate = new Date(this.date * 1000)
  32. this.labTime.string = tdate.getFullYear() + '-' + (tdate.getMonth() + 1) + '-' + tdate.getDate()
  33. }
  34. this.labMoney.string = `金额:${money}元`
  35. this.labRedCode.string = `红包码:${this.code}`
  36. }
  37. /** 点击复制红包码 */
  38. clickCopyRedCode() {
  39. GameM.audioM.playEffect(AUDIO_TYPE.button)
  40. AdM.setClipboard(this.code)
  41. }
  42. }