123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- var d= dialog({contentType:'load', skin:'bk-popup'}).show();
- var pagetype = 28;
- var $records = $('#records'),
- $wrapper = $('#wrapper'),
- $content = $('.div-content'),
- $noResult = $('#no_result_wrap');
-
- var scrollIns = null;
- var page = 1;
- appendFamilyMember($('#memberContainer'),function(){
- queryInit();
- },function(){
- //判断有授权家人,修改样式
- if($('#memberContainer').is(':hidden')){
- $('#wrapper').css('top','0px');
- }else{
- $('#wrapper').css('top','90px');
- $('.vertical-line').css('top','90px');
- $('.no-result-img').css('margin-top','150px')
- }
- })
- function getYear(date) {
- if(date) {
- return date.substr(0,4);
- }
- return "";
- }
- function getMD(date) {
- if(date) {
- return date.substr(5,5);
- }
- return "";
- }
- function getEventTypeClass(type) {
- if(type=="1") {
- return "menzhen";
- } else if(type=="2"){
- return "zhuyuan";
- } else if(type == "3"){
- return "tijian";
- }
- return "menzhen";
- }
- function getEventTypeName(type) {
- if(type=="1") {
- return "门诊";
- } else if(type=="2"){
- return "住院";
- } else if(type == "3"){
- return "体检";
- }
- }
- function hasGroup(date) {
- var year = getYear(date),
- $year = $('.record-year[data-year="'+ year +'"]');
- if($year.length) {
- return true;
- }
- return false;
- }
- function updatePullUpText(scroller,list) {
- scroller.off('refresh');
- scroller.on('refresh',function() {
- var $wrap = $(scroller.wrapper),
- $pullupLabel = $wrap.find('.pullUpLabel');
- if(!list || !list.length) {
- $pullupLabel.text('没有更多');
- } else {
- $pullupLabel.text('上拉加载更多');
- }
- });
- }
- function parseToHtml(eventData) {
- var sortedEvents = _.sortBy(eventData.data,function(event) {
- return -Date.parse(event.eventDate)
- });
- var groupEvents = _.groupBy(sortedEvents,function(event) {
- return getYear(event.eventDate)
- });
- var years = _.chain(groupEvents).keys().sortBy(function(year) {
- return -year;
- }).value();
- _.each(years,function(year) {
- var yearHtml = '', html = '';
- if(!hasGroup(year)) {
- yearHtml = '<li class="record-year c-909090" data-year="'+year+'">'+year+'</li>'
- }
- html = template('li_tmpl', {list: groupEvents[year]});
- $records.append(yearHtml+html);
- })
- }
- function toJson(o) {
- if(o) {
- return JSON.stringify(o);
- }
- return "{}";
- }
- scrollIns = new IScrollPullUpDown('wrapper',{
- probeType:2,
- bounceTime: 250,
- bounceEasing: 'quadratic',
- mouseWheel:false,
- scrollbars:true,
- fadeScrollbars:true,
- click: true,
- interactiveScrollbars:false
- },null,function pullUpAction() {
- var lastTime = $records.find('li:last').attr('data-event-date');
- getReqPromise('patient/archives/event',{type:'',page:page+1,pageSize:10,lastTime: lastTime},'JSON','GET')
- .then(function(res) {
- if(res.status==200) {
- page++;
- parseToHtml(res)
- updatePullUpText(scrollIns.myScroll,res.data);
- setTimeout(function() {
- scrollIns.myScroll.refresh();
- },100)
- }
-
- }).catch(function(e) { console && console.error(e) });
- });
- checkUserAgent();
- function bindEvents() {
- $records.on('click','li[data-from="1"]',function() {
- var id = $(this).attr('data-id');
- var type=JSON.parse($(this).attr('data-json')).eventType; //cy
- function checkSign(){
- d.show();
- var userAgent = window.localStorage.getItem(agentName);
- if(userAgent){
- var data = {};
- $.ajax(server + "patient/is_sign", {
- data: data,
- type: 'POST',
- dataType: 'json',
- beforeSend: function(request) {
- request.setRequestHeader("userAgent", userAgent);
- },
- error: function(res) {
- d.close();
- if(res.status == 999 || res.status == 998 || res.status == 997){
- loginUrl(res.status);
- return;
- }
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'校验失败',bottom:true}).show();
- },
- success: function(res) {
- d.close();
- if(res.status == 999 || res.status == 998 || res.status == 997){
- loginUrl(res.status);
- }
- else if (res.status == 200) {
- // -1 未签约 0 待签约 1 已签约 2待解约
- var is_sign = res.data;
- if(is_sign > 0){
- window.location.href = "event-profile.html?event="+id+"&type="+type
- }else{
- dialog({
- title: '提示',
- content: '对不起,签约家庭医生之后才能查看健康档案!',
- okValue:'我要签约',
- ok: function (){
- window.location.href = "../../qygl/html/signing-doctors.html";
- },
- cancelValue: '了解签约',
- cancel: function () {
- window.location.href = "../../qygl/html/signing-share2.html";
- }
- }).showModal();
- }
- } else {
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:res.msg,bottom:true}).show();
- }
- }
- });
- }
- else{
- dialog({contentType:'tipsbox', skin:'bk-popup' , content:'用户信息错误',bottom:true}).show();
- }
- }
- checkSign();
- }).on('click','li[data-from="2"]',function() {
- var id = $(this).attr('data-id');
- window.location.href = "jiuzhenxiangqing.html?event="+id
- })
- }
- function templateHelper() {
- template.helper("getYear", getYear);
- template.helper("getMD", getMD);
- template.helper("getEventTypeName", getEventTypeName);
- template.helper("getEventTypeClass", getEventTypeClass);
- template.helper("hasGroup", hasGroup);
- template.helper("toJson", toJson);
- }
- templateHelper();
- bindEvents();
- function queryInit() {
- page = 1;
- d.show();
- $records.empty();
- getReqPromise('patient/archives/event',{type:'',page:page,pageSize:10,lastTime: ''},'JSON','GET')
- .then(function(res) {
- d.close();
- if(res.status == 200) {
- if(res.data && res.data.length) {
- $noResult.hide();
- $content.show();
- parseToHtml(res);
- return true;
- } else {
- $content.hide();
- $noResult.show();
- return false;
- }
- } else {
- d.close();
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- }
-
- }).then(function() {
- scrollIns.myScroll.refresh();
- }).catch(function(e) {
- d.close();
- console && console.error(e);
- });
- }
- window.onpageshow = function() {
- var isLoaded = localStorage.getItem("jiuzhenjilu");
- localStorage.removeItem("jiuzhenjilu");
- if(isLoaded=="1") {
- localStorage.removeItem("jiuzhenjilu");
- }
- else {
- localStorage.setItem("jiuzhenjilu","1");
- }
- }
|