123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- var myScroll, page = 1,self;
- var unReadCount = 0; //标记未读消息数量
- var doctorCode;
- mui.plusReady(function() {
- self = plus.webview.currentWebview();
- backParent();
-
- myScroll = $('#lscroll').lscroll({pullUpAction: function(g){
- getMsgLs(page);
- }, top: 46});
- getMsgLs(1, true);
- doctorCode = JSON.parse(plus.storage.getItem("docInfo")).code;
- });
- function getMsgLs(curpage, isRefresh){
- var pagesize = 10;
- plus.nativeUI.showWaiting();
- // sendPost("doctor/message/findMessage", {
- //新的接口
- sendGet("/doctor/message/getSystemMessage",{
- // type: 3,
- // id: lastId,
- page: curpage,
- pagesize: pagesize
- }, null, function(res) {
- if (res.status == 200) {
- plus.nativeUI.closeWaiting();
- if (page == 1 && res.list.length == 0) {
- $("#wushuju").removeClass("c-hide");
- $('#list').hide();
- return;
- }
- $("#wushuju").addClass("c-hide");
- for(i = 0; i< res.list.length; i++){
- if(res.list[i].read == 1){
- unReadCount += 1;
- }
- }
- if(unReadCount > 0){
- $("#read_btn").removeClass("disabled");
- }
- if(isRefresh){
- $("#lscroll").empty().append(template("sign_tmpl", res));
- }else{
- $("#lscroll").append(template("sign_tmpl", res));
- }
-
- myScroll.refresh(res.list.length<pagesize);
- page = page + 1;
- } else
- mui.toast("加载消息出错!");
-
- })
-
- }
- mui("#list").on("tap", ".msg-box", function() {
- var $dom = $(this);
- if($dom.hasClass('new-msg')){
- sendPost("/doctor/message/read_health", {msgid: $(this).attr('data-code')}, null, function(res){
- if(res.status==200){
- $dom.removeClass('new-msg');
- $dom.addClass('bg-fff');
- //添加类型判断
- var type = $dom.attr("data-type"),
- dstr = $dom.attr("data-date");
- if(type == 4){ //随访消息
- var date = dstr.substr(0,4)+"/"+dstr.substr(5,2)+"/"+dstr.substr(8,2);
- mui.openWindow("../../suifang/html/index.html",'index',{extras:{date:date}});
- }else if(type == 5){//咨询
- var count = parseInt($dom.attr("data-count"));
- var sessionid = $dom.attr("data-sessionid");
- var sessionname = $dom.attr("data-sessionname");
-
- if(count == 1){
- openWebview("p2dzixun.html",{type: 2, sessionId: sessionid, sessionName: sessionname});
- }else{
- openWebview("../../xiaoxi/html/jiankangzixun.html");
- }
- }else if(type == 8){ //续方分配配送员
- var docCode = $dom.attr("data-receiver"),
- teamInfo = JSON.parse(plus.storage.getItem("teamInfo")),
- teamCode;
- for(var i=0; i<teamInfo.data.length; i++){
- var item = teamInfo.data[i];
- if(item.leaderCode == docCode){
- teamCode = item.id;
- break;
- }
- }
- openWebview('../../prescription/html/daifenpei.html', {
- teamCode: teamCode
- })
- }else if(type == 9){ //线下调整
- mui.openWindow({
- id: "change-chufang1",
- url: "../../prescription/html/change-chufang1.html",
- extras: {
- prescriptionCode:$dom.attr("data-relationcode")
- }
- })
- } else if(type == 10 || type == 11){ //意见反馈,账号申诉
- var fbType = type == 10 ? 2 : 1;
- mui.openWindow({
- id: "feedback-detail.html",
- url: "../../mine/html/feedback-detail.html",
- extras: {
- type: fbType,
- code: $dom.attr("data-relationcode")
- }
- })
- }else if(type == 13){ //产检记录
- mui.openWindow({
- id: "yunjianjihua",
- url: "../../fybj/html/yunjianjihua.html",
- extras: {
- patiCode: $dom.attr('pati-code'),
- doctorCode:doctorCode
- }
- })
- }
- else{
- mui.openWindow({
- id: "zhuanyijumin",
- url: "../../search/html/zhuanyijumin.html",
- extras: {
- type: "分配",
- }
- });
- }
- } else {
- mui.toast(res.msg);
- }
- })
- } else{
- //添加类型判断
- var type = $dom.attr("data-type"),
- dstr = $dom.attr("data-date");
- if(type == 4){ //随访
- var date = dstr.substr(0,4)+"/"+dstr.substr(5,2)+"/"+dstr.substr(8,2);
- mui.openWindow("../../suifang/html/index.html",'index',{extras:{date:date}});
- }else if(type == 5){//咨询
- var count = parseInt($dom.attr("data-count"));
- var sessionid = $dom.attr("data-sessionid");
- var sessionname = $dom.attr("data-sessionname");
-
- if(count == 1){
- openWebview("p2dzixun.html",{type: 2, sessionId: sessionid, sessionName: sessionname});
- }else{
- openWebview("../../xiaoxi/html/jiankangzixun.html");
- }
- }else if(type == 8){ //续方分配配送员
- var docCode = $dom.attr("data-receiver"),
- teamInfo = JSON.parse(plus.storage.getItem("teamInfo")),
- teamCode;
- for(var i=0; i<teamInfo.data.length; i++){
- var item = teamInfo.data[i];
- if(item.leaderCode == docCode){
- teamCode = item.id;
- break;
- }
- }
- openWebview('../../prescription/html/daifenpei.html', {
- teamCode: teamCode
- })
- }else if(type == 9){ //线下调整
- mui.openWindow({
- id: "change-chufang1",
- url: "../../prescription/html/change-chufang1.html",
- extras: {
- prescriptionCode:$dom.attr("data-relationcode")
- }
- })
- }else if(type == 10 || type == 11){ //意见反馈,账号申诉
- var fbType = type == 10 ? 2 : 1;
- mui.openWindow({
- id: "feedback-detail.html",
- url: "../../mine/html/feedback-detail.html",
- extras: {
- type: fbType,
- code: $dom.attr("data-relationcode")
- }
- })
- }else if(type == 13){ //产检记录
- mui.openWindow({
- id: "yunjianjihua",
- url: "../../fybj/html/yunjianjihua.html",
- extras: {
- patiCode: $(this).attr('pati-code'),
- doctorCode:doctorCode
- }
- })
- }
- else{
- mui.openWindow({
- id: "zhuanyijumin",
- url: "../../search/html/zhuanyijumin.html",
- extras: {
- type: "分配",
- }
- });
- }
- }
- });
- $("#read_btn").on('tap', function(){
- var $this = $(this);
- if(!$this.hasClass("disabled")){
- plus.nativeUI.showWaiting();
- sendPost("doctor/message/setMessageReaded", {type: 3}, null, function(res){
- if(res.status == 200){
- $this.addClass("disabled");
- getMsgLs(1, true);
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- });
- }
- })
- function backParent(){
- var old_back = mui.back;
- mui.back = function() {
- if(self.opener()){
- mui.fire(self.opener(), "refresh");
- }
- old_back();
- }
- }
|