123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- // 基本信息(包括userAgent、上个页面传递的数据)
- var baseInfo = null,
- // 基础环境信息(包括当前webview)
- baseEnv = null;
- var $eventListWrapper = $('#recent_event_list_wrap'),
- $eventList = $('#recent_event_list'),
- // 搜索无结果时显示
- $noResultWrap = $('#no_result_wrap');
- // 分页查询当前页数
- var curPage = 1,
- pagesize = 50, //实际接口并没有分页
- // iscroll 滚动条实例
- iscroller;
- template.helper("toJson", function(v, i) {
-
- return JSON.stringify(v);
- });
-
- // 获取基本信息(包括userAgent、上个页面传递的数据)
- var getBaseInfoPromise = function() {
- // 登录的相关信息
- var userAgent = plus && JSON.parse(plus.storage.getItem("userAgent"))
- return {
- userAgent: userAgent,
- patiInfo: baseEnv.webview.patiInfo
- }
- },
- // 获取基础环境信息
- getBaseEnvPromise = function () {
-
- var env = {
- webview: plus&&plus.webview.currentWebview()
- };
- return Promise.resolve().then(function(res) {
- return env;
- });
- },
- // 分页查询列表
- searchByPaging = function (isInit) {
- plus.nativeUI.showWaiting();
- var url = healthProfileServer+"doctor/health_record/list_medical",
- params = {
- patient: baseInfo.patiInfo.code,
- pageIndex: curPage,
- pageSize: pagesize
- };
- if(isInit){
- curPage = 1;
- }
- getReqPromise(url,params,'POST').then(function(res){
- if(res.status == 200) {
- var list = res.list;
- if(!list || !list.length) {
- $eventList.hide();
- $noResultWrap.show();
- checkIsReminded();
- } else {
- $noResultWrap.hide();
- $eventList.show();
-
- var html = template("recent_event_tmpl", {list: list});
- if(isInit){
- if(list.length > 0){
- var zuiyinTime = list[0].medicalTime.toString().split(" ")[0];
- var days = tab(zuiyinTime,new Date());
- if(days >= 365){
- checkIsReminded();
- }else{
- $("#jktj_tx").hide();
- }
- }
- $eventList.empty().append(html);
- }else{
- $eventList.append(html);
- }
- if(list.length == pagesize){
- curPage ++;
- }else{
- mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(true);
- }
- }
- } else {
- mui.toast(res.msg);
- }
- plus.nativeUI.closeWaiting();
- }).catch(function(e) {
- console && console.error(e)
- });
- },
- // 滚动条分页实例初始化
- initScroller = function() {
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- iscroller = mui('.mui-scroll-wrapper').pullRefresh({
- down: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- searchByPaging(true);
- self.endPulldownToRefresh();
- }, 500);
- }
- },
- /* 实际接口并没有处理分页
- up:{
- callback: function(){
- var self = this;
- setTimeout(function(){
- searchByPaging();
- self.endPullupToRefresh();
- }, 500);
- }
- }*/
- });
- },
- //判断是否7天内提醒过居民
- checkIsReminded = function(){
- var url = "/doctor/patient_label_info/isRemind",
- params = {patient: baseInfo.patiInfo.code};
- sendGet(url, params, null, function(res){
- if(res.status==200){
- //data 0表示没提醒过,1表示7天内已提醒过 2年龄不到65岁
- if(res.data == 0){
- $("#jktj_tx").html("提醒体检");
- }else if(res.data == 1){
- $("#jktj_tx").html("已提醒");
- }else if(res.data == 2){
- $("#jktj_tx").hide()
- }
- } else {
- mui.toast(res.msg);
- }
- });
- },
- // 绑定页面事件
- bindEvents = function () {
- $eventList.on('tap','li',function() {
- var data = JSON.parse($(this).attr("data-json"));
- openWebview("jiankangtijianxiangqing.html",{eventInfo: data,patiInfo: baseInfo.patiInfo});
- });
- $('#jktj_tx').on("tap", function(e){
- var url = "/doctor/patient_label_info/isRemind",
- params = {patient: baseInfo.patiInfo.code};
- sendGet(url, params, null, function(res){
- if(res.status==200){
- //data 0表示没有提醒过 1表示7天内提醒过
- if(res.data == 0){
- mui.confirm("是否向居民发送体检提醒消息?", "提示", ["立即提醒", "不了,谢谢"], function(e){
- if(e.index == 0){
- tixingJm();
- }
- })
- }else{
- mui.toast("七天内已提醒过该居民,请不要重复提醒");
- }
- } else {
- mui.toast(res.msg);
- }
- });
-
- })
- };
- function tab(date1,date2){
- var time =0;
- var days =0;
- var oDate1 = new Date(date1);
- var oDate2 = new Date(date2);
- start =oDate1.getTime();
- end =oDate2.getTime();
- time = end - start;
- days = Math.floor(time/86400000);
- return days;
- };
- function tixingJm(){
- plus.nativeUI.showWaiting();
- sendPost("/doctor/patient_label_info/singleRemindPhyExam", {patient: baseInfo.patiInfo.code}, null, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- mui.toast("提醒成功");
- $('#jktj_tx').html("已提醒");
- }
- else {
- mui.toast(res.msg);
- }
- })
- }
- // 页面业务处理流程开始
- new Promise(function(resolve, reject) {
- // TODO 临时放开
- //resolve(true);
- mui.plusReady(function() {
- // plus已经准备好,可以往下执行
- resolve(true);
- });
- }).then(function() {
- // plus.nativeUI.showWaiting();
- // 获取基础环境信息
- return getBaseEnvPromise().then(function(env) {
- baseEnv = env;
- }).then(function() {
- // 获取登录医生信息
- baseInfo = getBaseInfoPromise();
- initScroller();
- searchByPaging(true);
- // 绑定页面事件
- bindEvents();
- })
- }).catch(function(e) {
- plus.nativeUI.closeWaiting();
- console && console.error(e);
- });
|