import User from "../../FrameWork/User/User"; import Common5 from "../../Platform/th/Common5"; import GameBase from "../SCommon/GameBase"; import PrefabManage, { GameType } from "../PrefabManager/PrefabManage"; import ChatDialog from "./ChatDialog"; import ChatManager from "./ChatManager"; import JuQingManager from "./JuQingManager"; import { ryw_Event } from "../../FrameWork/Event/EventEnum"; import EventMgr from "../../FrameWork/Event/EventMgr"; const {ccclass, property} = cc._decorator; @ccclass export default class ChatList extends GameBase { //聊天列表 @property(cc.Node) chatListNode:cc.Node = null @property(cc.Node) chatListContent:cc.Node = null @property(cc.Node) listItem:cc.Node = null curDay = 0//当天 curChatTag = '' isChange = true initView(chatTag){ this.curChatTag = chatTag this.curDay = User.getDay() this.initListInfo() } onLoad() { super.onLoad() } protected start(): void { this.curDay = User.getDay() this.isChange = true this.initListInfo() EventMgr.onEvent_custom(ryw_Event.ExitBtnEvent,()=>{ if(cc.isValid(this.node, true)){ this.isChange = true console.log('initListInfo++++++++++++刷新') this.chatListContent.removeAllChildren() this.chatListContent.destroyAllChildren() this.initListInfo() } },this) console.log('isHaveNewMessage=========================', ChatManager.isHaveNewMessage()); this.scheduleOnce(()=>{ PrefabManage.preloadPrefabByType(GameType.ChatDialog) },0) } onDestroy(): void { super.onDestroy() } //初始化聊天列表(第几天) initListInfo(){ console.log("当前是第"+this.curDay+"天--") let allJuQingChatConfig:any = Common5.allJuQingChatConfig let nameArray = [] let tempNameTab = [] let tempChilds = [] Object.keys(allJuQingChatConfig).forEach(name => { //console.log(name) nameArray.push(name) }); let count = nameArray.length; let i = 0 this.schedule(() => { let name = nameArray[i] let personConfig = JuQingManager.getPersonJsonByJsonName(name) if(personConfig.type == 'RJB' || personConfig.type == 'DH'){ }else{ let personJson = ChatManager.getPersonConfig(name) let recordData = ChatManager.getChatRecordDataByJson(name) //console.log(recordData,'recordData+++++++++++++===') if(recordData && recordData.length > 0){ //duihuaArray.push[] let childItem = cc.instantiate(this.listItem) let nameStr = ChatManager.getNameByJson(name) childItem.getChildByName("nameStr").getComponent(cc.Label).string = nameStr tempNameTab.push(nameStr) let chatPerson = ChatManager.getConfigByJsonName(name) Common5.addUrlSprite_custom("head/"+chatPerson.imgPath, childItem.getChildByName("avatar").getComponent(cc.Sprite)); let itemInfo = this.getListItemStr(name,personJson,recordData,childItem.getChildByName("flag")) let contentStr = itemInfo.contentDesc let indexStr = itemInfo.indexStr if(contentStr.length > 14){ contentStr = contentStr.substr(0, 14) + "..." } childItem.getChildByName("contentStr").getComponent(cc.Label).string = contentStr childItem.attr({jsonName:name,playInfo:allJuQingChatConfig[name],indexStr:indexStr}) childItem.active = true let isFinish = true for(let rei = 0;rei0){ let idexz = 0 for(let i = 0;i{ prefabNode.getComponent(ChatDialog).enterDialog(event.target.jsonName,null,()=>{ this.initListInfo() }) }) } //显示列表的显示内容 getListItemStr(jsonName,personJson,recordData,flagNode){ let indexStr = '' //优先显示未完成对话的第一条 for(let i=0;i=0;k--){ if(personJson[k].indexStr == indexStr){ flagNode.active = false return {contentDesc:personJson[k].contentDesc,indexStr:indexStr} } } PrefabManage.showTextTips('这里没获取到内容?'+jsonName) flagNode.active = false return {contentDesc:"",indexStr:""} } }