| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 | mui.init();var page = 0,     pageSize = 10,    patient,    patientName,    isAdmin,    pCodes,    referrer;var back = mui.back;mui.back = function(){    var self = plus.webview.currentWebview(),        opener = self.opener();    if(opener){        mui.fire(opener, 'reload');    }    back();}mui.plusReady(function(){    var self = plus.webview.currentWebview();    isAdmin = self.isAdmin;    patient = self.patient;    patientName = self.patientName;    pCodes = self.pCodes;    referrer = self.referrer;    getList(true);    initScroller();    bindEvents();});function getList(isInit){    if(isInit){        page = 0;    }    var url = "/third/jkEdu/Article/getCollectionArticalList",        params = {            articleState: 1, // 1-正常,2-删除,3-草稿            pageIndex: page,            pageSize: pageSize,            userType: 1 //1医生,2居民        };    if(patient){        params.patient = patient;    }        sendGet(url, params, null, function(res){        if(res.status == 200){            if(isInit && res.data.length == 0){                $("#articleList").hide();                $(".no-result").show();            }else{                var html = template('li-tmp', {list : res.data});                if(isInit){                    $("#articleList").empty().append(html);                }else{                    $("#articleList").append(html);                }                                if(res.data.length < pageSize){                    mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(true);                }else{                    mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(false);                    page ++;                }            }        }else{            mui.toast(res.msg);        }    }, true);}/* * 取消收藏文章 */function unCollectionArticle(code,$this){    plus.nativeUI.showWaiting();    var params = {};    params.articleId=code;    params.userType = 1; //1医生,2居民    sendPost("/third/jkEdu/Article/cancelArticleCollection",params,function(res){        plus.nativeUI.closeWaiting();        if(res.msg){                        plus.nativeUI.toast(res.msg);        }else{            plus.nativeUI.toast("取消收藏失败!");        }       },function(res){        plus.nativeUI.closeWaiting();        if(res.status==200){            var $li = $this.closest('.article-li');            $li.remove();            plus.nativeUI.toast("取消收藏成功");                        var $lis = $(".article-li"),                len = $lis.length;            if(len == 0){                $("#articleList").hide();                $(".no-result").show();            }        }else{            if(res.msg){                plus.nativeUI.toast(res.msg);            }else{                plus.nativeUI.toast("取消收藏失败!");            }           }            })}//弹框提示是否发送给居民function showDialog(article,title,patientName) {    dialog({        title: '<div><div class="c-f18 c-17b3ec c-t-left">发送给</div><div class="mt5 c-f14 c-t-left c-909090">'+patientName+'</div></div>',        content: '<div><div class="c-f16 c-323232 c-t-left mb10">《'+title+'》</div><input id="messageInput" class="c-f14 pl10" placeholder="给居民留言..."/></div>',        okValue: '立即发送',        cancelValue: '我再看看',        cancel: function () {            return;        },        ok: function() {            send(article);        }    }).showModal();}//发送文章给患者function send(article){    var url = "/doctor/jkEdu/article/doctorSendArticleToPatients",        params = {            articleId: article,            patient: patient,            leaveWords: $.trim($('#messageInput').val())        };    if(pCodes){        params.patient = pCodes.join(",");    }    var docInfo = JSON.parse(plus.storage.getItem('docInfo'));    params.currentUserRole = docInfo.hospital;    params.currentUserRoleLevel = 4;        plus.nativeUI.showWaiting();    sendPost(url, params, null, function(res){        if(res.status == 10000){            mui.toast("发送成功!");            var $this = $(".share[data-code="+article+"]");                        if(!pCodes){                $this.after('<div class="sent-flag"><span class="c-fff c-f14 ml10">已发送</span></div>');            }            var num = $this.find(".send_count").text();            $this.find(".send_count").text(parseInt(num)+1);            if(referrer == "manbing"){                var self = plus.webview.currentWebview(),                    selfId = self.id;                backToManbingPage(self, selfId);            }        }else{            if(res.msg){                mui.toast(res.msg);            }else{                mui.toast("发送失败!");            }          }        plus.nativeUI.closeWaiting();    });}function bindEvents(){    $("#articleList").on('tap', ".article-info", function(e){        e.stopPropagation();        var code = $(this).attr("data-article-code");        var title = $(this).attr('data-title');        if(isAdmin){            openWebviewExtras("../../home/html/jianjiaotuisong-xiangqing.html",{articleId:code});        }else{            openWebview("article-info.html", {                articleId:code,                patient: patient,                 patientName: patientName,                pCodes: pCodes,                showHandleBar: true,                referrer: referrer            })        }        return false;    }).on('tap','div.collect', function(e){        e.stopPropagation();        var $this = $(this);        var code = $this.attr("data-code");        unCollectionArticle(code,$this);    }).on('tap','div.share', function(e){        e.stopPropagation();        var $this = $(this);        var code = $this.attr("data-code");        var title = $this.attr("data-title");        if(isAdmin){            openWebviewExtras("../../home/html/tuisong_duixiang.html",{articleId:code});        }else{            if(!patient){                if(pCodes){                    dialog({                        title: '<div><div class="c-f18 c-17b3ec c-t-left">发送给</div><div class="mt5 c-f14 c-t-left c-909090">'+pCodes.length+'人</div></div>',                        content: '<div><div class="c-f16 c-323232 c-t-left mb10">《'+title+'》</div><input id="messageInput" class="c-f14 pl10" placeholder="给居民留言..."/></div>',                        okValue: '立即发送',                        cancelValue: '我再看看',                        cancel: function () {                            return;                        },                        ok: function() {                            send(code);                        }                    }).showModal();                    return false;                }else{                    openWebview("xuanzejumin_more.html", {                        article: code,                        articleTitle: title,                        origin: 'jiaoyu'                    });                }            }else{                showDialog(code,title,patientName);            }        }    });        template.helper("setContent", function(str){        if(str){            var reg=/<[^<>]+>/g;            str = str.replace(reg, '');            return str;        }else{            return "";        }            });        template.helper("getArticleImage", function(str){        if(str){            if(str.indexOf("../") > -1){                return ""; //原福州代码中返回的相对路径            }            var url = getImgUrl(str);            return "<img src='"+url+"' width='80' height='80'>";        }        return "";    })        window.addEventListener("refresh", function(e){        getList(true);    })}function initScroller(){    //阻尼系数    var deceleration = mui.os.ios?0.003:0.0009;    mui('.mui-scroll-wrapper').scroll({        bounce: false,        indicators: true, //是否显示滚动条        deceleration:deceleration    });        mui('.mui-scroll-wrapper').pullRefresh({        down: {            callback: function(){                getList(true);                this.endPulldownToRefresh();            }        },        up: {            callback: function(){                var self = this;                setTimeout(function(){                    getList(false);                    self.endPullupToRefresh();                }, 500);            }        }    });}function backToManbingPage(wv, selfId){    var targetId = "zhongdiangenzong";    if(wv.id == targetId){        setTimeout(function(){            plus.webview.getWebviewById(selfId).close();        }, 300);    }else{        var opener = wv.opener();        if(wv.id != selfId){            wv.close();        }        backToManbingPage(opener, selfId);    }}
 |