//mui初始化 mui.init({ gestureConfig:{ doubletap: true, longtap: true, hold: true, release: true } }); var winHeight=window.innerHeight,//窗体高度 winWidth=window.innerWidth,//窗体高度 msgListUrl = 'doctor/consult/loglist', myScroll = null, self, docInfo, teamInfo, offTop =180, offBot = 52, pageSize = 100, prevImage, otherDocCodeArr=[],//储存可能存在的其他医生 patiCode = '',//患者code sessionId = '',//患者拼接id sessionName = '',//患者姓名 createTime = '',//咨询时间 patientInfo, zx_status = '',//0 待回复 1进行中 2完成 type = '', //咨询类型 8续方 consultCode="", prescriptionCode, //续方的code prescriptionStatus, //续方的状态 prescriptionMsg,//续方信息 followObj, jwCode, //基卫那边存储的原处方的code lastTimestamp = '', urlRegex = new RegExp('((https|http|ftp|rtsp|mms)?://)' + '?(([0-9a-zA-Z_!~*\'().&=+$%-]+: )?[0-9a-zA-Z_!~*\'().&=+$%-]+@)?' //ftp的user@ + '(([0-9]{1,3}\\.){3}[0-9]{1,3}' // IP形式的URL- 199.194.52.184 + '|' // 允许IP和DOMAIN(域名) + '([0-9a-zA-Z_!~*\'()-]+\\.)*' // 域名- www. + '([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z]\\.' // 二级域名 + '(gov|edu|int|com|cn|cx|cn|wang|cc|xin|net|org|top|tech|red|pub|ink|info|xyz|win))' // first level domain- .com or .museum + '(:[0-9]{1,4})?' // 端口- :80 + '((/[0-9a-zA-Z_!~*\'().;?:@&=+$,%#-]+)+/?)?' + '((\\?[0-9a-zA-Z_!~*\'().;:@&=+$,%#-]+)+/?)?'); var $title = $('#title'), $xzzd = $('#xzzd'); mui.plusReady(function () { docInfo = JSON.parse(plus.storage.getItem("docInfo")); self = plus.webview.currentWebview(); sessionId = self.sessionId; sessionName = self.sessionName; createTime = self.sessionTime; patiCode = self.patiCode; zx_status = self.stutas; type = self.type; consultCode = sessionId.split("_")[1]; //设置标题 $title.html(sessionName + createTime + '续方咨询'); //获取成员信息 getMembers(); getPrescriptionInfo(); getPatientInfo(); getPatientDeviceList(); if(zx_status==2){ offTop = 105; $('.div-drug').hide() offBot = 10; } myScroll = $('#contain').lscroll({ type: 2, // pullDownMsg1: "下拉加载更多", pullDownMsg2: "松手开始加载", // pullDownAction: function(g){ // getMsgList(g.options.page, false, true); // }, style: "top: "+ offTop +"px; bottom: "+ offBot +"px", }); prevImage = mui.previewImage(); bindEvents2(); }); /** * 获得续方的内容 */ function getPrescriptionInfo(){ plus.nativeUI.showWaiting(); var url = "/doctor/consult/prescriptionDetail", params = {consult: consultCode}; sendGet(url, params, function(){ plus.nativeUI.closeWaiting(); mui.toast('请求失败') }, function(res){ plus.nativeUI.closeWaiting(); if(res.status == 200){ prescriptionMsg = res.data; followObj = prescriptionMsg.followup=="null"?'':JSON.parse(prescriptionMsg.followup); jwCode = res.data.jwCode; prescriptionCode = res.data.code; $("#preDTName").text(res.data.symptoms+"-续方咨询"); var status = res.data.status; prescriptionStatus = status; var statusName = getStatusName(status); $("#xfStatus").text(statusName); var drugmsg = ""; for(j=0; j'; $(document.body).append(html); var video = $(document.body).find('video')[0]; video.play(); }else{//andriod var Intent = plus.android.importClass("android.content.Intent"); var Uri = plus.android.importClass("android.net.Uri"); var main = plus.android.runtimeMainActivity(); var intent=new Intent(Intent.ACTION_VIEW); var uri=Uri.parse(url); intent.setDataAndType(uri,"video/*"); main.startActivity(intent); } }); $(document).on('tap','#xzzd',function(){ //回复咨询 sendPost("/doctor/consult/readed", { consult:consultCode }, function() { plus.nativeUI.closeWaiting() }, function() { plus.nativeUI.closeWaiting(); mui.openWindow('../../message/html/xufangzixun.html', 'xufangzixun.html', { extras: { sessionId: sessionId, otherCode: patiCode, otherName: patientInfo.name, type: 8 } }); }) }); /** * 点击查看好友详细信息 */ $('#qun_detail').on("tap", function() { mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', { extras: { patiCode: patiCode } }); }); //显示星级评价 $('.j-show-btn').on('tap',function(){ var $this = $(this); $('.j-show-btn').show(); $this.hide(); }); //点击查看详情,查看续方详情 $("body").on('tap', '.view-detail', function(){ openWebview('xufangxiangqing.html',{ prescriptionCode: prescriptionCode, teamCode: patientInfo.jtAdminTeam }); }) //随访调查 $("body").on('tap', ".viewData", function(){ var type = $(this).attr('data-type') mui.openWindow('../../message/html/questionaires.html', 'questionaires', { extras: { pro_id:type, prescriptionCode: prescriptionCode, followupid:followObj.id } }) }) //登记随访 function registerSuifang(){ var followClass; if(prescriptionMsg.symptoms == "高血压"){ followClass = 1; }else if(prescriptionMsg.symptoms == "糖尿病"){ followClass = 2; }else{ followClass = '1,2'; } mui.openWindow('../../suifang/html/follow_way.html', 'xf_follow_way', { extras: { followup_id:followObj.id, followClass:followClass, patientInfo:patientInfo, prescriptionCode: prescriptionCode, prescriptionStatus:prescriptionMsg.status } }) } $(".suifang").on('click', function(){ if(! followObj){ registerSuifang() }else{ if(followObj.status == 2){ registerSuifang() }else{ mui.openWindow('../../suifang/html/fvDetail.html', 'xf_fvDetail', { extras: { followup_id:followObj.id, prescriptionCode:prescriptionCode } }) } } }) $(".wenjuan").on('click', function(){ mui.openWindow('../../message/html/wenjuan.html', 'wenjuan', { extras: { prescriptionCode: prescriptionCode, followup_id:followObj.id, zx_Status: zx_status==2?1:0 } }) }) $("body").on('tap', ".fillData", function(){ if(! followObj){ mui.toast('随访已不存在') return }else{ var type = $(this).attr('data-type'); var healthindexid = $(this).attr('data-health'); var url; if(type == 1){ url="doctor/prescription/followupcontent/importbloodpressure" }else{ url="doctor/prescription/followupcontent/importbloodsugar" } plus.nativeUI.showWaiting(); sendPost(url,{followupid:followObj.id,prescriptioncode:prescriptionCode,healthindexid:healthindexid},function(){ plus.nativeUI.closeWaiting(); mui.toast('请求失败') }, function(res){ plus.nativeUI.closeWaiting(); if(res.status == 200){ mui.toast('成功填入随访记录') }else{ mui.toast(res.msg) } }) } }) $(".follow").click(function(e){ e.stopPropagation(); if(! followObj){ mui.toast('随访已不存在') return }else{ plus.nativeUI.showWaiting(); sendPost('doctor/prescription/followupcontent/importdrugs',{followupid:followObj.id,prescriptioncode:prescriptionCode},function(){ plus.nativeUI.closeWaiting(); mui.toast('请求失败') }, function(res){ plus.nativeUI.closeWaiting(); if(res.status == 200){ mui.toast('成功填入随访记录') }else{ mui.toast(res.msg) } }) } }) //头部导航 mui('#nav').scroll({ deceleration: 0.0005, scrollY: false, //是否竖向滚动 scrollX: true, //是否横向滚动 indicators: false }) } function getStatusName(status){ var name = "", img = ""; status = status + ''; switch (status){ case '-3': name = '支付过期'; break; case '-2': name = '患者取消'; break; case '-1': name = '审核不通过'; break; case '0': case '2': case '3': case '4': case '10': name = '审核中'; break; case '20': name = '药师审核中'; break; case '21': name = '药师审核失败'; break; case '30': name = '开方中'; break; case '31': name = '开方失败'; break; case '40': name = '待支付'; break; case '41': name = '支付失败'; break; case '50': name = '配药中'; break; case '60': name = '等待领药'; break; case '61': case '62': case '65': case '69': name = '配送中'; break; case '100': name = '已完成'; break; default: break; } return name; } /** * 获取消息(下拉刷新) */ function getMsgList(pageIndex, isClear, isPre) { getMsgs(pageIndex,function(data){ if (!!!data.list) { plus.nativeUI.closeWaiting(); myScroll.refresh(!!!data.list); return; } showMsg(data.list, isClear, isPre); }) } /** * 获取成员信息 */ function getMembers(callBack){ imClient.Sessions.getParticipants(sessionId, function(rs){ members = {}; $.each( rs , function(i, v) { if(v.id!=docInfo.code && v.id!=patiCode){ otherDocCodeArr.push(v.id) } }) isSign() }, function(msg){ mui.toast("获取成员列表失败!"); }) } //判断是否有签约关系 function isSign() { //status=2 已完成回复 if (zx_status != 2) { sendGet("doctor/family_contract/doctor_patient_sign_exist", { doctor: docInfo.code, patient: patiCode }, null, function(res) { if(res.status == 200) { if(res.data.status == -1 && res.data.msg === '无签约关系'){ //没有签约关系 $xzzd.show();//与团队长没有签约关系 }else{ $xzzd.show(); } } else { mui.toast("获取签约关系失败"); } }) }else{ //获取被评价成员 sendGet("doctor/consult/evaluate/list", { consult:consultCode, type:1 }, null, function(res) { if(res.status == 200) { if(res.list.length > 0){ //已经评分 if(res.list[0].type == 1){//实名 var obj = _.groupBy(res.list, function(item){ return item.doctor; }) for(var key in obj){ var arr = obj[key], dataObj = {}; $.each( arr , function(i, v) { if(v.evaluate_type == 1){ dataObj.ability = v.score; } if(v.evaluate_type == 2){ dataObj.attitude = v.score; } if(v.evaluate_type == 3){ dataObj.speed = v.score; } }) dataObj.name = arr[0].name; dataObj.avatar = arr[0].photo; showStar(dataObj); } $('#service').show(); }else{ $('.no-service').show(); } }else{ $('.no-service').show(); } }else{ mui.toast("获取评分数据失败"); } }) } getMsgs(1,function (res) { if (!!!res.list) { plus.nativeUI.closeWaiting(); mui.toast("暂无咨询记录!"); myScroll.refresh(!!!res.list); return; } showMsg(res.list, false, false, true) }); } /** * 获取聊天图片列表 */ function getImgMsgList(handle) { im.getPrivateMsg(getUserId(), otherCode, lastId, pageSize, function(data) { chatCache.imgs = data.records.reverse(); appendPrevImgs(chatCache.imgs); if(handle) handle(data); }, 2); } //显示星星 function showStar(obj){ if(obj){ var abList = addStars(obj.ability) var atList = addStars(obj.attitude) var spList = addStars(obj.speed) var html='
  • '+obj.name+'
    专业能力
      '+abList+'
    服务态度
      '+atList+'
    回复速度
      '+spList+'
  • '; $('#starList').append(html); } } function addStars(score){ var list='', num=''; var one = '
  • '; num = Math.floor(score/20); for(var i=0;i= 0; i--) { msg = msgList.list[i]; msg = JSON.parse(msg); setLastMsg(msg); typeMsg = parseInt(msg.content_type); if (typeMsg === 4|| typeMsg==14) { continue; } var contentMsg = msg.content; if(typeMsg == 7 || typeMsg==10 || typeMsg==13){ if(typeMsg == 7 && msg.sender_id == 'system'){ contentMsg = "居民24小时内未回复,系统自动结束咨询"; } html += '
    '+ contentMsg +'
    '; continue; } else if(typeMsg == 5){ var con = JSON.parse(msg.content); if(msg.sender_id == docInfo.code){ html += '
    已向'+ con.doctor_name +'医生求助立即查看
    '; } continue; } var _class = ["chat-log"]; if (users.length > 0) { for (var ii = 0; ii < users.length; ii++) { var user = users[ii]; if (user['id'] === msg['sender_id']) { doctor_img = getImgUrl(user['avatar']); doctor_name = user['name']; if(docInfo.code != user['id']) { _class.push("chat-left"); } else { _class.push("chat-right"); } break; } } } if(msg.timestamp - preTime > 60 * 1000) { preTime = msg.timestamp; var date = new Date(); date.setTime(msg.timestamp); var time = date.format('yyyy-MM-dd hh:mm:ss'); html += '
    ' + time + '
    '; } //type:1.文字 2.图片 3.音频 var temp = '
    '+ '
    ' + '
    ' + doctor_name + ''; var sendErrDom = ""; if(!msg.beforeSend && msg.id && msg.id.indexOf('loc')==0){ sendErrDom = ""; } switch(typeMsg) { case 0: case 1://普通文本 case 8://求助文本 temp += '
    '+ sendErrDom +'
    ' + matchUrl(contentMsg) + '
    '; break; case 6://开始咨询文本 var rs = JSON.parse(contentMsg); var tzMsg = rs.tzMsg; temp += '
    '+ sendErrDom + '
    '+ '

    本消息为系统提醒

    '+ '

    '+rs.title+'

    '+ '

    体征信息:'+rs.tzMsg+'

    '+ '
    '; break; case 2://图片 case 9://求助图片 if(msg.local_src=="data:,"){ contentMsg = msg.content; }else if(msg.local_src){ contentMsg = msg.local_src.indexOf('data:')==0? msg.local_src: plus.io.convertLocalFileSystemURL(msg.local_src); }else{ contentMsg = msg.content; } temp += '
    '+ sendErrDom + '
    '+'
    '; $('img.l-previmg[data-code="'+ msg.id +'"]').remove(); break; case 3://语音 var rec = msg.local_src? JSON.parse(msg.local_src) : contentMsg? JSON.parse(contentMsg) : undefined; if(rec){ var path = msg.local_src?msg.local_src:msg.content; temp += "
    "+ sendErrDom + "
    "+ "
    " + ""+(rec? rec.times: "") +"\'\'"+ "
    "+ "
    "; } break; case 12: //视频 var videoInfo = msg.content.split(","); var shichang = formatSeconds(videoInfo[2]);//时长 if(docInfo.code != msg.sender_id) { temp += '
    '+ ''+ ''+ ''+ ''+shichang+''+ '
    '; }else{ temp += '
    '+ ''+ ''+ ''+ ''+shichang+''+ '
    '; } break; case 15: //审核消息 var rs = JSON.parse(contentMsg); var reason = ""; if(rs.reason){ reason = '

    原因:'+rs.reason+'

    '; } temp += '
    '+ sendErrDom + '
    '+ '

    本消息为系统提醒

    '+ '

    '+rs.title+'

    '+ '

    审核结果:'+rs.result+'

    '+reason+ '点此查看详情'+ '
    '; break; case 16: var rs = JSON.parse(contentMsg); if(msg.sender_id == docInfo.code){ temp += '
    '+ '

    '+rs.text+'

    '+ '
    '; }else{ var alertMsg; if(rs.needUpload == 'false'){ alertMsg = rs.tzAlert+' 自动填入随访记录' temp += '
    '+ '
    '+ '

    本消息为系统提醒

    '+ '

    '+rs.tzMsg+'

    '+ '

    '+rs.tzTime+'

    '+ '

    '+alertMsg+'

    '+ '
    '; }else{ alertMsg = rs.tzAlert temp += '
    '+ '
    '+ '

    本消息为系统提醒

    '+ // '

    '+rs.tzMsg+'

    '+ // '

    '+rs.tzTime+'

    '+ '

    '+alertMsg+'

    '+ '
    '; } } break; case 17://随访调查 var rs = JSON.parse(contentMsg); if(msg.sender_id == docInfo.code){ temp += '
    '+ '

    '+rs.text+'

    '+ '
    '+rs.doctorremind+'
    '; }else{ if(rs.sysMsg){ temp += '
    '+ '
    '+ '

    本消息为系统提醒

    '+ '

    '+rs.text+'

    '+ '查看'+ '
    '; } } break; } html += temp + '
    '; } if(isPre) lastId = msgList.list[msgList.list.length - 1].id; if(isClear){ $("#contain").append(html); }else{ if(isPre){ $("#contain").prepend(html); if(scrollToTop) myScroll.refreshToTop(); else myScroll.refresh(msgList.list.length==0); return; } else { $("#contain").append(html); } } myScroll.refreshToEnd(); plus.nativeUI.closeWaiting(); } function imgLoad(img){ if(img.src.indexOf('data:')==0) return; var canvas = document.createElement('CANVAS'), ctx = canvas.getContext('2d'), newImg = new Image(); newImg.src = img.src; canvas.height = newImg.height; canvas.width = newImg.width; ctx.drawImage(newImg, 0, 0); var src = newImg.src; var outputFormat = src.substring(src.lastIndexOf('.')+1); outputFormat = outputFormat.toLowerCase()=="jpg"? "jpeg" : outputFormat; var dataURL = canvas.toDataURL('image/' + outputFormat); canvas = null; } /** * 获取消息 */ function getMsgs(page,sucHandle){ sendGet(msgListUrl,{ consult: consultCode, page: page, pagesize: pageSize },null,function (res) { if (res.status === 200) { sucHandle.call(this,res); } else { mui.toast(res.msg); } }); } /** * 设置获取到的最后一条消息 */ function setLastMsg(msg){ if(!lastTimestamp || lastTimestamp>msg.timestamp){ lastTimestamp = msg.timestamp; lastSeq = msg.seq; lastId = msg.id.indexOf("loc")==0? lastId : msg.id; } } //毫秒转换成时分秒 function formatSeconds(value) { var theTime = parseInt(value/1000);// 秒 var theTime1 = 0;// 分 var theTime2 = 0;// 小时 if(theTime > 60) { theTime1 = parseInt(theTime/60); theTime = parseInt(theTime%60); if(theTime1 > 60) { theTime2 = parseInt(theTime1/60); theTime1 = parseInt(theTime1%60); } } var result = ""+parseInt(theTime);//秒 if(parseInt(theTime)<=9){ result = "0"+parseInt(theTime);//秒 } if(theTime1 > 0) {//分 if(parseInt(theTime1)>9){ result = ""+parseInt(theTime1)+":"+result; }else{ result = "0"+parseInt(theTime1)+":"+result; } } if(theTime2 > 0) {//小时 if(parseInt(theTime2)>9){ result = ""+parseInt(theTime2)+":"+result; }else{ result = "0"+parseInt(theTime2)+":"+result; } } var resResult = ""; if(result.split(":").length==1){//秒 resResult = "00:"+result; }else if(result.split(":").length==2){//分 resResult = "00:"+result; }else{//时 resResult = result; } return resResult; } /** * 定位聊天记录位置 * @param {Object} id */ function locationLog(id){ var $logdom = $('.chat-log[data-code="'+ id +'"]'); if($logdom.length){ myScroll.scrollToElement( $logdom[0], 0, 0, -20 ); plus.nativeUI.closeWaiting(); } else { getCacheMsgById(id, function(tx, data){ if(data.length>0){ getCacheMsg("", "", function(tx, ls){ showMsg(ls, false, true, false, true); }, data[0].timestamp, true ) } else { getLastCacheMsg(function(tx, msg){ var startmsg = msg.length>0? msg[msg.length-1] : undefined; getMsgs(1,function(ls){ if(ls.length>0 && (!firstMsg || (firstMsg.timestamp'; var str = ""; var s = content.split(a[0]); for(var i=0; i=0; if($playDom){ if(player){ if(plus.os.name=="iOS" && !isPlayBenDi){//ios player.pause(); }else{ player.stop(); } $playDom.removeClass('active'); if($playDom.attr('data-code') == dom.attr('data-code')){ $playDom = false; return; } } } $playDom = dom; if(plus.os.name=="iOS" && !isPlayBenDi){//ios $(document.body).find('audio').remove(); var html = ''; $(document.body).append(html); player = $(document.body).find('audio')[0]; player.play(); player.addEventListener('ended', function () { $playDom.removeClass('active'); $playDom = false; }, false); }else{//andriod player = plus.audio.createPlayer(getImgUrl(path)); player.play(function() { $playDom.removeClass('active'); $playDom = false; }, function(e) { $playDom.removeClass('active'); $playDom = false; }); } }