consult-detail.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. var Request = GetRequest()
  2. var sessionId = null,
  3. patiCode = window.localStorage.getItem("severPatientCode"),
  4. patiName = null,
  5. consultCode = Request["consult"],
  6. kindType = Request["type"],//区分续方8或健康2
  7. page = 1,
  8. members = [];
  9. var docInfo = JSON.parse(window.localStorage.getItem("severDocInfo"));
  10. $(function(){
  11. recordAPI.getSessionId({consult:consultCode}).then(function(res){
  12. if(res.status == 200){
  13. var msg = JSON.parse(res.msg)[0];
  14. sessionId = msg.session_id;
  15. }
  16. }).then(function(){
  17. //获得会话参与人员
  18. recordAPI.getMembers(sessionId).then(function(res){
  19. members = res;
  20. getMessage();
  21. })
  22. })
  23. function getMessage(){
  24. var params = {
  25. page: 1,
  26. pagesize: 1000,
  27. consult:consultCode
  28. }
  29. recordAPI.getList(params).then(function(res){
  30. var list = res.list.list
  31. if (list && list.length > 0) {
  32. var html = '',
  33. length = list.length;
  34. for (var j = length-1; j >= 0; j--) {
  35. var reply = JSON.parse(list[j])
  36. if(reply.content_type!=4 && reply.content_type!=14){//跳过教育指导
  37. html += formatMsg(reply);
  38. }
  39. }
  40. plyr.setup();
  41. $("#talkBox").append(html);
  42. }
  43. });
  44. }
  45. function formatMsg(reply){
  46. var isSelf = (reply.sender_id == docInfo.code) ? true : false;
  47. var isSystem = reply.sender_id == 'system';
  48. var html = '';
  49. var typeMsg = reply.content_type;
  50. if(typeMsg == 7 || typeMsg == 10 || typeMsg == 13){
  51. var content = reply.content;
  52. html = template('sys_msg_tmp', {content: content});
  53. }else if(typeMsg == 5){
  54. var con = JSON.parse(reply.content);
  55. if(reply.sender_id == docInfo.code){
  56. html = '<div class="time-tips"><span class="xt-xiaoxi">已向'+ con.doctor_name +'医生求助</span></div>';
  57. }
  58. }else{
  59. //获取个人成员信息
  60. var member;
  61. for(var i=0; i<members.length; i++){
  62. if(reply.sender_id == members[i].id){
  63. member = members[i];
  64. break;
  65. }
  66. }
  67. var img = httpRequest.getImgUrl(member.avatar);
  68. var content = '';
  69. try{
  70. content = JSON.parse(reply.content);
  71. }catch(e){
  72. if(typeMsg == 12){ //视频文件
  73. var arr = reply.content.split(",");
  74. content = {};
  75. content.img = arr[0];
  76. content.path = arr[1];
  77. content.time = arr[2];
  78. }else{
  79. content = reply.content;
  80. }
  81. }
  82. var obj = {
  83. isSelf: isSelf,
  84. time: new Date(reply.timestamp).format('yyyy-MM-dd HH:mm:ss'),
  85. type: typeMsg,
  86. kindType:kindType,//区分续方或健康
  87. name: member.name,
  88. img: img,
  89. content: content
  90. };
  91. html = template('msg_tmp', obj);
  92. }
  93. return html;
  94. }
  95. template.helper('getSourceUrl', function(str){
  96. return httpRequest.getImgUrl(str);
  97. });
  98. $("#talkBox").on("click",".showBigPic",function(){
  99. var $this = $(this)
  100. layer.open({
  101. type: 1,
  102. title:false,
  103. shadeClose: true,
  104. content:'<img style="max-width:100%" src="'+$this.attr('src')+'">'
  105. })
  106. })
  107. })