MoneySaveItem.ts 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. init(data, tixian, callback: Function, index) {
  24. this.callback = callback
  25. this.tixian = tixian
  26. this.data = data
  27. this.labAdd.string = (this.data.amount * 0.01).toFixed(2) + ""
  28. this.yuanlabel.string = "元"
  29. let cashTypeDes = '';
  30. switch (this.data.cashType) {
  31. case 1:
  32. cashTypeDes = '常规提现';
  33. break;
  34. case 10:
  35. cashTypeDes = '福袋提现';
  36. break;
  37. case 11:
  38. cashTypeDes = '视频红包提现';
  39. break;
  40. case 12:
  41. cashTypeDes = '金猪币提现';
  42. break;
  43. case 13:
  44. cashTypeDes = '现金提现';
  45. break;
  46. default:
  47. cashTypeDes = '';
  48. break;
  49. }
  50. this.sourceType.string = cashTypeDes;
  51. this.sourceType.node.parent.active = true;
  52. if (cashTypeDes == '') {
  53. this.sourceType.node.parent.active = false;
  54. }
  55. // if (this.data.cashType == 1) {
  56. // this.sourceType.node.parent.active = true
  57. // } else if (this.data.cashType == 2) {
  58. // this.sourceType.string = "每日提现"
  59. // } else {
  60. // this.sourceType.node.parent.active = false
  61. // }
  62. let x = this.node.x
  63. this.node.y = - this.node.height * 0.5 * 1.5
  64. this.node.getChildByName("Hand").active = false
  65. if (index == 1) {
  66. this.node.y = -200
  67. if (!tixian) {
  68. this.node.getChildByName("Hand").active = true
  69. }
  70. this.node.position = this.nodePos[0]
  71. } else if (index == 2) {
  72. // this.node.y = 0
  73. this.node.position = this.nodePos[1]
  74. } else if (index == 3) {
  75. // this.node.y = -200
  76. this.node.position = this.nodePos[2]
  77. } else {
  78. this.node.position = this.nodePos[3]
  79. }
  80. let y = this.node.y
  81. mk.console.logSingle("moneySaveItem", x + " : " + y)
  82. let delayTime = Math.random()
  83. this.scheduleOnce(() => {
  84. 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)))))
  85. }, delayTime)
  86. }
  87. cool = false;
  88. clickAdd() {
  89. if (this.cool) {
  90. return
  91. }
  92. this.cool = true;
  93. this.scheduleOnce(() => {
  94. this.cool = false;
  95. }, 2)
  96. this.unscheduleAllCallbacks()
  97. this.node.getChildByName("Hand").active = false
  98. if (this.callback) {
  99. this.callback(this.data, this.node)
  100. }
  101. }
  102. }