123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- var Request = GetRequest()
- var sessionId = null,
- patiCode = window.localStorage.getItem("severPatientCode"),
- patiName = null,
- consultCode = Request["consult"],
- kindType = Request["type"],//区分续方8或健康2
- page = 1,
- members = [];
- var docInfo = JSON.parse(window.localStorage.getItem("severDocInfo"));
- $(function(){
- recordAPI.getSessionId({consult:consultCode}).then(function(res){
- if(res.status == 200){
- var msg = JSON.parse(res.msg)[0];
- sessionId = msg.session_id;
- }
- }).then(function(){
- //获得会话参与人员
- recordAPI.getMembers(sessionId).then(function(res){
- members = res;
- getMessage();
- })
- })
- function getMessage(){
- var params = {
- page: 1,
- pagesize: 1000,
- consult:consultCode
- }
- recordAPI.getList(params).then(function(res){
- var list = res.list.list
- if (list && list.length > 0) {
- var html = '',
- length = list.length;
- for (var j = length-1; j >= 0; j--) {
- var reply = JSON.parse(list[j])
- if(reply.content_type!=4 && reply.content_type!=14){//跳过教育指导
- html += formatMsg(reply);
- }
- }
- plyr.setup();
- $("#talkBox").append(html);
- }
- });
- }
-
- function formatMsg(reply){
- var isSelf = (reply.sender_id == docInfo.code) ? true : false;
- var isSystem = reply.sender_id == 'system';
- var html = '';
- var typeMsg = reply.content_type;
-
- if(typeMsg == 7 || typeMsg == 10 || typeMsg == 13){
- var content = reply.content;
- html = template('sys_msg_tmp', {content: content});
- }else if(typeMsg == 5){
- var con = JSON.parse(reply.content);
- if(reply.sender_id == docInfo.code){
- html = '<div class="time-tips"><span class="xt-xiaoxi">已向'+ con.doctor_name +'医生求助</span></div>';
- }
- }else{
- //获取个人成员信息
- var member;
- for(var i=0; i<members.length; i++){
- if(reply.sender_id == members[i].id){
- member = members[i];
- break;
- }
- }
- var img = httpRequest.getImgUrl(member.avatar);
- var content = '';
- try{
- content = JSON.parse(reply.content);
- }catch(e){
- if(typeMsg == 12){ //视频文件
- var arr = reply.content.split(",");
- content = {};
- content.img = arr[0];
- content.path = arr[1];
- content.time = arr[2];
- }else{
- content = reply.content;
- }
- }
- var obj = {
- isSelf: isSelf,
- time: new Date(reply.timestamp).format('yyyy-MM-dd HH:mm:ss'),
- type: typeMsg,
- kindType:kindType,//区分续方或健康
- name: member.name,
- img: img,
- content: content
- };
- html = template('msg_tmp', obj);
- }
- return html;
- }
-
- template.helper('getSourceUrl', function(str){
- return httpRequest.getImgUrl(str);
- });
-
- $("#talkBox").on("click",".showBigPic",function(){
- var $this = $(this)
- layer.open({
- type: 1,
- title:false,
- shadeClose: true,
- content:'<img style="max-width:100%" src="'+$this.attr('src')+'">'
- })
- })
- })
|