RedCodeNode.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /** 红包码界面 */
  2. import { HTTP_TYPE, RecordTYPE } from "../datas/CommonData";
  3. import { TuCaoData } from "../datas/TuCaoData";
  4. import GameM, { AUDIO_TYPE } from "../manager/GameM";
  5. import UiM, { PANEL_NAME } from "../manager/UiM";
  6. import RedCodeItem from "../prefabs/RedCodeItem";
  7. import LogUtil from "../utils/LogUtil";
  8. import { Utils } from "../utils/Utils";
  9. import CashOut from "./CashOut";
  10. const { ccclass, property } = cc._decorator;
  11. @ccclass
  12. export default class RedCodeNode extends cc.Component {
  13. @property(cc.Node)
  14. content: cc.Node = null;
  15. @property(cc.Node)
  16. labEmpty: cc.Node = null;
  17. @property(cc.Node)
  18. parNode: cc.Node = null;
  19. cashType = 0
  20. itemP = null
  21. async onLoad() {
  22. this.itemP = await Utils.loadResPromise('prefabs/RedCodeItem')
  23. }
  24. /** 初始化
  25. * @param cashType 1、常规提现 2、每日提现 3、夺宝提现 4、富翁提现 50、裂变提现 60、看视频领红包提现*/
  26. init(cashType) {
  27. this.cashType = cashType
  28. this.content.removeAllChildren()
  29. if (this.cashType == 50) {
  30. GameM.ClubData.requestClubWithDrawRecords()
  31. }
  32. else if (this.cashType == 60) {
  33. this.freshRecord();
  34. }
  35. else {
  36. GameM.httpM.sendDatas(HTTP_TYPE.getCashRecord, null, GameM.commonData.resultCashRecord.bind(GameM.commonData))
  37. }
  38. }
  39. freshRecord() {
  40. let arr = []
  41. if (this.cashType == 50) {
  42. arr = GameM.ClubData.getRedCodeByClubCashType()
  43. } else if (this.cashType == 60) {
  44. arr = TuCaoData.Ins.videoRbData.redMoneyCode;
  45. } else {
  46. arr = GameM.commonData.getRedCodeByCashType(this.cashType)
  47. }
  48. for (var i = 0; i < arr.length; i++) {
  49. let item: cc.Node = cc.instantiate(this.itemP)
  50. let s = item.getComponent(RedCodeItem)
  51. let data = arr[i]
  52. if (this.cashType == 50) {
  53. let createTime: string = data.createTime
  54. LogUtil.logV(" createTime", createTime)
  55. let spliteStr = createTime.split(" ")
  56. s.init((data.amount * 0.0001).toFixed(2), spliteStr[0], data.withdrawCode, this.cashType)
  57. }
  58. else if (this.cashType == 60) {
  59. s.init(data.VideoCashBig, data.applyTime, data.RedMoneyCode);
  60. }
  61. else {
  62. s.init((data.amount * 0.01).toFixed(2), data.applyTime, data.withdrawalCode)
  63. }
  64. this.content.addChild(item)
  65. }
  66. if (arr.length <= 0) {
  67. this.labEmpty.active = true
  68. }
  69. else {
  70. this.labEmpty.active = false
  71. }
  72. }
  73. clickClose() {
  74. GameM.audioM.playEffect(AUDIO_TYPE.button)
  75. if (this.cashType == 1) {
  76. this.hideEff()
  77. }
  78. else {
  79. UiM.Instance.offPanel(PANEL_NAME.RedCodeNode)
  80. }
  81. }
  82. hideEff() {
  83. let pos = UiM.Instance.cashNode.getComponent(CashOut).labRedCode.position
  84. let addy = (cc.winSize.height - 1334) / 2
  85. pos.y += addy
  86. cc.tween(this.parNode).to(0.2, { scale: 0, position: pos }).call(() => {
  87. UiM.Instance.offPanel(PANEL_NAME.RedCodeNode)
  88. }).start();
  89. }
  90. }