123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- var page = 1,
- pageSize = 10,
- dateVal,
- statusVal,
- typeVal,
- scroller;
- mui.init();
- mui.plusReady(function(){
- var self = plus.webview.currentWebview();
- dateVal = self.dateVal || 1;
- statusVal = self.statusVal;
- typeVal = self.typeVal;
-
- if(self.dateName == "全部"){
- self.dateName = "今日未测量";
- }
- $("#dateName").text(self.dateName);
- $("#statusName").text(self.statusName);
- $("#typeName").text(self.typeName);
-
- if(dateVal){
- $("#dateSheet li[data-val="+dateVal+"]").find("a").addClass("active");
- }else{
- $("#dateSheet li").eq(0).find("a").addClass("active");
- }
-
- if(statusVal){
- $("#statusSheet li[data-val="+statusVal+"]").find("a").addClass("active");
- }else{
- $("#statusSheet li").eq(0).find("a").addClass("active");
- }
- if(typeVal){
- $("#typeSheet li[data-val="+typeVal+"]").find("a").addClass("active");
- }else{
- $("#typeSheet li").eq(0).find("a").addClass("active");
- }
-
- getData(true);
- bindEvents();
- initScroller();
- })
- //获得居民列表
- function getData(isInit){
- if(isInit){
- page = 1;
- }
- var url = "doctor/device/getDevicesList",
- params = {
- noGaugeDay: dateVal,//未测量天数(1今日为测量 2七天未测量 3本月未测量 4超过一个月未测量)
- isBinding: statusVal, //是否绑定(1绑定 2解绑)
- categoryCode: typeVal, //设备类型(1血糖仪 2血压计)
- isSend: 1, //今日是否已发送提醒消息(1已发送)
- page: page,
- pageSize: pageSize
- };
-
- plus.nativeUI.showWaiting();
- sendGet(url, params, null,function(res){
- if(res.status == 200){
- $("#count").text("("+res.data.tatalCount+")");
- var list = res.data.data;
- if(list.length == 0){
- if(isInit){
- $("#result_wrapper").hide();
- $("#no_result_wrap").show();
- }else{
- scroller.endPullupToRefresh(true);
- }
- }else{
- $("#result_wrapper").show();
- $("#no_result_wrap").hide();
-
- var html = template("li-tmp", {list: list});
- if(isInit){
- $("#result_wrapper").empty().append(html);
- }else{
- $("#result_wrapper").append(html);
- }
-
- if(list.length < pageSize){
- scroller.endPullupToRefresh(true);
- }else{
- page ++;
- if(isInit){
- scroller.refresh(true);
- }else{
- scroller.endPullupToRefresh(false);
- }
- }
- }
- }else{
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }, true);
- }
- //发送消息
- function sendMessage(){
- var data = [],
- $inputs = $("input[name=patient]:checked"),
- len = $inputs.length;
- for(i=0; i<len; i++){
- var obj = $($inputs[i]).data("json");
- data.push({
- patient: obj.patient,
- deviceSn: obj.device_sn,
- deviceName: obj.device_name,
- categoryCode: obj.category_code
- });
- }
- var url = "doctor/device/sendDeviceWxMessage",
- params = {
- data: JSON.stringify(data),
- };
- plus.nativeUI.showWaiting();
- sendPost(url, params, null, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- mui.toast(res.msg);
- scroller.scrollTo(0,0,100);
- getData(true); //刷新页面数据
- }else{
- mui.toast(res.msg);
- }
- })
- }
- function bindEvents(){
- $("#dateName").on('click', function(){
- mui('#dateSheet').popover('toggle');
- });
- $("#statusName").on('click', function(){
- mui('#statusSheet').popover('toggle');
- });
- $("#typeName").on('click', function(){
- mui('#typeSheet').popover('toggle');
- });
- $("#patientNumber").on('click', function(){
- mui('#numberSheet').popover('toggle');
- })
- //选择日期选项
- $(".date-item").on('tap', function(){
- var $this = $(this),
- value = $this.attr("data-val"),
- text = $this.find("a").text();
-
- if(value == dateVal){
- mui('#dateSheet').popover('toggle');
- return false;
- }
- dateVal = value;
- $this.find("a").addClass("active");
- $("#dateName").text(text);
- mui('#dateSheet').popover('toggle');
- scroller.scrollTo(0, 0, 500);
- getData(true);
- });
-
- //选择状态
- $(".status-item").on('tap', function(){
- var $this = $(this),
- value = $this.attr("data-val"),
- text = $this.find("a").text();
-
- if(value == statusVal){
- mui('#dateSheet').popover('toggle');
- return false;
- }
- statusVal = value;
- $("#statusName").text(text);
- mui('#statusSheet').popover('toggle');
- scroller.scrollTo(0, 0, 500);
- getData(true);
- });
-
- //选择设备类型
- $(".type-item").on('tap', function(){
- var $this = $(this),
- value = $this.attr("data-val"),
- text = $this.find("a").text();
-
- if(value == typeVal){
- mui('#dateSheet').popover('toggle');
- return false;
- }
- typeVal = value;
- $("#typeName").text(text);
- mui('#typeSheet').popover('toggle');
- scroller.scrollTo(0, 0, 500);
- getData(true);
- });
-
- //复选框点击事件
- $("input[name=checkAll]").on('change', function(){
- var $this = $(this);
- if($this.prop("checked")){
- $("input[name=patient]").prop("checked", true);
- }else{
- $("input[name=patient]").prop("checked", false);
- }
- checkSendBtnEnable();
- });
-
- $("#result_wrapper").on('change', "input[name=patient]", function(){
- var $checkedList = $("input[name=patient]:checked"),
- len = $checkedList.length,
- $allInputs = $("input[name=patient]"),
- allLen = $allInputs.length;
-
- if(len == allLen){
- $("input[name=checkAll]").prop("checked", true);
- }else{
- $("input[name=checkAll]").prop("checked", false);
- }
- checkSendBtnEnable();
- });
-
- //发送消息
- $(".header-link").on('click', function(){
- if($(this).hasClass("disabled")){
- return false;
- }
- sendMessage();
- })
- }
- function checkSendBtnEnable(){
- var $checkedList = $("input[name=patient]:checked"),
- len = $checkedList.length;
-
- if(len > 0){
- $(".header-link").removeClass("disabled");
- }else{
- $(".header-link").addClass("disabled");
- }
- }
- function initScroller(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
-
- scroller = mui(".mui-scroll-wrapper").pullRefresh({
- down:{
- callback: function(){
- getData(true);
- this.endPulldownToRefresh();
- }
- },
- up: {
- callback: function(){
- getData(false);
- }
- }
- })
- }
|