123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- var prevImage;
- var lastId = 0;
- var consultInfo;
- var groupName;
- mui.plusReady(function() {
- self = plus.webview.currentWebview();
- if(self.openId){
- mui.later(function(){
- closeOp(self.opener());
- }, 500)
- }
-
- setTitle(self.groupName);
- getMineInfo();//初始化个人信息
- // getMemberLs();//获取成员信息
- getTeamInfo();
- closeRefreshXiaoxi();
- prevImage = mui.previewImage();
-
- try {
- plus.push.clear();
- } catch(e) {
-
- }
- });
- function closeRefreshXiaoxi(){
- mui.back = function() {
- var wv = plus.webview.getWebviewById('xiaoxi.html');
- if(wv){
- mui.fire(wv, "refreshIMMsg");
- }
- self.close();
- }
- }
-
- function closeOp(wv){
- if(wv){
- if(self.openId == wv.id){
- wv.close();
- } else {
- closeOp(wv.opener());
- wv.close();
- }
- }
- }
- function getTeamInfo(){
- sendPost("/doctor/talkgroup/getConsultByGroupCode", {
- groupCode: self.groupCode
- }, null, function(res){
- if(res.status == 200){
- consultInfo = res.data;
- consultInfo.curGroup = self.groupCode;
- if(self.groupCode == consultInfo.group1)
- setTitle(consultInfo.groupName1);
- else
- setTitle(consultInfo.groupName2);
-
- if(consultInfo.group1 && consultInfo.group2==self.groupCode){
- $('.topmsg').hide();
- /*$('#wrapper1').css('top', '16px');
- offTop = 46;*/
- } else if(consultInfo.status==1){
- $('.topmsg').html("咨询求助已结束");
- $('#wrapper1').css({top: '46px', bottom: '0px'});
- $('#input_div').hide();
- } else if(consultInfo.group1==self.groupCode ||
- (!consultInfo.group1 && consultInfo.groupCreator2==getUserId()) ){
- $('.topmsg').html('首次回复24小时后,将自动结束咨询<a href="javascript:void(0)" onclick="jieshu()">立即结束</a>');
- $('#wrapper1').css({top: '46px', bottom: '52px'});
- } else if( consultInfo.groupCreator1 == getUserId() || consultInfo.groupCreator2 == getUserId() ) {
- $('.topmsg').html('首次回复24小时后,将自动结束咨询<a href="javascript:void(0)" onclick="jieshu()">立即结束</a>');
- $('#wrapper1').css({top: '46px', bottom: '52px'});
- } else {
- $('.topmsg').hide();
- }
-
- if(myScroll) myScroll.refresh();
- $('#qiuzhuico').toggle( consultInfo.group1==self.groupCode && docInfo.level==2 );
-
- getMemberLs();
- } else {
- mui.toast("获取团队信息失败!")
- }
-
- })
- }
-
- function getMemberLs(t){
- sendPost("/doctor/talkgroup/groupmembers", {
- groupCode: self.groupCode
- }, null, function(res){
- if(res.status == 200){
- $.each(res.data, function(i, v) {
- v.name = v.memberName;
- if(v.memberCode == consultInfo.patient)
- v.type="patient";
- members[v.memberCode] = v;
- });
- if(!t)
- getNewMsgList(true); //读取对话消息,
- } else {
- mui.toast("获取成员列表失败");
- }
- })
- }
-
- /**
- * 获取聊天图片列表
- */
- function getImgMsgList(handle){
- im.getGroupMsg(getUserId(), self.groupCode, lastId, pageSize, function(data) {
- chatCache.imgs = data.records.reverse();
- appendPrevImgs(chatCache.imgs);
- if(handle) handle(data);
- }, 2);
- }
-
- /**
- * 获取未读消息
- */
- function getNewMsgList(isInit){
- if(isInit && self.msgId){
- //带msgId定位参数的,
- locationLog(self.msgId);
- } else if(chatCache.firstMsgId){
- im.getGroupMsg(getUserId(), self.groupCode, 10000000000, pageSize, function(data) {
- getNewMsgHandle(data, isInit);
- }, undefined, chatCache.firstMsgId);
- } else{
- im.getGroupMsg(getUserId(), self.groupCode, 0, pageSize, function(data) {
- getNewMsgHandle(data, isInit);
- });
- }
- }
-
- /**
- * 获取消息
- */
- function getMsgList(pageIndex, isClear, isPre) {
- var list = getChacheMsg();
- if(list.length<pageSize){
- im.getGroupMsg(getUserId(), self.groupCode, lastId, pageSize, function(data) {
- if(data.count>0){
- if(!chatCache.firstMsgId || data.startId > chatCache.firstMsgId)
- chatCache.firstMsgId = data.startId;
- addMsgToCache(data);
- list = getChacheMsg();
- }
- showMsg({count: list.length, records: list}, isClear, isPre);
- });
- } else {
- showMsg({count: pageSize, records: list}, isClear, isPre);
- }
- }
- /**
- * 发送消息
- */
- function uploadMsg(type, content) {
- service.isConsultFinished(consultInfo.consult, function(res){
- if(res.data==0){
- im.sendGroupMsg(getUserId(), self.groupCode, content, type, function(data) {
- getNewMsgList();
- }, 2)
- } else {
- $('.topmsg').html("咨询求助已结束");
- $('#wrapper1').css({top: '46px', bottom: '0px'});
- $('#input_div').hide();
- myScroll.refresh();
- }
- })
- }
-
- function setTitle(teamName){
- groupName = teamName;
- document.querySelector("h1").innerText = teamName || "";
- }
-
- /**
- * 求助
- */
- function qiuzhu() {
- gotSelectDoc();
- }
-
- function gotSelectDoc(m){
- mui.openWindow('../../qzys/html/select_doctor.html', 'qzys-select_doctor', {
- extras: {
- consultInfo: consultInfo,
- accessData: {
- consultCode: consultInfo.consult,
- patient: consultInfo.patient
- }
- }
- });
- }
-
- function jieshu(){
- mui.confirm("结束咨询后,居民及所有医生均无法再次回复,是否确认继续结束?", "", ["继续结束", "我再看看"], function(e) {
- if(e.index == 0) {
- sendPost("doctor/consult/finish", {
- consult: consultInfo.consult
- }, null, function(res) {
- if(res.status == 200){
- $('.topmsg').html("咨询求助已结束");
- $('#input_div').hide();
- mui.toast("已结束该咨询");
- } else {
- mui.toast(res.msg)
- }
- });
- }
- })
- }
-
- $('#contain').on('tap', '.qiuzhu5', function(){
- var code = $(this).attr('data-code');
- mui.openWindow('../../message/html/qiuzhuqunliao.html', 'qiuzhuqunliao2', {
- extras: {
- groupCode: code
- }
- });
- })
-
- document.getElementById("qun_detail").addEventListener('tap', function() {
- var m = [];
- for(var k in members){
- members[k].code = members[k].memberCode;
- m.push(members[k]);
- }
- mui.openWindow({
- url: "../../tuandui/html/tuanduishezhi.html",
- id: "tuanduishezhi.html",
- extras: {
- teamName: groupName,
- members: m,
- type: 2
- }
- })
- });
-
- window.addEventListener('updateTeamName', function(e) {
- setTitle(e.detail.teamName)
- });
-
- window.addEventListener('getMember', function(e) {
- getMemberLs(1);
- });
|