/// <summary> /// 增加客服上报数据 /// </summary> public void AddQuestion(QuestionsReplyInfo _info) { if (!questionList.ContainsKey(_info.ID)) { questionList[_info.ID] = _info; } else { Debug.LogError("ID=" + _info.ID + "的客服数据唯一ID重复"); } }
void OnEnable() { if (questionTitil != null) { questionTitil.value = string.Empty; } if (questionDes != null) { questionDes.value = string.Empty; } if (questionSubmit != null) { UIEventListener.Get(questionSubmit.gameObject).onClick = delegate { for (int i = 0; i < questiontypes.Length; i++) { if (questiontypes[i] != null) { UIToggle tog = questiontypes[i].GetComponent <UIToggle>(); if (tog != null && tog.value) { QuestionsReplyInfo questionInfo = new QuestionsReplyInfo(questionTitil.value, questionDes.value, i + 1); if (GameCenter.mainPlayerMng.OnQuestionsReplyRequest != null) { GameCenter.mainPlayerMng.OnQuestionsReplyRequest(questionInfo); } return; } } } }; } Show(); if (games != null) { games.SetActive(false); } }
void Show() { if (info == null) { return; } if (games != null) { games.SetActive(true); } if (time != null) { time.text = info.Time; } if (titil != null) { titil.text = info.Titil; } if (des != null) { des.text = info.Des; } if (replyDes != null) { replyDes.text = info.ReplyDes; } if (typeDes != null) { typeDes.text = info.Type >= typeLabs.Length ? string.Empty : typeLabs[info.Type].text; } if (isReply != null) { isReply.SetActive(info.IsReply); } if (dontReply != null) { dontReply.SetActive(!info.IsReply); } if (replySubmit != null) { replySubmit.gameObject.SetActive(info.Evaluation <= 0); } for (int i = 0; i < evaluations.Length; i++) { if (evaluations[i] != null) { if (info.Evaluation <= 0) { evaluations[0].startsActive = true; } else { if (i + 1 == info.Evaluation) { evaluations[i].startsActive = true; } else { evaluations[i].startsActive = false; } } BoxCollider box = evaluations[i].GetComponent <BoxCollider>(); box.enabled = info.Evaluation <= 0 && info.IsReply; } } if (replySubmit != null) { UIEventListener.Get(replySubmit.gameObject).onClick = delegate { for (int i = 0; i < evaluations.Length; i++) { if (evaluations[i] != null) { UIToggle tog = evaluations[i].GetComponent <UIToggle>(); if (tog != null && tog.value) { if (!info.IsReply && info.Evaluation <= 0) { GameCenter.messageMng.AddClientMsg(381); return; } QuestionsReplyInfo questionInfo = new QuestionsReplyInfo(DataInfo.ID, i + 1); if (GameCenter.mainPlayerMng.OnQuestionsReplyRequest != null) { GameCenter.mainPlayerMng.OnQuestionsReplyRequest(questionInfo); } return; } } } }; } }
void SetQuestionsInfo(QuestionsReplyInfo info) { QuestionsReplyInfo.PathType pathType = QuestionsReplyInfo.PathType.NONE; string path = string.Empty; string text = string.Empty; if (info != null) { pathType = info.GetPathType; path = info.GetPath(pathType); } else { info = new QuestionsReplyInfo(); pathType = QuestionsReplyInfo.PathType.QUESTIONSALL; path = info.GetPath(pathType); } if (path.Equals(string.Empty)) { return; } GetQuestionsInfo(path, (x) => { text = x; if (string.IsNullOrEmpty(text)) { Debug.LogError("下载客服数据失败,路径= :" + path); return; } int reportid = 0; switch (pathType) { case QuestionsReplyInfo.PathType.QUESTIONSALL: // Debug.Log("text = " + text); LitJson.JsonData jsonData = LitJson.JsonMapper.ToObject(text); if (jsonData != null && text.Contains("result")) { if ((int)jsonData["result"] != 0) { Debug.LogError("下载客服数据失败 :" + text); return; } } if (text.Contains("count")) { int count = (int)jsonData["count"]; if (text.Contains("reports")) { LitJson.JsonData reports = jsonData["reports"]; for (int i = 0; i < count; i++) { LitJson.JsonData reportsEty = reports[i]; int id = (int)reportsEty["reportId"]; string infodes = (string)reportsEty["info"]; string time = (string)reportsEty["reportTime"]; string reply = (string)reportsEty["reply"]; int type = (int)reportsEty["type"]; int assess = (int)reportsEty["assess"]; QuestionsReplyInfo question = new QuestionsReplyInfo(id, assess, type, time, reply, infodes); GameCenter.mainPlayerMng.AddQuestion(question); } } } ShowList(); break; case QuestionsReplyInfo.PathType.EVALUATE: GameCenter.mainPlayerMng.UpdateQuestion(info.ID, info.Evaluation); ShowList(); break; case QuestionsReplyInfo.PathType.REPLY: reportid = 0; string replydes = string.Empty; if (reportid > 0) { GameCenter.mainPlayerMng.UpdateQuestion(reportid, replydes); } List <QuestionsReplyInfo> dataList = GameCenter.mainPlayerMng.QuestionList; QuestionsReplyUI ety = null; if (grid != null) { grid.maxPerLine = dataList.Count; } int j = 0; for (; j < dataList.Count; j++) { if (gameList.Count > j) { gameList[j].DataInfo = dataList[j]; } } break; case QuestionsReplyInfo.PathType.REPROT: string[] strReport = text.Split('|'); if (strReport.Length >= 3) { if (!strReport[0].Equals("0")) { return; } info.Update(strReport[1], strReport[2]); GameCenter.mainPlayerMng.AddQuestion(info); ShowList(); } break; default: break; } }); }