tuanduiqunliao.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. var prevImage;
  2. var lastId = 0;
  3. var sessionId = "";
  4. var sessionName = "";
  5. mui.plusReady(function() {
  6. plus.nativeUI.showWaiting();
  7. self = plus.webview.currentWebview();
  8. teamInfo = self.info;
  9. sessionId = self.sessionId;
  10. sessionName = self.sessionName;
  11. getMineInfo();//初始化个人信息
  12. if(sessionName){
  13. $("#title").html(sessionName)
  14. }
  15. //刷新消息页
  16. var opener = self.opener();
  17. if(opener.id=="jumingim.html" || opener.id=="yishengim.html"){
  18. mui.back = backToWebviewById(opener.id,false,function() {
  19. var mainWebview = plus.webview.getWebviewById(opener.id);
  20. mui.fire(mainWebview,"xiaoxiUpdate");
  21. self.close();
  22. });
  23. } else {
  24. backToParent();
  25. }
  26. //backxiaoxi();
  27. prevImage = mui.previewImage();
  28. initPage();
  29. try {
  30. plus.push.clear();
  31. } catch(e) {
  32. }
  33. });
  34. function initPage(){
  35. if(teamInfo&&teamInfo.teamCode) {
  36. sendGet("/doctor/admin-teams/"+ teamInfo.teamCode +"/members", {}, null, function(res){
  37. if(res.status == 200){
  38. members = {};
  39. $.each(res.data, function(i, v) {
  40. members[v.code] = v;
  41. });
  42. createSession(3, getMembers);
  43. } else
  44. mui.toast("获取成员列表失败!");
  45. })
  46. } else if(sessionId){
  47. imClient.Sessions.getParticipants(sessionId,function(res) {
  48. members = {};
  49. $.each(res, function(i, v) {
  50. members[v.id] = v;
  51. });
  52. createSession(3, getMembers);
  53. },function(res) {
  54. mui.toast("获取成员列表失败!");
  55. })
  56. }
  57. }
  58. /**
  59. * 获取聊天图片列表
  60. */
  61. function getImgMsgList(handle){
  62. im.getGroupMsg(getUserId(), teamInfo.code, lastId, pageSize, function(data) {
  63. console.log("imgs:" + JSON.stringify(data));
  64. chatCache.imgs = data.records.reverse();
  65. appendPrevImgs(chatCache.imgs);
  66. if(handle) handle(data);
  67. }, 2);
  68. }
  69. /**
  70. * 发送消息
  71. */
  72. function uploadMsg(type, content, locSrc, isNotSend, callBack) {
  73. uploadMsgBase(type, content, locSrc, isNotSend, callBack);
  74. }
  75. function setTitle(teamName){
  76. document.querySelector("h1").innerText = teamName;
  77. }
  78. document.getElementById("qun_detail").addEventListener('tap', function() {
  79. mui.openWindow({
  80. url: "../../tuandui/html/tuanduishezhi.html",
  81. id: "tuanduishezhi.html",
  82. extras: teamInfo || {
  83. teamCode: sessionId,
  84. teamName: sessionName
  85. }
  86. })
  87. });
  88. window.addEventListener('updateTeamName', function(e) {
  89. setTitle(e.detail.teamName)
  90. });