123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- var first = true, docInfo, teamInfo,thisTeamsId , leader;
- var $xfxx=$("[data-code='xfxx']");//续方
- //var $xtfw=$("[data-code='xtfw']");//协同
- var type;
- mui.plusReady(function() {
- docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- docinfo(docInfo);
- initScroll();
- juageLeader();
- page.init();
- teams = JSON.parse(plus.storage.getItem("teamInfo"));
- //控制协同
- // if(docInfo.hospital){
- // if(docInfo.hospital.substr(0,6) == '350211' && docInfo.level == 1){
- // $xtfw.show()
- // }else{
- // $xtfw.hide()
- // }
- // }else{
- // $xtfw.hide()
- // }
- })
- var page={
- $consultTeam:$("#consultTeam"),//咨询数
- $sign:$("#sign "), //签约
- $healthIndex:$("#healthIndex"),//健康指标
- $renewIdex:$("#renewIdex"),
- $xietong:$("#xietongNum"),
- init:function(){
- this.initData();
- // this.updateBadgeNumber();
- },
-
- //数据初始化
- initData:function(){
- var m=this;
- m.selectListSize();
-
- sendPost("doctor/baseinfo", null, function(res){
- mui.toast(res.msg);
- }, function(res){
- if(res.status==200){
- var data = res.data;
- if(data.isFamous!=1){
- $(".myzx").hide();
- }
- }
- }, null, null, true);
- },
-
- //查询未读消息数
- selectListSize:function(refresh){
- var m=this;
- sendPost("/doctor/message/messages",{}, function(){
- if(refresh)
- // myScroll.endPullDownToRefresh();
- mui.toast("数据加载失败,请检查网络无误后下拉刷新。");
- }, function(res){
- if(res.status=="200"){
- var lastMessage, p= {msg: "", msgTime: ""};
- if(res.data.consult && res.data.consult.amount>0){
- lastMessage = res.data.consult.lastMessage || p;
- m.$consultTeam.html(assesCount(res.data.consult.amount)).removeClass('c-hide')
- .prev().html(lastMessage.msgTime).removeClass('c-hide');
- $('#jkzx_lastMsg').html(lastMessage.msg).removeClass('c-hide');
- } else {
- m.$consultTeam.addClass('c-hide').prev().addClass('c-hide');
- $('#jkzx_lastMsg').addClass('c-hide');
- }
-
- if(res.data.concern && res.data.concern.amount>0){
- lastMessage = res.data.concern.lastMessage || p;
- var time = formatShowTime(lastMessage.msgTime);
- m.$sign.html(assesCount(res.data.concern.amount)).removeClass('c-hide')
- .prev().html(time).removeClass('c-hide');
- $('#sign_lastMsg').html(lastMessage.msg).removeClass('c-hide');
- } else {
- m.$sign.addClass('c-hide').prev().addClass('c-hide');
- $('#sign_lastMsg').addClass('c-hide');
- }
- // if(res.data.healthIndex && res.data.healthIndex.amount>0){
- // lastMessage = res.data.healthIndex.lastMessage || p;
- // var time = formatShowTime(lastMessage.msgTime);
- // m.$healthIndex.html(assesCount(res.data.healthIndex.amount)).removeClass('c-hide')
- // .prev().html(time).removeClass('c-hide');
- // $('#jktz_lastMsg').html(lastMessage.msg).removeClass('c-hide');
- // } else {
- // m.$healthIndex.addClass('c-hide').prev().addClass('c-hide');
- // $('#jktz_lastMsg').addClass('c-hide');
- // }
-
- //处理系统消息
- if(res.data.system && res.data.system.amount > 0){
- // $('.xitong p.msg-p').html(res.data.system.lastMessage.msg);
- var time = formatShowTime(res.data.system.lastMessage.msgTime);
- $('#xitong_date').html(time).removeClass("c-hide");
- if(res.data.system.amount >0){
- $('#xitong_index').html(res.data.system.amount).removeClass("c-hide");
- } else {
- $('#xitong_index').addClass("c-hide");
- }
-
- $('.xitong').show();
- } else {
- $('#xitong_index').addClass('c-hide').prev().addClass('c-hide');
- $('#xitong_lastcontent').addClass('c-hide');
- }
-
- //处理 续方消息
- // if (res.data.prescription && res.data.prescription.amount>0) {
- // $(".xfxx").attr('data-type', res.data.prescription.lastMessage.type);
- // lastMessage = res.data.prescription.lastMessage || p;
- // var time = formatShowTime(lastMessage.msgTime);
- // m.$renewIdex.html(assesCount(res.data.prescription.amount)).removeClass('c-hide')
- // .prev().html(time).removeClass('c-hide');
- // $('#xfxx_lastMsg').html(lastMessage.title).removeClass('c-hide');
- // }else{
- // m.$renewIdex.addClass('c-hide').prev().addClass('c-hide');
- // $('#xfxx_lastMsg').addClass('c-hide');
- // }
- //处理 协同消息
- // if (res.data.callService && res.data.callService.amount>0) {
- // lastMessage = res.data.callService.lastMessage || p;
- // var time = formatShowTime(lastMessage.msgTime);
- // m.$xietong.html(assesCount(res.data.callService.amount)).removeClass('c-hide')
- // .prev().html(time).removeClass('c-hide');
- // $('#xt-last').html(lastMessage.msg).removeClass('c-hide');
- // }else{
- // m.$xietong.addClass('c-hide').prev().addClass('c-hide');
- // $('#xt-last').addClass('c-hide');
- // }
-
- // if(res.data.famousConsult && res.data.famousConsult.amount>0){
- // lastMessage = res.data.famousConsult.lastMessage || p;
- // $('#myzx_index').html(assesCount(res.data.famousConsult.amount)).removeClass('c-hide')
- // .prev().html(lastMessage.msgTime).removeClass('c-hide');
- // $('#myzx_lastMsg').html(lastMessage.msg).removeClass('c-hide');
- // } else {
- // $('#myzx_index').addClass('c-hide').prev().addClass('c-hide');
- // $('#myzx_lastMsg').addClass('c-hide');
- // }
- //根据消息数显示红点
- var imMsgCount = JSON.parse(res.data.imMsgCount);
- var xiaoxiHtml = plus.webview.getWebviewById("xiaoxi.html");
- var mainHtml = plus.webview.getWebviewById("main");
- if(imMsgCount.patient>0 || imMsgCount.doctor>0||imMsgCount.patientEnd>0) {
- mui.fire(xiaoxiHtml, 'imMsgCount', imMsgCount);
- }
- if(res.data.concern.amount>0 || res.data.system.amount>0 || imMsgCount.patient>0 || imMsgCount.doctor>0 ){
- mui.fire(mainHtml, "showPoint");
- }else if(imMsgCount.patientEnd>0 &&imMsgCount.patient==0 &&imMsgCount.doctor==0){
- mui.fire(mainHtml, "showBluePoint");
- }else{
- mui.fire(mainHtml, "hidePoint");
- }
- if(xiaoxiHtml && (res.data.concern.amount>0 || res.data.system.amount>0)) {
- mui.fire(xiaoxiHtml, "xiaoxiweidu",{status:"1"});
- }else{
- mui.fire(xiaoxiHtml, "xiaoxiweidu",{status:"0"});
- }
- }
- // if(refresh)
- // myScroll.endPullDownToRefresh();
- }, null, null, true)
-
- },
-
- //刷新应用角标数字
- updateBadgeNumber:function(){
- var userId = plus.storage.getItem('im_userid');
- imClient.Application.getBadgeNo(userId, function(result) {
- try {
- if (result && result.badge != null) {
- plus.runtime.setBadgeNumber(result.badge);
- }
- } catch (e) {
-
- }
- })
- }
- }
- function assesCount(count){
- if(count>99)
- return "99+";
- return count;
- }
- var myScroll;
- /**
- * 初始化iscroll
- */
- function initScroll () {
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
-
- myScroll = mui(".mui-scroll").pullToRefresh({
- down: {
- callback: function() {
- var self = this;
- page.selectListSize(true);
- setTimeout(function(){
- self.endPullDownToRefresh();
- },1000)
- }
- }
- });
- }
- /**
- * 列表点击事件
- */
- var initListEvent = function(){
- $('#systemMsg').on('tap', 'li', function(e){
- var html = $(this).attr("data-html"),
- type = $(this).attr("data-type");
- if(html){
- openWebview(html,{type:type});
- }
- })
- }();
- function asessTime(timestamp, noSeconds){
- var today = new Date().format('yyyy-MM-dd');
- var date = new Date();
- date.setTime(timestamp);
- var dateStr = date.format('yyyy-MM-dd');
- if(!(today.substring(0,4) == dateStr.substring(0,4))){
- return dateStr;
- }
- if(today == dateStr){
- if(noSeconds){
- return date.format('hh:mm');
- }else
- return date.format('hh:mm:ss');
- }
- return date.format('MM-dd');
- }
- //显示时间
- function formatShowTime(time){
- var time = time.replace(/-/g,"/"),
- timestamp = new Date(time).getTime();
- return asessTime(timestamp, 1);
- }
- window.addEventListener("refresh", function(){
- page.selectListSize(false);
- });
- // 判断是否为团队长
- function juageLeader(){
- var leaderUrl = '/statistics/checkDoctorIsTeamLeder';
- var params = {};
- sendGet(leaderUrl,params,null,function(res){
- if (res.status == 200) {
- if ( res.data && res.data != null) {
- $xfxx.show();
-
- }if(leader==3 && res.data ==null ){
- $xfxx.show();
- }
- }
- })
- }
- function docinfo(data){
- return leader= data.level;
- }
|