RecordItem.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import { RecordTYPE } from "../datas/CommonData";
  8. import AdM from "../manager/AdM";
  9. import GameM, { AUDIO_TYPE } from "../manager/GameM";
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class RecordItem extends cc.Component {
  13. @property(cc.Label)
  14. labDes: cc.Label = null;
  15. @property(cc.Label)
  16. labTime: cc.Label = null;
  17. @property(cc.Label)
  18. labAdd: cc.Label = null;
  19. @property(cc.Label)
  20. labTotal: cc.Label = null;
  21. @property(cc.Node)
  22. redCodeNode: cc.Node = null;
  23. @property(cc.Label)
  24. labRedCode: cc.Label = null;
  25. type: RecordTYPE
  26. date: number
  27. num: number
  28. code = ''
  29. // LIFE-CYCLE CALLBACKS:
  30. // onLoad () {}
  31. start() {
  32. }
  33. init(type, date, num, total, CashMode = 1, withdrawalCode = '', clubType = false) {
  34. this.type = type
  35. this.date = date
  36. this.num = num
  37. if (clubType) {
  38. this.labDes.string = GameM.ClubData.clubRecordAwardTypeArr[this.type - 1]
  39. } else {
  40. if (type == -1) {
  41. this.labDes.string = '微信提现'
  42. }
  43. else {
  44. this.labDes.string = GameM.commonData.recordAwardTypeArr[this.type]
  45. }
  46. }
  47. if (clubType) {
  48. this.labTime.string = date + ""
  49. if (type == 3) {
  50. this.labTotal.string = ""
  51. } else {
  52. this.labTotal.string = `余额 ${total}`
  53. }
  54. } else {
  55. let tdate = new Date(this.date * 1000)
  56. this.labTime.string = tdate.getFullYear() + '-' + (tdate.getMonth() + 1) + '-' + tdate.getDate()
  57. this.labTotal.string = `余额 ${total}`
  58. }
  59. if (this.num > 0) {
  60. this.labAdd.string = `+${this.num}`
  61. }
  62. else {
  63. this.labAdd.string = this.num.toString()
  64. }
  65. if (CashMode == 2) {
  66. this.code = withdrawalCode
  67. this.labRedCode.string = `红包码:${this.code}`
  68. this.redCodeNode.active = true
  69. }
  70. else {
  71. this.redCodeNode.active = false
  72. }
  73. }
  74. /** 点击复制红包码 */
  75. clickCopyRedCode() {
  76. GameM.audioM.playEffect(AUDIO_TYPE.button)
  77. AdM.setClipboard(this.code)
  78. }
  79. // update (dt) {}
  80. }