123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783 |
- $(function () {
- var winHeight=window.innerHeight,//窗体高度
- winWidth=window.innerWidth,//窗体高度
- msgListUrl = 'doctor/consult/loglist',
- myScroll = null,
- self,
- docInfo,
- teamInfo,
- offTop = 45,
- offBot = 52,
- pageSize = 1000,
- prevImage,
- otherCode = '',//咨询者code
- sessionId = '',//咨询者拼接id
- sessionName = '',//咨询者姓名
- createTime = '',//咨询时间
- qyDocInfo = null,//签约医生信息
- consultInfo = {},//患者详情
- status = '',//0 待回复 1进行中 2完成
- type = '', //咨询类型 1三师咨询,2家庭医生咨询,3图文咨询,4公共咨询,5病友圈, 6名医咨询
- 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'),
- $tixys = $('.tixys');
-
- //mui初始化
- mui.init({
- gestureConfig:{
- doubletap: true,
- longtap: true,
- hold: true,
- release: true
- }
- });
- mui.plusReady(function () {
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- self = plus.webview.currentWebview();
- sessionId = self.sessionId;
- sessionName = self.sessionName;
- createTime = self.sessionTime;
- qyDocInfo = self.qyDocInfo ? JSON.parse(self.qyDocInfo) : null;
- consultInfo = self.consultInfo;
- otherCode = self.otherCode;
- status = self.stutas;
- type = self.type;
- //设置标题
- $title.html(sessionName + createTime + '咨询');
- //设置高度
- if(status == 2){
- offTop = 70
- }
- //获取成员信息
- getMembers();
- 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();
- });
- /**
- * 获取消息(下拉刷新)
- */
- 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 = {};
- var patientCode;
- $.each( rs , function(i, v) {
- if(v.id!=docInfo.code)
- otherCode = v.id;
- if(v.is_patient==1){
- isPatient = true;
- patientCode = v.id;
- }
- });
- otherCode = patientCode||otherCode;
- isSign();
- }, function(msg){
- console.log("e:"+JSON.stringify(msg))
- mui.toast("获取成员列表失败!");
- })
- }
- //判断是否有签约关系
- function isSign() {
- //status === 2:已完成回复
- if (status != 2) {
- sendGet("doctor/family_contract/doctor_patient_sign_exist", {
- doctor: docInfo.code,
- patient: otherCode
- }, null, function(res) {
- if(res.status == 200) {
- if(res.data.status == -1 && res.data.msg === '无签约关系') {
- //没有签约关系
- //判断是否是名医咨询,名医咨询可以跳转去IM页面
- if(type == 6){
- $xzzd.show();
- }
- // 修复bug#3460 【医生端】健康咨询:患者签约到期与医生存在未结束咨询时,从健康咨询进入无法回复咨询。
- if(qyDocInfo&& (docInfo.code != qyDocInfo.doctor)){
- $tixys.show();
- } else {
- $xzzd.show();
- }
- } else {
- $xzzd.show();
- }
- } else {
- mui.toast("获取签约关系失败!");
- }
- })
- }else{
- //获取被评价成员
- sendGet("doctor/consult/evaluate/list", {
- consult:consultInfo.id,
- type:1
- }, null, function(res) {
- if(res.status == 200) {
- if(res.list.length > 0){ //已经评分
- //兼容1.3.4的数据
- if(res.list[0].evaluate_type == 0){//旧数据
- $.each( res.list , function(i, v) {
- showStar(v);
- })
- $('#service').show();
- }else{
- 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;
- showStar2(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) {
- console.log("imgs:" + JSON.stringify(data));
- chatCache.imgs = data.records.reverse();
- appendPrevImgs(chatCache.imgs);
- if(handle) handle(data);
- }, 2);
- }
- //显示星星 旧数据
- function showStar(obj){
- if(obj){
- var list='',
- num='';
- var one = '<li><img src="../images/icon_xingxing.png" alt="" /></li>';
- num = Math.floor(obj.score/20);
- for(var i=0;i<num;i++){
- list += one;
- }
- var html='<li class="one"><div class="img"><img src="'+obj.photo+'" alt="" /></div><div class="name">'+obj.name+'</div><ul class="star">'+list+'</ul></li>';
- $('#starList').append(html);
- }
- }
- //显示星星 新数据
- function showStar2(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){
- console.log(msg.content)
- 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="text-align: center;"><a><img src="' + doctor_img + '" class="c-images-cycle" width="40" height="40"/></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://开始咨询文本
- //如果是续方咨询,显示样式不一致
- if(type == 8){
- var rs = JSON.parse(contentMsg);
- temp += '<div class="c-msg">'+ sendErrDom +
- '<dd class="word-bread" data-type="1">'+
- '<p>【本消息为系统提醒】</p>'+
- '<p>'+rs.title+'</p>'+
- '<p>'+rs.tzMsg+'</p>'+
- /*'<p>上次续方时间'+rs.lastTime+'</p>'+*/
- '</dd></div>';
- }else{
- temp += '<div class="c-msg">'+ sendErrDom +'<dd class="word-bread" data-type="1"><span>' + matchUrl(contentMsg) + '</span></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="../../message/images/bofang_icon.png">'+
- '<img class="jianjiao-icon-right" src="../../message/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="ml10 c-333">原因:'+rs.reason+'</p>';
- }
- temp += '<div class="c-msg">'+ sendErrDom +
- '<dd class="word-bread" data-type="1">'+
- '<p class="c-333">【本消息为系统提醒】</p>'+
- '<p class="c-333">审核消息:</p>'+
- '<p class="ml10 c-333">'+rs.title+'</p>'+
- '<p class="ml10 c-333">审核结果:'+rs.result+'</p>'+reason+
- '<a href="javascript:void(0);" class="view-detail">点此查看详情</a>'+
- '</dd></div>';
- break;
- }
- html += temp + '</div></dl>';
- }
- if(isPre)
- lastId = msgList.list[msgList.list.length - 1].id;
- if(isClear){
- $("#contain").html(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);
- // updateCacheMsgById($(img).attr('data-code'), "", "", "", dataURL);
- canvas = null;
- }
- /**
- * 获取消息
- */
- function getMsgs(page,sucHandle){
- sendGet(msgListUrl,{
- consult: consultInfo.id,
- 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 formatJyzd(msg, sendErrDom,yiduHtml){
- // // {"title":"2016年春节放假调休门诊安排通知","id":"ff1b39cfdf6a482c958140ba768474cc","img":"http://f1.yihuimg.com/TFS/upfile/WBJ/111/2016-02-05/160294_1454633481085_fullsize.png","content":"为了您的健康,我给您发送了一篇文章,请咨询查阅,如有问题,可随时与我沟通"}
- // if(msg){
- // //针对\n,\r等特殊字符,在json转换时会报错
- // msg = msg.replace(/\n/g, "\\n");
- // msg = msg.replace(/\r/g, "\\r");
- // msg = JSON.parse(msg);
- // // msg.img = msg.type==1? "../../../images/jkjl_share.png" : msg.img;
- // if(msg.type == 1){ //健康记录
- // msg.img = "../../../images/jkjl_share.png";
- // }else if(msg.type == 2){ //健康指导
- // var img = msg.img.split(",");
- // if(img[0] && img[0] != "null"){
- // msg.img = img[0];
- // }else{
- // msg.img = "../../../images/default_share_blue.png";
- // }
- // }else{ //健康教育
- // msg.img = msg.img;
- // }
- // var temp =
- // '<div class="c-msg">'+ sendErrDom +'<dd class="word-bread word-article" data-code="'+ msg.id+'" data-inner-type="'+ msg.type +'" data-type="4">'
- // + yiduHtml
- // + '<h4 class="text-ellipsis c-f18">'+ msg.title +'</h4>'
- // + '<div class="article-content"><img src="'+ msg.img +'">'
- // + '<div>'+ msg.content+'</div>'
- // + '</div>'
- // + '</dd></div>';
- // return temp;
- // }
- // return "";
- // }
- 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]);
- // var i = content.indexOf(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;
- }
-
- //事件绑定
- $('#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 {
- console.log(loc)
- 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);
- }
- });
- //点击健康教育文章连接
- // .on('tap', '.word-article', function(){
- // var type = $(this).attr('data-inner-type');
- // var code = $(this).attr('data-code');
- // if(type==1){
- // mui.openWindow('../../jkjl/html/health-record.html', 'health-record', {
- // extras: {
- // patientCode: code,
- // qyRelation: 0
- // }
- // });
- // }else if(type == 2){
- // mui.openWindow('../../hzzd/html/guidance_info.html', 'guidance_info', {
- // extras:{
- // guideId: code
- // }
- // })
- // } else{
- // mui.openWindow("../../jkjy/html/article.html", "article", {
- // extras: {
- // article: code
- // }
- // })
- // }
- //
- // });
- //绑定挂号链接
- $(document).on('tap', 'a', function(){
- if($(this).attr("name") == "guahao"){
- var id = $(this).attr("data-id");
- mui.openWindow("../../wdyy/html/detail-appointment.html", "detail-appointment", {
- extras: {
- dataId: id
- }
- })
- }
- });
-
- $(document).on('tap','#xzzd',function(){
- // 回复咨询
- sendPost("/doctor/consult/readed", {
- consult:consultInfo.id
- }, function() {
- plus.nativeUI.closeWaiting()
- }, function() {
- plus.nativeUI.closeWaiting();
- if(type == 8){
- mui.openWindow('../../message/html/xufangzixun.html', 'xufangzixun.html', {
- extras: {
- sessionId: consultInfo.session_id,
- otherCode: otherCode,
- otherName: consultInfo.patientName,
- type: type // 解决type参数值与从“消息”页面进入时携带的值代表的意义不一致,导致了bug#3225 【医生端】健康咨询:首页健康咨询中进入im详情无法邀请全科/求助。
- }
- })
- }else{
- mui.openWindow('../../message/html/p2dzixun.html', 'p2dzixun', {
- extras: {
- sessionId: consultInfo.session_id,
- otherCode: otherCode,
- otherName: consultInfo.patientName,
- type: (type == 1 || type == 2 )?1:type // 解决type参数值与从“消息”页面进入时携带的值代表的意义不一致,导致了bug#3225 【医生端】健康咨询:首页健康咨询中进入im详情无法邀请全科/求助。
- }
- })
- }
- });
- }).on('tap','.tixys',function(){
- //提醒医生
- openWebview("../../message/html/p2p.html",{otherCode: qyDocInfo.doctor, otherName: qyDocInfo.name});
- });
- 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;
- });
- }
- }
-
- /**
- * 点击查看好友详细信息
- */
- $('#qun_detail').on("tap", function() {
- mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', {
- extras: {
- patiCode: consultInfo.patient
- }
- });
- })
-
- //显示星级评价
- $('.j-show-btn').on('tap',function(){
- var $this = $(this);
- $('.j-show-btn').show();
- $this.hide();
- })
-
- });
|