BankQipaoTip.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import CommonData, { HTTP_TYPE } from "../datas/CommonData";
  2. import GameM from "../manager/GameM";
  3. import UiM from "../manager/UiM";
  4. import LogUtil from "../utils/LogUtil";
  5. import { Utils } from "../utils/Utils";
  6. const { ccclass, property } = cc._decorator;
  7. @ccclass
  8. export default class BankQipaoTip extends cc.Component {
  9. // LIFE-CYCLE CALLBACKS:
  10. private itemP: cc.Prefab = null
  11. onLoad() {
  12. LogUtil.logV("BankQipaoTip", "onLoad()")
  13. GameM.httpM.sendDatas(HTTP_TYPE.bankCashRecord, null, GameM.commonData.updateBankPacket.bind(GameM.commonData))
  14. // }
  15. // let packet = [{
  16. // "amount": 30,
  17. // "isSaveBank": 0,
  18. // "partnerTradeNo": "a",
  19. // "cashType": 1
  20. // },{
  21. // "amount": 500,
  22. // "isSaveBank": 0,
  23. // "partnerTradeNo": "a",
  24. // "cashType": 1
  25. // },{
  26. // "amount": 600,
  27. // "isSaveBank": 0,
  28. // "partnerTradeNo": "a",
  29. // "cashType": 1
  30. // }]
  31. // this.showAlreadyMoney(packet)
  32. }
  33. start() {
  34. LogUtil.logV("BankQipaoTip", "start()")
  35. }
  36. showAlreadyMoney(data) {
  37. LogUtil.logV("BankQipaoTip", "showAlreadyMoney()")
  38. this.unscheduleAllCallbacks()
  39. this.node.stopAllActions()
  40. this.node.skewX = 0
  41. this.node.skewY = 0
  42. this.node.active = true
  43. if (GameM.commonData.currentRichBankCashTaskIndex > 0) {
  44. this.node.getChildByName("tixianNode").active = true
  45. this.node.getChildByName("qipaoBg").active = false
  46. this.node.getChildByName("tipLabel").active = false
  47. this.node.getChildByName("moneyLabel").active = false
  48. let lable = this.node.getChildByName("tixianNode").getChildByName("animlabel").getComponent(cc.Label)
  49. let index = 0
  50. this.schedule(() => {
  51. if (cc.isValid(lable)) {
  52. if (index == 0) {
  53. lable.string = "。"
  54. index = 1
  55. } else if (index == 1) {
  56. lable.string = "。。"
  57. index = 2
  58. } else if (index == 2) {
  59. lable.string = "。。。"
  60. index = 0
  61. }
  62. }
  63. }, 1)
  64. return
  65. }
  66. if (data == null || data == undefined) {
  67. this.node.getChildByName("qipaoBg").active = false
  68. this.node.getChildByName("tipLabel").active = false
  69. this.node.getChildByName("moneyLabel").active = false
  70. this.node.getChildByName("tixianNode").active = false
  71. return
  72. }
  73. if (!(data.length > 0)) {
  74. this.node.getChildByName("qipaoBg").active = false
  75. this.node.getChildByName("tipLabel").active = false
  76. this.node.getChildByName("moneyLabel").active = false
  77. this.node.getChildByName("tixianNode").active = false
  78. return
  79. }
  80. let money = 0
  81. for (let entry of data) {
  82. money += entry.amount
  83. }
  84. this.node.getChildByName("qipaoBg").active = true
  85. this.node.getChildByName("tipLabel").active = true
  86. this.node.getChildByName("moneyLabel").active = true
  87. this.node.getChildByName("tixianNode").active = false
  88. this.node.getChildByName("moneyLabel").getComponent(cc.Label).string = (money * 0.01).toFixed(2) + "元"
  89. let action =
  90. cc.sequence(
  91. cc.skewTo(0.125, 18.6, -18.6),
  92. cc.skewTo(0.125, 0, 0),
  93. cc.skewTo(0.125, -18.6, +18.6),
  94. cc.skewTo(0.125, 18.6, -18.6),
  95. cc.skewTo(0.125, 0, 0),
  96. cc.skewTo(0.125, -18.6, +18.6),
  97. cc.skewTo(0.125, 18.6, -18.6),
  98. cc.skewTo(0.125, 0, 0),
  99. cc.skewTo(0.125, -18.6, +18.6),
  100. cc.skewTo(0.125, 0, 0)
  101. )
  102. this.node.runAction(cc.repeatForever(cc.sequence(action, cc.delayTime(5))))
  103. }
  104. async creatPacketAnim(type: number) {
  105. this.itemP = await Utils.loadResPromise('prefabs/MoneySaveItem')
  106. let node = cc.instantiate(this.itemP)
  107. node.parent = cc.find("Canvas")
  108. node.scale = 1
  109. if (type == 1) {
  110. node.position = cc.find("Canvas").convertToNodeSpaceAR(this.node.convertToWorldSpaceAR(cc.v3(-145, 337)))
  111. } else {
  112. node.position = cc.find("Canvas").convertToNodeSpaceAR(this.node.convertToWorldSpaceAR(cc.v3(0, -324)))
  113. }
  114. let targetPos = cc.find("Canvas").convertToNodeSpaceAR(this.node.convertToWorldSpaceAR(cc.v3(0, -92)))
  115. node.runAction(cc.sequence(cc.spawn(cc.moveTo(1, cc.v2(targetPos)), cc.scaleTo(1, 0.4)), cc.callFunc(() => {
  116. node.destroy()
  117. })))
  118. }
  119. clickPacket() {
  120. this.creatPacketAnim(Math.random() - 0.5 > 0 ? 1 : 2)
  121. }
  122. // update (dt) {}
  123. }