123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026 |
- //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<res.data.prescriptionInfo.length; j++){
- var item = res.data.prescriptionInfo[j];
- drugmsg += item.drugName+" "+item.num+item.drugNumUnitName+" ";
- }
- $("#drugInfo").find('.j-msg').text(drugmsg);
- if(zx_status!=2){
- $('.div-drug').show()
- }
- if(status<0){
- $('.suifang').hide()
- }
- }else{
- mui.toast(res.msg);
- }
- }, true);
- }
- //获得患者信息
- function getPatientInfo(){
- var url = '/doctor/patient_label_info/patient',
- params = {patient: patiCode};
- sendPost(url, params, null, function(res){
- if(res.status == 200){
- patientInfo = res.data;
- }else{
- mui.toast(res.msg);
- }
- }, 'POST', '', true)
- }
- //判断患者是否有设备绑定
- function getPatientDeviceList(){
- var url = "doctor/device/PatientDeviceList",
- params = {patient: patiCode, page:1, pagesize: 2};
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- if(res.data.length == 0){
- //没有绑定设备
- $(".tzjl").hide();
- }else{
- //绑定了设备
- $(".tzjl").show();
- }
- }else{
- //获取设备信息失败
- }
- }, true);
- }
- function bindEvents2(){
- //顶部内容的展开和收缩
- $("#expandBox").on('click', function(e){
- e.stopPropagation();
- var $this = $(this);
- if($this.hasClass('expand')){
- $this.removeClass('expand');
- $this.find('img').attr('src', '../images/zhankai_icon.png');
- $("#prescriptionInfo").hide();
- var top = $(".div-drug").height()+73;
- $("#wrapper1").css({
- "top" : top+'px'
- });
- }else{
- $this.addClass('expand');
- $this.find('img').attr('src', '../images/shouqi_icon.png');
- $("#prescriptionInfo").show();
- var top = $(".div-drug").height()+73;
- $("#wrapper1").css({
- "top" : top+'px'
- });
- }
- });
- //体征记录
- $(".tzjl").on('click', function(){
- mui.openWindow('../../jkjl/html/health-record.html', 'health-record', {
- extras: {
- patientCode: patiCode,
- patientName: patientInfo.name,
- qyRelation: 1
- }
- });
- });
-
- //检查检验
- $(".jcjy").on('click', function(){
- openWebview("../../huanzhe/html/jianchajianyan.html",{
- patiInfo: {
- code: patiCode
- }
- });
- });
-
- //诊断处方
- $(".zdcf").on('click', function(){
- openWebview("../../prescription/html/chufangxiangqing.html",{
- code: jwCode,
- patient:patiCode
- });
- });
-
- //历史续方
- $(".lsxf").on('click', function(){
- openWebview('../../prescription/html/juminxufangjilu.html', {
- teamCode: patientInfo.jtAdminTeam,
- patiCode: patiCode,
- patiName: patientInfo.name
- });
- });
-
- $("#prescriptionInfo").on("click", function(){
- openWebview('../../prescription/html/xufangxiangqing.html',{
- prescriptionCode: prescriptionCode,
- teamCode: patientInfo.jtAdminTeam
- });
- });
-
- //事件绑定
- $('#contain').on('tap', '.word-bread[data-type="3"]', function(){
- $('#contain').find('.word-bread[data-type="3"]').removeClass("active");
- var $dom = $(this);
- var loc = $(this).attr('data-loc-audio');
- $dom.addClass('active');
- if(!loc){
- var ser = $(this).attr('data-audio');
- if(ser){
- ser = JSON.parse(ser);
- //下载
- var path = "_doc/audio/"+new Date().getTime()+".wav";
- var dtask = plus.downloader.createDownload( ser.path, {
- filename: path
- },function ( d, status ) {
- if ( status == 200 ) {
- //更新数据,播放语音
- playRecord(path, $dom);
- } else {
- $dom.removeClass('active');
- mui.toast("下载语音失败!");
- }
- });
- dtask.start();
- } else{
- $dom.removeClass('active');
- mui.toast("语音数据丢失!");
- }
- } else {
- loc = JSON.parse(loc);
- //播放语音
- playRecord(getImgUrl(loc.path), $dom);
- }
- }).on('tap', '.preview-video[data-type="12"]', function(){//播放视频
- var url = $(this).attr('data-video');
- if(plus.os.name=="iOS"){//ios
- $(document.body).find('video').remove();
- var html = '<video controls style="display:none;" preload="auto" width="1" height="1" src="'+url+'" ></video>';
- $(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='<li class="new-li"><div class="p1"><div class="imgs"><img src="'+ getImgUrl(obj.avatar)+'" alt=""/></div><div class="name">'+obj.name+'</div></div><div class="p2"><div class="div"><div class="label">专业能力</div><ul class="list">'+abList+'</ul></div><div class="div"><div class="label">服务态度</div><ul class="list">'+atList+'</ul></div><div class="div"><div class="label">回复速度</div><ul class="list">'+spList+'</ul></div></div></li>';
- $('#starList').append(html);
- }
- }
- function addStars(score){
- var list='',
- num='';
- var one = '<li><img src="../images/icon_xingxing.png" alt="" /></li>';
- num = Math.floor(score/20);
- for(var i=0;i<num;i++){
- list += one;
- }
- return list
- }
- /**
- * 显示消息
- */
- function showMsg(msgList, isClear, isPre, appendImg, scrollToTop) {
- if(msgList.list.length == 0) {
- plus.nativeUI.closeWaiting();
- myScroll.refresh(msgList.length==0);
- return;
- }
- var html = "";
- var preTime = 0;
- var typeMsg = 1;
- var doctor_img ;
- var doctor_name = "";
- var msg;
- var sender;
- var users = msgList.users;
- var isDoc = false;
- for(var i = msgList.list.length - 1; 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 += '<div class="time-tips"><div>'+ contentMsg +' </div></div>';
- continue;
- } else if(typeMsg == 5){
- var con = JSON.parse(msg.content);
- if(msg.sender_id == docInfo.code){
- html += '<div class="time-tips"><div>已向'+ con.doctor_name +'医生求助<a data-name="'+ con.doctor_name +'" data-code="'+ con.doctor +'" class="qiuzhu5" href="javascript:void(0)">立即查看</a> </div></div>';
- }
- 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 += '<div class="time-tips"><span>' + time + '</span></div>';
- }
-
- //type:1.文字 2.图片 3.音频
- var temp = '<dl data-type="'+ typeMsg +'" data-code="'+ msg.id +'" class="' + _class.join(" ") + '">'+
- '<dt style="height: auto; text-align: center;"><a><img src="' + doctor_img + '" class="c-images-cycle" /></a></dt>' +
- '<div class="c-content"><span class="c-f12 name">' + doctor_name + '</span>';
- var sendErrDom = "";
- if(!msg.beforeSend && msg.id && msg.id.indexOf('loc')==0){
- sendErrDom = "<i data-info='"+ JSON.stringify(msg) +"' class='c-tips'></i>";
- }
-
- switch(typeMsg) {
- case 0:
- case 1://普通文本
- case 8://求助文本
- temp += '<div class="c-msg">'+ sendErrDom +'<dd class="word-bread" data-type="1"><span>' + matchUrl(contentMsg) + '</span></dd></div>';
- break;
- case 6://开始咨询文本
- var rs = JSON.parse(contentMsg);
- var tzMsg = rs.tzMsg;
- temp += '<div class="c-msg">'+ sendErrDom +
- '<dd class="word-bread new-sty" data-type="1">'+
- '<div class="new-messg"><p class="new-mess-p">本消息为系统提醒</p></div>'+
- '<p class="c-333">'+rs.title+'</p>'+
- '<p class="c-333">体征信息:'+rs.tzMsg+'</p>'+
- '</dd></div>';
- 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 += '<div class="c-msg">'+ sendErrDom + '<dd class="word-bread word-bread-img" data-type="2">'+'<img onload="imgLoad(this)" data-src="'+ msg.content +'" data-code="'+ msg.id +'" data-preview-src="" data-preview-group="1" width="100" height="100" src="'+ getImgUrl(contentMsg) +'" /></dd></div>';
- $('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 += "<div class='c-msg'>"+ sendErrDom + "<dd class='word-bread audio' data-type='3' data-code='"+ msg.id +"' data-audio='" + contentMsg + "' data-loc-audio='" + path +"'>"+
- "<div style='width:"+ (rec.times*1.5+30) +"px' class='soundWav'>" +
- "<span class='soundWavT'>"+(rec? rec.times: "") +"\'\'</span>"+
- "</div>"+
- "</dd></div>";
- }
- break;
- case 12: //视频
- var videoInfo = msg.content.split(",");
- var shichang = formatSeconds(videoInfo[2]);//时长
- if(docInfo.code != msg.sender_id) {
- temp += '<div class="c-msg"><dd data-content="'+msg.content+'" class="preview-video" data-type="12" data-video="'+getImgUrl(videoInfo[1])+'">'+
- '<img class="video-img-left" src="'+getImgUrl(videoInfo[0])+'">'+
- '<img class="bofang-icon-left" src="../../message/images/bofang_icon.png">'+
- '<img class="jianjiao-icon-left" src="../../message/images/zuoshanjiao_bg.png">'+
- '<span class="shichang-time-left">'+shichang+'</span>'+
- '</dd></div>';
- }else{
- temp += '<div class="c-msg"><dd data-content="'+msg.content+'" class="preview-video" data-type="12" data-video="'+getImgUrl(videoInfo[1])+'">'+
- '<img class="video-img-right" src="'+getImgUrl(videoInfo[0])+'">'+
- '<img class="bofang-icon-right" src="../images/bofang_icon.png">'+
- '<img class="jianjiao-icon-right" src="../images/youshanjiao_bg.png">'+
- '<span class="shichang-time-right">'+shichang+'</span>'+
- '</dd></div>';
- }
- break;
- case 15: //审核消息
- var rs = JSON.parse(contentMsg);
- var reason = "";
- if(rs.reason){
- reason = '<p class="c-333 xf-word">原因:'+rs.reason+'</p>';
- }
- temp += '<div class="c-msg">'+ sendErrDom +
- '<dd class="word-bread new-sty" data-type="1">'+
- '<div class="new-messg"><p class="new-mess-p">本消息为系统提醒</p></div>'+
- '<p class="c-333">'+rs.title+'</p>'+
- '<p class="c-333">审核结果:'+rs.result+'</p>'+reason+
- '<a href="javascript:void(0);" class="view-detail">点此查看详情</a>'+
- '</dd></div>';
- break;
- case 16:
- var rs = JSON.parse(contentMsg);
- if(msg.sender_id == docInfo.code){
- temp += '<dd class="word-bread survey-msg"><div class="msg-body clearfix">'+
- '<p class="c-333 c-f15">'+rs.text+'</p>'+
- '</div></dd>';
- }else{
- var alertMsg;
- if(rs.needUpload == 'false'){
- alertMsg = rs.tzAlert+' <a href="javascript:;" data-health="'+rs.healthindexid+'" data-type="'+rs.type+'" class="fillData">自动填入随访记录</a>'
- temp += '<div class="c-msg">'+
- '<dd class="word-bread new-sty" data-type="1">'+
- '<div class="new-messg"><p class="new-mess-p">本消息为系统提醒</p></div>'+
- '<p class="c-333">'+rs.tzMsg+'</p>'+
- '<p class="c-333">'+rs.tzTime+'</p>'+
- '<p class="c-333">'+alertMsg+'</p>'+
- '</dd></div>';
- }else{
- alertMsg = rs.tzAlert
- temp += '<div class="c-msg">'+
- '<dd class="word-bread new-sty" data-type="1">'+
- '<div class="new-messg"><p class="new-mess-p">本消息为系统提醒</p></div>'+
- // '<p class="c-333">'+rs.tzMsg+'</p>'+
- // '<p class="c-333">'+rs.tzTime+'</p>'+
- '<p class="c-333">'+alertMsg+'</p>'+
- '</dd></div>';
- }
- }
- break;
- case 17://随访调查
- var rs = JSON.parse(contentMsg);
- if(msg.sender_id == docInfo.code){
- temp += '<dd class="word-bread survey-msg"><div class="msg-body clearfix">'+
- '<p class="c-333 c-f15">'+rs.text+'</p>'+
- '</div></dd><div class="xf-notice">'+rs.doctorremind+'</div>';
- }else{
- if(rs.sysMsg){
- temp += '<div class="c-msg">'+
- '<dd class="word-bread new-sty" data-type="1">'+
- '<div class="new-messg"><p class="new-mess-p">本消息为系统提醒</p></div>'+
- '<p class="c-333">'+rs.text+'</p>'+
- '<a href="javascript:;" data-type="'+rs.msgType+'" class="viewData">查看</a>'+
- '</dd></div>';
- }
- }
- break;
- }
- html += temp + '</div></dl>';
- }
- 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<ls[0].timestamp) ))
- firstMsg = ls[0];
- showMsg(msg.concat(ls), false, true, false, true);
- })
-
- }, lastTimestamp);
-
- }
- })
- }
- }
- /**
- * 将字符串转为对象
- * @param {Object} data
- */
- function parseMsg(data) {
- var d = [];
- for(var i = 0; i < data.length; i++) {
- d.push(JSON.parse(data[i]));
- }
- return d;
- }
- function matchUrl(content){
- var a = urlRegex.exec(content);
- if(a){
- var ah = '<a class="urlMatch" href="javascript:void(0)">'+ a[0] +'</a>';
- var str = "";
- var s = content.split(a[0]);
- for(var i=0; i<s.length; i++){
- if(i==s.length-1)
- str += s[i];
- else
- str += s[i] + ah;
- }
- return str;
- }
- return content;
- }
- var player;
- var $playDom = false;
- function playRecord(path, dom){
- var isPlayBenDi = path.indexOf('.amr')>=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 = '<audio preload="auto" src="'+getImgUrl(path)+'"></audio>';
- $(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;
- });
- }
- }
|