var lastId = 0; var prevImage; var isHidden = ""; var consultData; var isJieshuCaozuo = false; mui.plusReady(function() { self = plus.webview.currentWebview(); isHidden = self.isHidden; if(isHidden){ $(".header-group").hide(); } var sessionName = self.name; if(sessionName){ $("#title").html(sessionName) } plus.nativeUI.showWaiting(); getMineInfo();//初始化个人信息 createSession(2, getUnfinishConsult); prevImage = mui.previewImage(); var opener = self.opener(); if(opener && opener.id=="mingyizixunliebiao"){ backToMyzx(); } else if(self.from == "faqiqiuzhu"){ backToParent(); } else if(opener && opener.id=="faqizixun") { mui.back = backToWebviewById("mingyizixunliebiao",false,function() { var mainWebview = plus.webview.getWebviewById("mingyizixunliebiao"); mui.fire(mainWebview,"activeItem"); }); } else if(opener && (opener.id=="jumingim.html" || opener.id=="yishengim.html")){ mui.back = backToWebviewById(opener.id,false,function() { var mainWebview = plus.webview.getWebviewById(opener.id); mui.fire(mainWebview,"xiaoxiUpdate"); self.close(); }); } else if (opener && opener.id=="zuyuanziliao") { function closeOpener(cur){ if(cur.id != "xiaoxi.html" && cur.id != "main" && cur.id != "../../tuandui/html/tuandui.html" && cur.id != "mine.html" && cur.id != "home1.html" && cur.id != "home2.html" && cur.id != "huanzhe.html" && cur.id!="yishengim.html"){ var opener = cur.opener(); cur.close(); closeOpener(opener); } } mui.back = function(){ // if(docInfo.level == 1){ // mui.fire(plus.webview.getWebviewById("home1.html"), "refresh");; // } else { // var mainWebview = plus.webview.getWebviewById("main"); // mui.fire(mainWebview,"activeXiaoxi"); // mainWebview.show(); // } mui.later(function(){ closeOpener(self.opener()); self.close(); }, 300); } } else { backToParent(); } }); function getUnfinishConsult(){ getMembers(function(){ if(self.consultData){ initPage(self.consultData); } else { service.hasUnfinishedConsult(otherCode, function(res){ initPage(res.data); }) } }) } function initPage(data){ consultData = data; if(self.type=="doctor-to-doctor"){ //医生间,正常聊天 } else if(consultData.consult){ //存在未结束的咨询 $('#wrapper1').css({top:'46px'}); if(myScroll) myScroll.refresh(); $('.topmsg').html('首次回复24小时后,将自动结束咨询立即结束').show(); if(consultData.zxGroupCode){ //未结束的咨询属于求助咨询,type为10 if(docInfo.code==consultData.from) $('.forward').show(); } } else { //不存在未结束的咨询 $('#wrapper1').css({bottom: '0px'}); $('#input_div').hide(); } //getNewMsgs(true);//获取新消息 getFirstMsgs(); } /** * 获取聊天图片列表 */ 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 uploadMsg(type, content, locSrc, isNotSend, callBack) { if(consultData && consultData.consult){ service.isConsultFinished(consultData.consult, function(res){ if(res.data==0){ uploadMsgBase(type, content, locSrc, isNotSend, callBack); } else { $('.topmsg').hide(); $('#wrapper1').css({top:'16px', bottom: '0px'}); $('#input_div').hide(); $('.forward').hide(); myScroll.refresh(); } }) } else { uploadMsgBase(type, content, locSrc, isNotSend, callBack); } } function jieshu(){ mui.confirm("结束咨询后,居民及所有医生均无法再次回复,是否确认继续结束?", "", ["继续结束", "我再看看"], function(e) { if(e.index == 0) { sendPost("doctor/consult/finish_consult", { consult: consultData.consult }, null, function(res) { if(res.status == 200){ isJieshuCaozuo = true; $('.topmsg').html("咨询求助已结束"); $('.forward').hide(); $('#input_div').hide(); $('#wrapper1').css({bottom:'0px'}); myScroll.refresh(); mui.toast("已结束该咨询"); } else { mui.toast(res.msg) } }); } }) } function viewZixun(){ openWebview("../../message/html/p2dzixun.html",{ // groupName: name, sessionName: consultData.patient_name, sessionId: consultData.zxGroupCode }); mui.later(function(){ self.close(); }, 1000) } function backToMyzx(){ var old_back = mui.back; mui.back = function() { if(isJieshuCaozuo){ var wv = plus.webview.getWebviewById("mingyizixunliebiao"); if(wv){ wv.reload(true); } } old_back(); } } /** * 点击查看好友详细信息 */ $('#qun_detail').on("tap", function(){ if(isPatient){ mui.openWindow('../../huanzhe/html/huanzhexinxi.html', 'huanzhexinxi.html', { extras: { patiCode: otherCode } }); } else { mui.openWindow('../../mine/html/zuyuanziliao.html', 'zuyuanziliao1', { extras: { docCode: otherCode } }); } })