123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- var now = new Date(),
- patiCode,
- deviceSn,
- type,
- unit;
- mui.init();
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
-
- patiCode = self.patiCode;
- deviceSn = self.deviceSn;
- type = self.type;
-
- $("#title").text(self.deviceName);
- if(type == 1){
- unit = "mmol/L";
- }else if(type == 2){
- unit = "mmHg";
- }
-
- //获取近半年的月份信息
- getMonth();
- bindEvents();
- templateHelper();
- });
- function getMonth(){
- var list = [];
- for(i=0; i<6; i++){
- var d = new Date();
- d.setMonth(now.getMonth() - i);
- list.push(d.format("yyyy-MM"));
- }
- var html = template("month-tmp", {list: list});
- $("#content").empty().append(html);
- }
- function getMonthDate(month){
- var lastDate = getMonthLastDate(month),
- days = lastDate.getDate(),
- dateList = [];
-
- if(now.getMonth() == lastDate.getMonth()){
- var days2 = now.getDate();
- for(i=0; i<days2; i++){
- var e = new Date(month);
- e.setDate(now.getDate() - i);
- dateList.push(e.format("yyyy-MM-dd"));
- }
- }else{
- for(i=0; i<days; i++){
- var e = new Date(month);
- e.setDate(lastDate.getDate() - i);
- dateList.push(e.format("yyyy-MM-dd"));
- }
- }
- var html = template("date-tmp", {list: dateList});
- $("#"+month).empty().append(html);
- }
- //获取当月的天数
- function getMonthLastDate(month){
- var d = new Date(month),
- year = d.getFullYear(),
- month = d.getMonth() + 1;
- var d2 = new Date(year, month, 0);
- return d2;
- }
- function getMonthDateData(month){
- var url = "doctor/health_index/getHealthDateAll",
- params = {
- patientCode: patiCode,
- deviceSn: deviceSn,
- choseMonth: month,
- type: type
- };
-
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- var list = res.data;
- if(list.length == 0){
- $("#"+month+" .no-record").show();
- }else{
- $("#"+month+" .no-record").hide();
- var html = template("date-tmp", {list: list});
- $("#"+month).append(html);
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- function getDateRecords(date){
- var url = "doctor/health_index/patientHealthIndexByDateAndDeviceSn",
- params = {
- patientCode: patiCode,
- deviceSn: deviceSn,
- choseDay: date,
- type: type
- };
-
- plus.nativeUI.showWaiting();
- sendGet(url, params, null, function(res){
- if(res.status == 200){
- var list = res.data,
- $ul = $(".record-list[data-date="+date+"]");
- if(list.length == 0){
- $ul.find(".no-record").show();
- }else{
- $ul.find(".no-record").hide();
- var html = "";
- if(type == "1"){
- html = template("record-tmp", {list: list, unit: unit});
- }else if(type == "2"){
- html = template("record2-tmp", {list: list, unit: unit});
- }
- $ul.append(html);
- }
- plus.nativeUI.closeWaiting();
- }else{
- plus.nativeUI.closeWaiting();
- mui.toast(res.msg);
- }
- }, true);
- }
- function bindEvents(){
- $("#content").on('click', ".month", function(){
- var $this = $(this),
- month = $this.attr("data-val");
- if($this.hasClass("active")){
- $this.removeClass("active");
- $this.find(".fa").removeClass("fa-angle-up").addClass("fa-angle-down");
- $this.parent().find(".date-list").hide();
- return false;
- }
- var $activeMonth = $(".month.active");
- if($activeMonth.length > 0){
- $activeMonth.removeClass("active");
- $activeMonth.find(".fa").removeClass("fa-angle-up").addClass("fa-angle-down");
- $activeMonth.parent().find(".date-list").hide();
- }
- $this.addClass("active");
- $this.find(".fa").removeClass("fa-angle-down").addClass("fa-angle-up");
- $this.parent().find(".date-list").show();
-
- if($this.parent().find(".date-panel").length > 0){
- return false;
- }
- getMonthDateData(month);
- });
-
- $("#content").on('click', ".date", function(){
- var $this = $(this),
- date = $this.attr("data-val");
-
- if($this.hasClass("active")){
- $this.removeClass("active");
- $this.find(".fa").removeClass("fa-angle-up").addClass("fa-angle-down");
- $this.parent().find(".record-list").hide();
- return false;
- }
- var $activeDate = $this.parent().parent().find(".date.active");
- if($activeDate.length > 0){
- $activeDate.removeClass("active");
- $activeDate.find(".fa").removeClass("fa-angle-up").addClass("fa-angle-down");
- $activeDate.parent().find(".record-list").hide();
- }
- $this.addClass("active");
- $this.find(".fa").removeClass("fa-angle-down").addClass("fa-angle-up");
- $this.parent().find(".record-list").show();
- if($this.parent().find(".record").length > 0){
- return false;
- }
- getDateRecords(date);
- });
-
- $(".header-link").on('click', function(){
- openWebview("../../huanzhe/html/huanzhexinxi.html",{
- patiCode: patiCode
- });
- })
- }
- function templateHelper(){
- template.helper("getTime", function(str){
- var s = str.replace(/\-/g, "/");
- var d = new Date(s);
- return d.format("hh:mm");
- });
-
- template.helper("getTypeName", function(gi_type){
- switch(gi_type){
- case "1":
- return "早餐前";
- break;
- case "2":
- return "早餐后";
- break;
- case "3":
- return "午餐前";
- break;
- case "4":
- return "午餐后";
- break;
- case "5":
- return "晚餐前";
- break;
- case "6":
- return "晚餐后";
- break;
- case "7":
- return "睡前";
- break;
- }
- });
-
- template.helper("getXTValue", function(val, type){
- val = parseFloat(val);
- var min = 0,
- max = 0;
- switch(type){
- case "1":
- case "3":
- case "5":
- case "7":
- min = 4,
- max = 7;
- break;
- case "2":
- case "4":
- case "6":
- min = 4,
- max = 11.1;
- break;
- }
- if(val < min){
- return '<i class="fa fa-long-arrow-down c-green"></i><span class="c-green ml10">'+val+unit+'</span>';
- }else if(val > max){
- return '<i class="fa fa-long-arrow-up c-red"></i><span class="c-red ml10">'+val+unit+'</span>';
- }else{
- return val+unit;
- }
- });
-
- template.helper("getXYValue", function(val, type){
- val = parseFloat(val);
- var min, max;
- if(type = 1){
- min = 90;
- max = 140;
- }else{
- min = 60;
- max = 90;
- }
- if(val < min){
- return '<i class="fa fa-long-arrow-down c-green"></i><span class="c-green ml10">'+val+unit+'</span>';
- }else if(val > max){
- return '<i class="fa fa-long-arrow-up c-red"></i><span class="c-red ml10">'+val+unit+'</span>';
- }else{
- return val+unit;
- }
- })
-
- }
|