MoneySaveItem.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. const { ccclass, property } = cc._decorator;
  2. @ccclass
  3. export default class MoneySaveItem extends cc.Component {
  4. @property(cc.Label)
  5. labDes: cc.Label = null;
  6. @property(cc.Label)
  7. labTime: cc.Label = null;
  8. @property(cc.Label)
  9. labAdd: cc.Label = null;
  10. @property(cc.Label)
  11. labelTotal: cc.Label = null;
  12. @property(cc.Node)
  13. readyTixianBtn: cc.Node = null;
  14. @property(cc.Label)
  15. sourceType: cc.Label = null;
  16. @property(cc.Label)
  17. yuanlabel: cc.Label = null;
  18. num: number
  19. tixian: boolean
  20. data: any
  21. callback: Function = null
  22. nodePos = [cc.v3(54, -63), cc.v3(313, 57), cc.v3(572, -67), cc.v3(862, -67)]
  23. hasClick = false;
  24. init(data, tixian, callback: Function, index) {
  25. if (this.hasClick) {
  26. return
  27. }
  28. this.hasClick = true;
  29. this.callback = callback
  30. this.tixian = tixian
  31. this.data = data
  32. this.labAdd.string = (this.data.amount * 0.01).toFixed(2) + ""
  33. this.yuanlabel.string = "元"
  34. let cashTypeDes = '';
  35. // switch (this.data.cashType) {
  36. // case 1:
  37. // cashTypeDes = '常规提现';
  38. // break;
  39. // case 10:
  40. // cashTypeDes = '福袋提现';
  41. // break;
  42. // case 11:
  43. // cashTypeDes = '视频红包提现';
  44. // break;
  45. // case 12:
  46. // cashTypeDes = '金猪币提现';
  47. // break;
  48. // case 13:
  49. // cashTypeDes = '现金提现';
  50. // break;
  51. // default:
  52. // cashTypeDes = '';
  53. // break;
  54. // }
  55. this.sourceType.string = cashTypeDes;
  56. this.sourceType.node.parent.active = true;
  57. if (cashTypeDes == '') {
  58. this.sourceType.node.parent.active = false;
  59. }
  60. // if (this.data.cashType == 1) {
  61. // this.sourceType.node.parent.active = true
  62. // } else if (this.data.cashType == 2) {
  63. // this.sourceType.string = "每日提现"
  64. // } else {
  65. // this.sourceType.node.parent.active = false
  66. // }
  67. let x = this.node.x
  68. this.node.y = - this.node.height * 0.5 * 1.5
  69. this.node.getChildByName("Hand").active = false
  70. if (index == 1) {
  71. this.node.y = -200
  72. if (!tixian) {
  73. this.node.getChildByName("Hand").active = true
  74. }
  75. this.node.position = this.nodePos[0]
  76. } else if (index == 2) {
  77. // this.node.y = 0
  78. this.node.position = this.nodePos[1]
  79. } else if (index == 3) {
  80. // this.node.y = -200
  81. this.node.position = this.nodePos[2]
  82. } else {
  83. this.node.position = this.nodePos[3]
  84. }
  85. let y = this.node.y
  86. mk.console.logSingle("moneySaveItem", x + " : " + y)
  87. let delayTime = Math.random()
  88. this.scheduleOnce(() => {
  89. this.node.runAction(cc.repeatForever(cc.sequence(cc.moveTo(1.5, cc.v2(this.node.x, y - 5)), cc.moveTo(1.2, cc.v2(this.node.x, this.node.y + 5)))))
  90. }, delayTime)
  91. }
  92. cool = false;
  93. clickAdd() {
  94. if (this.cool) {
  95. return
  96. }
  97. this.cool = true;
  98. this.scheduleOnce(() => {
  99. this.cool = false;
  100. }, 2)
  101. this.unscheduleAllCallbacks()
  102. this.node.getChildByName("Hand").active = false
  103. if (this.callback) {
  104. this.callback(this.data, this.node)
  105. this.hasClick = false;
  106. }
  107. }
  108. }