import TableView from "../../component/TableView"; const { ccclass, property } = cc._decorator; /** * 红包提现界面 * @author 薛鸿潇 */ @ccclass export default class RedBagCash extends cc.Component { @property({ displayName: '滚动视图', type: cc.ScrollView }) private sroll_view: cc.ScrollView = null!; @property({ displayName: '条目容器', type: cc.Node }) private node_content: cc.Node = null!; @property({ displayName: 'lbl红包数量', type: cc.Label }) private lbl_redbag: cc.Label = null!; @property({ displayName: 'lbl毛币数量', type: cc.Label }) private lbl_rmb: cc.Label = null!; private tableview: TableView = null; onLoad() { // gData.gameData.gameData.redMoney = 10200;// 测试数据,数据正确后请删除 this.tableview = this.sroll_view.getComponent('TableView'); } start() { gData.redBagCash.init_list = true; // this.initMoney(); // this.initScrollView(); } update(dt) { if (gData.redBagCash.init_list) { this.initScrollView(); this.initMoney(); } } lateUpdate() { gData.redBagCash.init_list = false; } /** * 初始化滚动视图 */ private initScrollView() { this.sroll_view.node.emit('srollview-init', gData.redBagCash.c_data); // 条目动画 this.scheduleOnce(() => { this.itemAnim(); }, 0) } private itemAnim() { let arr_node = this.node_content.children; const n_count = this.node_content.childrenCount; const start_pos = new cc.Vec2(0, -this.sroll_view.node.height); for (let i = 0; i < n_count; i++) { let node_item = arr_node[i]; const end_pos = node_item.getPosition(); node_item.y = start_pos.y; this.scheduleOnce(() => { mk.tween.move(node_item, 0.6, start_pos, end_pos, null, 'backOut'); }, i * 0.1) } } /** * 初始化货币数量 */ private initMoney() { this.lbl_redbag.string = `${gData.gameData.gameData.redMoney}`; let rmb = gData.gameData.gameData.redMoney / 10000; rmb = rmb > 1 ? Math.floor(rmb) : parseFloat(rmb.toFixed(2)); this.lbl_rmb.string = `${rmb}`; } }