RedCodeListPanel.ts 3.8 KB

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