RankList.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const ListAdapter = require('../friendlist/ListViewAdapter');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. scrollView: cc.ScrollView,
  6. content: cc.Node,
  7. tipLabel: cc.Label,
  8. item: cc.Prefab,
  9. itemScriptName: 'RankItem',
  10. myItem: cc.Node,
  11. },
  12. onLoad() {
  13. this.listAdapter = new ListAdapter(this.scrollView);
  14. this.setLoading();
  15. },
  16. bindData(data) {
  17. this.myItem.getComponent(this.itemScriptName)._bindData(data.me);
  18. if (data.ranks) {
  19. // this.listAdapter.updateItems(data.ranks, this.item, this.itemScriptName);
  20. data.ranks.forEach(dataItem => {
  21. let child = cc.instantiate(this.item);
  22. this.content.addChild(child);
  23. child.getComponent(this.itemScriptName).updateItem(dataItem, 0);
  24. });
  25. this.content.active = true;
  26. this.tipLabel.node.active = false;
  27. } else {
  28. this.content.active = false;
  29. this.tipLabel.node.active = true;
  30. this.tipLabel.string = "暂无数据";
  31. }
  32. },
  33. networkError(error) {
  34. console.log(error);
  35. this.tipLabel.node.active = true;
  36. this.tipLabel.string = '网络错误';
  37. this.content.active = false;
  38. },
  39. setLoading() {
  40. this.content.active = false;
  41. this.tipLabel.node.active = true;
  42. this.tipLabel.string = "加载中...";
  43. },
  44. update(dt) {
  45. // this.listAdapter.update(dt);
  46. },
  47. onScrollEvent() {
  48. // this.listAdapter.update();
  49. },
  50. });