123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- mui.init();
- var page = 0,
- pageSize = 10,
- patient,
- patientName,
- isAdmin,
- pCodes, //从慢病管理页面中跳转过来的多个居民的code
- referrer;
-
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
- isAdmin = self.isAdmin;
- patient = self.patient;
- patientName = self.patientName;
- pCodes = self.pCodes;
- referrer = self.referrer;
-
- initScroller();
- getArticleList(true);
- bindEvents();
- })
- function getArticleList(isInit){
- if(isInit){
- page = 0;
- }
- var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
- var url = "doctor/jkEdu/article/PC/pushArticleList",
- params = {
- sendType: isAdmin? 2 : 1, //1医生 2卫计委(管理员)
- iDisplayStart: page * pageSize,
- iDisplayLength: pageSize,
- currentRoleCode: docInfo.hospital,
- currentRoleLevel: 4
- };
- if(isAdmin){
- var selectedRole = JSON.parse(plus.storage.getItem("selectedRole"));
- params.currentRoleCode = selectedRole.code;
- params.currentRoleLevel = selectedRole.level;
- }
- sendGet(url, params, null, function(res){
- if(res.status > 0){
- var list = res.data.aaData;
- if(isInit){
- if(list.length == 0){
- $(".mui-table-view").hide();
- $(".no-result").show();
- }else{
- var html = template("articleimgLi", {list: list});
- $(".mui-table-view").empty().append(html);
- }
- }else{
- var html = template("articleimgLi", {list: list});
- $(".mui-table-view").append(html);
- }
- if(list.length < pageSize){
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }else{
- page ++;
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false);
- }
- }else{
- mui.toast(res.message);
- }
- }, true);
- }
- function bindEvents(){
- $("body").on('tap', ".article-info", function(){
- 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,
- showHandleBar: true,
- pCodes: self.pCodes,
- referrer: self.referrer
- });
- }
- return false;
- });
-
- 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+"'>";
- }
- return "";
- });
-
- window.addEventListener('reload', function(){
- getArticleList(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(){
- getArticleList(true);
- this.endPulldownToRefresh();
- }
- },
- up: {
- callback: function(){
- var self = this;
- setTimeout(function(){
- getArticleList(false);
- }, 500);
- }
- }
- })
- }
|