123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- var page = 1,
- pagesize = 10;
- var $tabs = $('#tabs'),
- $panels = $('.c-panels'),//切换选项卡
- $list = $('#dest_list'),//选项卡内容
- $teamGroups = $('.lin-sel-group'),//团队数
- $notext = $('#no_result_wrap'),//没有样式
- $scroll = $('#iScroll');//内容展示
-
- var teamInfo,
- teamCode,//团队code
- state="",//1.待处理,2.完成
- serverType="",//服务类型 0.医生咨询,1.预约挂号
- startDate="",
- endDate="",
- docInfo;
- mui.init();
- mui.plusReady(function(){
- //设置团队
- initTeamInfo();
- initScroller();
- plus.nativeUI.showWaiting();
- queryListData();
- bindEvents();
- });
- function initTeamInfo(){
- teamInfo = JSON.parse(plus.storage.getItem("teamInfo"));
- docInfo = JSON.parse(plus.storage.getItem("docInfo"))
- $('.lin-sel-group').html(template('teams_tmpl', teamInfo));
-
- var index =0;
- if(docInfo.adminTeamCode){
- for(var i=0;i<teamInfo.data.length;i++){
- if(teamInfo.data[i].id == docInfo.adminTeamCode){
- index = i;
- }
- }
- }
- $('.lin-sel-group li').eq(index).addClass('checked');
- setCurTeamName()
- }
- function setCurTeamName(){
- teamCode = $('.lin-sel-group li.checked').attr('data-code');
- $('.demo-comtop h1').html(($('.lin-sel-group li.checked').attr('data-name'))+'协同任务管理 <label class="lin-down-arrow"></label>');
- }
- /**
- * 显示团队选择
- */
- function showGroupSel(e, isShow){
- isShow = isShow || $('.lin-mask:hidden').length != 0;
- $('.lin-mask').toggle(isShow);
- $('.lin-sel-group').toggle(isShow);
- }
- function queryListData(fun,text){
- var params ={
- doctor:docInfo.code,
- adminTeamCode:teamCode,
- state:state,
- serverType:serverType,
- startDate:startDate,
- endDate:endDate,
- page:page,
- size:pagesize
- }
- sendGet("doctor/pcCustomer/getCallServices",params, function(){
- plus.nativeUI.closeWaiting();
- fun&&fun.call(this,false)
- mui.toast("请求失败");
- }, function(res){
- plus.nativeUI.closeWaiting();
- if(res.status == 200){
- var html = template('li_tmpl',{list:_.map(res.data,function(o){
- o.jsonStr = JSON.stringify(o);
- return o;})
- })
- if(page == 1 && res.data.length==0){
- $notext.show();
- $scroll.hide();
- }else{
- $notext.hide();
- $scroll.show();
- if(text == 'down'){
- $list.empty();
- fun&&fun.call(this,false)
- }else{
- if(res.data.length < pagesize){
- fun&&fun.call(this,true)
- }else{
- fun&&fun.call(this,false)
- }
- }
- $list.append(html);
- }
- }else{
- fun&&fun.call(this,false)
- mui.toast("获取数据失败");
- }
- })
- }
- //局部刷新
- function reloadLessData(){
- plus.nativeUI.showWaiting();
- page = 1;
- $list.empty();
- mui('.mui-scroll-wrapper').pullRefresh().refresh(true);//重置
- queryListData();
- }
- //整体刷新
- function reloadPageData(){
- plus.nativeUI.showWaiting();
- page = 1;
- recoverTag()
- $list.empty();
- queryListData();
- }
- //恢复选项卡
- function recoverTag(){
- $('.c-panel').find('li').removeClass('list-selected');
- $.map($('.c-panel'),function(o,i){
- var $li = $('.c-panel').eq(i).find('li').eq(0);
- $li.addClass('list-selected');
- $('.j-tag').eq(i).text($li.find('a').text())
- })
- paramReset()
- }
- function paramReset(){
- state='';
- serverType='';startDate='';endDate='';
- }
- function bindEvents(){
- $tabs.on('click','.sanp-flex',function() {
- var index = $(this).index(),
- $panel = $panels.find('.c-panel').eq(index);
- $panel.siblings().hide();
- if($panel.css('display')=='none') {
- $panel.show();
- } else {
- $panel.hide();
- }
- })
-
- $panels.on('click','li',function() {
- var $panel = $(this).closest('.c-panel');
- $(this).siblings().removeClass('list-selected');
- $(this).addClass('list-selected');
- $panel.hide();
- $('.j-tag').eq($panel.index()).text($(this).find('a').text())
-
- if($panel.index() ==0){ state = $(this).attr('data-id') }
- if($panel.index() ==1){ serverType = $(this).attr('data-id') }
- if($panel.index() ==2){
- var num = $(this).attr('data-id'),
- now = new Date();
- var day = now.getDate();
- var month = now.getMonth() + 1;
- var year = now.getFullYear();
- var date = year+'-'+month+'-'+day
- endDate = date;
- if(num == 1){
- startDate = beforeWeek(date,6);
- }else if(num == 2){
- startDate = beforeMonth(date,1);
- }else if(num == 3){
- startDate = beforeMonth(date,6);
- }else if(num == 4){
- startDate = beforeMonth(date,12);
- }else{
- startDate = '';
- }
- }
- reloadLessData()
- })
-
- //点击跳转
- $list.on('tap','.j-detail',function(){
- mui.openWindow({
- id: "xietongfuwu-detail",
- url: "xietongfuwu-detail.html",
- extras: {
- code:$(this).attr('data-code')
- }
- })
- })
-
- $('.demo-comtop h1').on('tap', showGroupSel);
-
- $teamGroups.on('click', 'li', function(){
- showGroupSel(undefined, false);
- if(!$(this).hasClass('checked')){
- $(this).addClass('checked').siblings().removeClass('checked');
- setCurTeamName();
- }
- reloadPageData()//重新加载数据
- })
-
- $('#search_btn').click(function(){
- openWebview("xietongfuwu-search.html", {teamCode: teamCode});
- })
- }
- function initScroller(){
- var deceleration = mui.os.ios ? 0.003:0.0009;
- mui(".mui-scroll-wrapper").scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration: deceleration
- });
- mui(".mui-scroll-wrapper").pullRefresh({
- up: {
- callback: function() {
- var self = this;
- page++;
- queryListData(function(value){
- setTimeout(function(){
- self.endPullupToRefresh(value);
- },500)
- },'up')
- }
- }
- })
- }
- window.addEventListener("refreshXietong", function(){
- reloadPageData()
- })
- //相隔几天
- function getDays(sDate,eDate){
- var oDate1;
- var oDate2;
- var iDays;
- oDate1= sDate.split("-");
- oDate2= eDate.split("-");
- var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]);
- var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]);
- iDays = parseInt(Math.abs(strDateE - strDateS ) / 1000 / 60 / 60 /24)
- return iDays ;
- }
- //现在时间
- function getNowDate() {
- var date = new Date();
- var year = date.getFullYear();
- var month = date.getMonth() + 1;
- var day = date.getDate();
- var hour = date.getHours();
- var minute = date.getMinutes();
- var second = date.getSeconds();
- return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
- }
- //该上月份最后一天
- function lastDate(date){
- var arr = date.split('-');
- var year = arr[0];
- var month = arr[1]*1-1;
- if(month<1){
- month = 12;
- year = year - 1;
- }
- var day = new Date(year,month,0).getDate();
- return day;
- }
- //近一周
- function beforeWeek(date,num){
- var arr = date.split('-');
- var reduce = arr[2]*1-num;
- if(reduce>0){
- var sDate = arr[0]*1+'-'+arr[1]*1+'-'+reduce;
- return sDate;
- }else if(arr[1]*1 > 1){
- var sDate = arr[0]*1+'-'+(arr[1]*1-1)+'-'+(lastDate(date)+reduce);
- return sDate;
- }else{
- var sDate = (arr[0]*1-1)+'-12-'+(lastDate(date)+reduce);
- return sDate;
- }
- }
- //近几个月前
- function beforeMonth(date,num){
- var arr = date.split('-');
- var reduce = arr[1]*1-num;
- if(reduce>0){
- var sDate = arr[0]+'-'+reduce+'-'+arr[2];
- return sDate;
- }else{
- var sDate = (arr[0]*1-1)+'-'+(12+reduce*1)+'-'+arr[2];
- return sDate;
- }
- }
- template.helper('setSex',function(item){
- if(item == 1){
- return '男'
- }else{
- return '女'
- }
- })
- template.helper('setType',function(item){
- if(item == 1){return '预约挂号'}
- if(item == 0){return '医生咨询'}
- })
- template.helper("setPhoto", function(p) {
- return getImgUrl(p);
- });
|