BRABRecords.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. let Global = require("Global");
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. },
  6. onLoad() {
  7. this.initData();
  8. this.initButton();
  9. },
  10. onEnable() {
  11. this.initContent();
  12. },
  13. setRecordData(data) {
  14. this.RecordData = data;
  15. },
  16. initData() {
  17. // this.RecordData = [
  18. // [[], [], new Date(), 0],
  19. // [[], [], new Date(), 0]
  20. // ];
  21. this.RecordDataIndex = 0;
  22. this.prefab_history = UIHelper.pathGetNode(this.node, "prefab_history");
  23. this.content = UIHelper.pathGetNode(this.node, "scrollView/view/content");
  24. this.button_close = UIHelper.pathGetNode(this.node, "sprite_bg/button_close");
  25. },
  26. initButton() {
  27. UIHelper.addButtonListener(this.button_close, this.node, "BRABRecords", "closeNode");
  28. },
  29. initContent() {
  30. for (let i = this.RecordDataIndex; i < this.RecordData.length; i += 1) {
  31. this.RecordDataIndex += 1
  32. let data = this.RecordData[i];
  33. let arr1 = data[0];
  34. let arr2 = data[1];
  35. let data3 = data[3];
  36. if (data3 == undefined) {
  37. this.RecordDataIndex -= 1;
  38. break;
  39. } else if (arr1.length > 0 || arr2.length > 0) {
  40. let data1 = arr1.length > 0 ? arr1.reduce((a, b) => { return a + b; }) : 0;
  41. let data2 = arr2.length > 0 ? arr2.reduce((a, b) => { return a + b; }) : 0;
  42. let time = data[2];
  43. let node = cc.instantiate(this.prefab_history);
  44. let label_ymdHistory = node.getChildByName("label_ymdHistory").getComponent(cc.Label);
  45. let label_hmsHistory = node.getChildByName("label_hmsHistory").getComponent(cc.Label);
  46. let label_bet1History = node.getChildByName("label_bet1History").getComponent(cc.Label);
  47. let label_bet2History = node.getChildByName("label_bet2History").getComponent(cc.Label);
  48. let label_wolHistory = node.getChildByName("label_wolHistory").getComponent(cc.Label);
  49. label_ymdHistory.string = Global.formatDateYMD(time);
  50. label_hmsHistory.string = Global.formatDateHMS(time);
  51. label_bet1History.string = data1;
  52. label_bet2History.string = data2;
  53. label_wolHistory.string = data3;
  54. node.active = true;
  55. node.parent = this.content;
  56. }
  57. }
  58. },
  59. closeNode() {
  60. this.node.active = false;
  61. },
  62. });