| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- /** 提现记录界面 */
- import { HTTP_TYPE } from "../datas/CommonData";
- import GameM, { AUDIO_TYPE } from "../manager/GameM";
- import UiM, { PANEL_NAME } from "../manager/UiM";
- import RecordItem from "../prefabs/RecordItem";
- import LogUtil from "../utils/LogUtil";
- import { Utils } from "../utils/Utils";
- const { ccclass, property } = cc._decorator;
- @ccclass
- export default class CashRecordNode extends cc.Component {
- @property(cc.Node)
- recordContent: cc.Node = null;
- @property(cc.Node)
- recordSview: cc.Node = null;
- itemP = null
- //分帧加载
- addNum = 0
- addTotal = 0
- _n = 0
- _dis = 5
- private disY = 0
- private lastY = 0
- /**提现记录类型 1:俱乐部提现*/
- private type = 0
- async onLoad() {
- this.node.height = cc.winSize.height
- this.addNum = 0
- this.addTotal = 0
- this.itemP = await Utils.loadResPromise('prefabs/RecordItem')
- this.recordSview.height += (cc.winSize.height - 1334)
- this.recordContent.parent.height += (cc.winSize.height - 1334)
- }
- initType(type = 0) {
- this.type = type
- this.recordContent.removeAllChildren()
- if (this.type == 1) {
- GameM.ClubData.requestClubWithDrawRecords()
- }
- if (GameM.commonData.isAuth && this.type != 1) {
- LogUtil.logV('BBBB ', " getCashRecord")
- GameM.httpM.sendDatas(HTTP_TYPE.getCashRecord, null, GameM.commonData.resultCashRecord.bind(GameM.commonData))
- }
- }
- // onEnable() {
- // this.recordContent.removeAllChildren()
- // if (GameM.commonData.isAuth) {
- // GameM.httpM.sendDatas(HTTP_TYPE.getCashRecord, {})
- // }
- // }
- freshRecord() {
- if (this.type == 1) {
- this.addTotal = GameM.ClubData.clubCashRecord.length
- } else {
- this.addTotal = GameM.commonData.cashRecord.length
- LogUtil.logV('BBBB GameM.ClubData.cashRecord ', GameM.ClubData.cashRecord)
- }
- this.addNum = 0
- }
- update(dt) {
- if (this.addNum < this.addTotal) {
- if (this._n <= this._dis) {
- this._n++
- }
- else {
- this._n = 0
- let item: cc.Node = cc.instantiate(this.itemP)
- item.name = this.addNum.toString()
- let s = item.getComponent(RecordItem)
- let data = null
- if (this.type == 1) {
- data = GameM.ClubData.clubCashRecord[this.addNum]
- let cashMode = 0
- if (typeof data.withdrawCode === 'string' && data.withdrawCode != "" && data.withdrawCode != "null") {
- cashMode = 2
- }
- LogUtil.logV("typeof data.withdrawCode ", typeof data.withdrawCode)
- LogUtil.logV("ClubCashRecordNode cashMode", cashMode + " withdrawalCode:" + data.withdrawCode)
- let createTime: string = data.createTime
- let spliteStr = createTime.split(" ")
- let timeStr = ""
- if (spliteStr.length > 0) {
- timeStr = spliteStr[0]
- } else {
- timeStr = createTime
- }
- s.init(data.applyType, spliteStr[0], (data.amount * 0.0001).toFixed(2), (data.currentBalance * 0.0001).toFixed(2), cashMode, data.withdrawCode, true)
- } else {
- data = GameM.commonData.cashRecord[this.addNum]
- LogUtil.logV("cashType ", data.cashType)
- s.init(data.cashType, data.applyTime, (data.amount * 0.01).toFixed(2), (data.remain * 0.0001).toFixed(2), data.CashMode, data.withdrawalCode)
- }
- // to do
- this.disY = item.height + 2
- item.y = - item.height * 0.5 - this.disY * this.addNum
- this.recordContent.addChild(item)
- this.checkVisible(item)
- this.recordContent.height = this.addTotal * this.disY
- this.addNum++
- }
- }
- this.onScroll()
- }
- onScroll() {
- if (Math.abs(this.recordContent.y - this.lastY) >= this.disY) {
- this.lastY = this.recordContent.y
- this.recordContent.children.forEach(element => {
- this.checkVisible(element)
- });
- }
- }
- checkVisible(item: cc.Node) {
- let disy = item.y + this.recordContent.y
- if (disy >= 45 + this.disY || disy <= -this.recordSview.height - 45 - this.disY) {
- item.active = false
- }
- else {
- item.active = true
- }
- }
- clickClose() {
- GameM.audioM.playEffect(AUDIO_TYPE.button)
- UiM.Instance.offPanel(PANEL_NAME.CashRecordNode, true)
- }
- }
|