123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- let Global = require("Global");
- cc.Class({
- extends: cc.Component,
- properties: {
- },
- onLoad() {
- this.initData();
- this.initButton();
- },
- onEnable() {
- this.initContent();
- },
- setRecordData(data) {
- this.RecordData = data;
- },
- initData() {
- // this.RecordData = [
- // [[], [], new Date(), 0],
- // [[], [], new Date(), 0]
- // ];
- this.RecordDataIndex = 0;
- this.prefab_history = UIHelper.pathGetNode(this.node, "prefab_history");
- this.content = UIHelper.pathGetNode(this.node, "scrollView/view/content");
- this.button_close = UIHelper.pathGetNode(this.node, "sprite_bg/button_close");
- },
- initButton() {
- UIHelper.addButtonListener(this.button_close, this.node, "BRABRecords", "closeNode");
- },
- initContent() {
- for (let i = this.RecordDataIndex; i < this.RecordData.length; i += 1) {
- this.RecordDataIndex += 1
- let data = this.RecordData[i];
- let arr1 = data[0];
- let arr2 = data[1];
- let data3 = data[3];
- if (data3 == undefined) {
- this.RecordDataIndex -= 1;
- break;
- } else if (arr1.length > 0 || arr2.length > 0) {
- let data1 = arr1.length > 0 ? arr1.reduce((a, b) => { return a + b; }) : 0;
- let data2 = arr2.length > 0 ? arr2.reduce((a, b) => { return a + b; }) : 0;
- let time = data[2];
- let node = cc.instantiate(this.prefab_history);
- let label_ymdHistory = node.getChildByName("label_ymdHistory").getComponent(cc.Label);
- let label_hmsHistory = node.getChildByName("label_hmsHistory").getComponent(cc.Label);
- let label_bet1History = node.getChildByName("label_bet1History").getComponent(cc.Label);
- let label_bet2History = node.getChildByName("label_bet2History").getComponent(cc.Label);
- let label_wolHistory = node.getChildByName("label_wolHistory").getComponent(cc.Label);
- label_ymdHistory.string = Global.formatDateYMD(time);
- label_hmsHistory.string = Global.formatDateHMS(time);
- label_bet1History.string = data1;
- label_bet2History.string = data2;
- label_wolHistory.string = data3;
- node.active = true;
- node.parent = this.content;
- }
- }
- },
- closeNode() {
- this.node.active = false;
- },
- });
|