| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 | var baseInfo = null,// 基础环境信息(包括当前webview)	teamCode,// 从缓存取出所选团队	self,	keyword, // 搜索关键字	type = 0, //类型	startDate = getDateBefore(6),	endDate = getNowDate();	var page1 = 1,    page2 = 1,    pagesize = 10,	$search = $('#search'), // 搜索框	scrollers = [],	loaded = [false, false];	// 选择血糖血压容器function selTypeDiv() {	if(type == 0) {		$("#viewTabs").find("li").eq(0).addClass("curr")		$(".selectDate li").first().addClass("curr");		$("#xuetangView").show();		$("#xueyaView").hide();	} else {		$("#viewTabs").find("li").eq(1).addClass("curr")		$(".selectDate").find("li").eq(4).addClass("curr");		$("#xuetangView").hide();		$("#xueyaView").show();	}}// 获取登录相关信息function getBaseInfo() {	self = plus.webview.currentWebview();	teamCode = self.teamCode;	type = self.type;	selTypeDiv();}function initPatientListByTeam(isInit) {    if(isInit){        if(type == 0){            page1 = 1;        }else{            page2 = 1;        }    }	var url = "/doctor/scheme/getTrackPatientIndexCountList";	plus.nativeUI.showWaiting();	sendGet(url, {	    type: type == 0 ? 1 : 2, 	    teamCode: teamCode, 	    startDate: startDate, 	    endDate: endDate, 	    keyword: keyword ? keyword : "",	    page: type == 0 ? page1 : page2, 	    size: pagesize	}, null, function(res) {		plus.nativeUI.closeWaiting();		$(".pullUp").hide();		$(".pullDown").hide();		if(res.status == 200) {			if(res.data.length > 0) {			    loaded[type] == true;				$("#XTlist").show();				$("#XYlist").show();				$(".no-result").hide();				var html = template('listDataToHtml', {data: res.data})				if(isInit) {				    if(type == 0){				        $("#XTlist").html(html);				    }else{				        $("#XYlist").html(html);				    }//				    scrollers[type].scrollTo(0,0,100);				} else {				    if(type == 0){                        $("#XTlist").append(html);                    }else{                        $("#XYlist").append(html);                    }				}				if(res.data.length < pagesize){				    scrollers[type].endPullupToRefresh(true);				}else{				    if(type == 0){                        page1 ++;                    }else{                        page2 ++;                    }                    scrollers[type].enablePullupToRefresh();				}			} else {				if(isInit) {				    if(type == 0){                        $("#XTlist").hide();                        $("#xuetangView .no-result").show();                    }else{                        $("#XYlist").hide();                        $("#xueyaView .no-result").show();                    }				} else {					mui.toast("暂无更多数据!");				}			}		} else {			mui.toast(res.msg);		}	}, true)}// 绑定页面事件function bindEvents() {	// 头像路径 	template.helper("getPatientImg", function(str){        if(str){            if(str.indexOf("../") > -1){                return str; //原福州代码中返回的相对路径            }            var url = getImgUrl(str);            return url;        }        return "";    });    // 搜索	$search.bind("input propertychange", function() {		keyword = $search.val();		initPatientListByTeam(true);	});	// 血糖血压切换	$(document).on("tap", "#viewTabs li", function() {		$(this).addClass("curr").siblings().removeClass("curr");		$(".selectDate").children().removeClass("curr");		type = $(this).index();		selTypeDiv();				if(!loaded[type]){		    startDate = getDateBefore(6);            initPatientListByTeam(true);		}	});	// 天数选择	$(document).on("tap", ".selectDate li", function() {		var days = $(this).attr("data-days");		startDate = getDateBefore(days);		$(this).addClass("curr").siblings().removeClass("curr");		page = 1;		initPatientListByTeam(true);	});	// 血糖时间段切换//	$(document).on("tap", "#duringList li", function() {//		$(this).addClass("curr").siblings().removeClass("curr");//	})	// 跳转个人血糖记录页	$(document).on("tap", "#XTlist li", function() {		var patient = $(this).attr("data-patient");		openWebview("xuetang-view.html",{            code: patient,            dateT: endDate        });	})	// 跳转个人血压记录页	$(document).on("tap", "#XYlist li", function() {		var patient = $(this).attr("data-patient");		openWebview("xueya-view.html",{            code: patient,            dateT: endDate        });	})}function initScroll(){    $.each(document.querySelectorAll('.mui-scroll-wrapper'), function(index, pullRefreshEl) {            var pullRefresh = mui(pullRefreshEl).pullRefresh({                down:{                    callback: function(){                        var self = this;                        setTimeout(function(){                            initPatientListByTeam(true);                            self.endPulldownToRefresh();                        }, 300);                    }                },                up: {                    callback: function(){                        var self = this;                        setTimeout(function(){                            initPatientListByTeam(false);//                          self.endPullupToRefresh();                        }, 300);                    }                }            });            scrollers.push(pullRefresh);        })}// 页面业务处理流程开始new Promise(function(resolve, reject) {	mui.plusReady(function() {		resolve(true);	})}).then(function() {	getBaseInfo();}).then(function() {	bindEvents();	initScroll();	initPatientListByTeam(true);}).catch(function(e) {	plus.nativeUI.closeWaiting();	console && console.error(e);})
 |