123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- var UserInformationApi = require('../net/UserInformationApi');
- var {UserInformationType} = require('../utils/GameEnum');
- var TimelineItem = require("UserInformationTimelineItem");
- cc.Class({
- extends: cc.Component,
- properties: {
- emptyNode: cc.Node,
- scrollViewNode: cc.ScrollView,
- timelinePrefab: cc.Prefab,
- itemArray: [TimelineItem],
- },
-
- init() {
- },
- onLoad () {
- },
- onDisable() {
- for (let item of this.itemArray) {
- item.node.active = false;
- }
- this.scrollViewNode.scrollToTop();
- this.emptyNode.active = false;
- },
- start () {
- },
- loadUserTimeline(uid) {
- this.uid = uid;
- this.getNetworkData();
- },
-
- getNetworkData() {
- UserInformationApi.getTimelineList(this.uid, (responseData)=> {
-
- this.configData(responseData);
- }, (error) => {
- console.log('error' + error);
- this.loadDataError();
- });
- },
- configData(responseData) {
- for (let item of this.itemArray) {
- item.node.active = false;
- }
- this.dataList = responseData.list;
- if (this.dataList == undefined || this.dataList.length == 0) {
- this.emptyNode.active = true;
- this.scrollViewNode.node.active = false;
- } else {
- this.emptyNode.active = false;
- this.scrollViewNode.node.active = true;
- this.loadItemData()
- }
- },
- loadDataError() {
- for (let item of this.itemArray) {
- item.node.active = false;
- }
- this.emptyNode.active = true;
- this.scrollViewNode.node.active = false;
- },
- loadItemData() {
- for (var i = 0; i < this.dataList.length; i++) {
- let item = null;
- if (this.itemArray[i]) {
- item = this.itemArray[i];
- item.node.active = true;
- } else {
- item = cc.instantiate(this.timelinePrefab);
- item = item.getComponent('UserInformationTimelineItem');
- item.node.parent = this.scrollViewNode.content;
- this.itemArray.push(item);
- }
- let itemModel = this.dataList[i];
- item.configData(itemModel);
- }
- }
-
- });
|