xietongfuwu-management.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. var page = 1,
  2. pagesize = 10;
  3. var $tabs = $('#tabs'),
  4. $panels = $('.c-panels'),//切换选项卡
  5. $list = $('#dest_list'),//选项卡内容
  6. $teamGroups = $('.lin-sel-group'),//团队数
  7. $notext = $('#no_result_wrap'),//没有样式
  8. $scroll = $('#iScroll');//内容展示
  9. var teamInfo,
  10. teamCode,//团队code
  11. state="",//1.待处理,2.完成
  12. serverType="",//服务类型 0.医生咨询,1.预约挂号
  13. startDate="",
  14. endDate="",
  15. docInfo;
  16. mui.init();
  17. mui.plusReady(function(){
  18. //设置团队
  19. initTeamInfo();
  20. initScroller();
  21. plus.nativeUI.showWaiting();
  22. queryListData();
  23. bindEvents();
  24. });
  25. function initTeamInfo(){
  26. teamInfo = JSON.parse(plus.storage.getItem("teamInfo"));
  27. docInfo = JSON.parse(plus.storage.getItem("docInfo"))
  28. $('.lin-sel-group').html(template('teams_tmpl', teamInfo));
  29. var index =0;
  30. if(docInfo.adminTeamCode){
  31. for(var i=0;i<teamInfo.data.length;i++){
  32. if(teamInfo.data[i].id == docInfo.adminTeamCode){
  33. index = i;
  34. }
  35. }
  36. }
  37. $('.lin-sel-group li').eq(index).addClass('checked');
  38. setCurTeamName()
  39. }
  40. function setCurTeamName(){
  41. teamCode = $('.lin-sel-group li.checked').attr('data-code');
  42. $('.demo-comtop h1').html(($('.lin-sel-group li.checked').attr('data-name'))+'协同任务管理 <label class="lin-down-arrow"></label>');
  43. }
  44. /**
  45. * 显示团队选择
  46. */
  47. function showGroupSel(e, isShow){
  48. isShow = isShow || $('.lin-mask:hidden').length != 0;
  49. $('.lin-mask').toggle(isShow);
  50. $('.lin-sel-group').toggle(isShow);
  51. }
  52. function queryListData(fun,text){
  53. var params ={
  54. doctor:docInfo.code,
  55. adminTeamCode:teamCode,
  56. state:state,
  57. serverType:serverType,
  58. startDate:startDate,
  59. endDate:endDate,
  60. page:page,
  61. size:pagesize
  62. }
  63. sendGet("doctor/pcCustomer/getCallServices",params, function(){
  64. plus.nativeUI.closeWaiting();
  65. fun&&fun.call(this,false)
  66. mui.toast("请求失败");
  67. }, function(res){
  68. plus.nativeUI.closeWaiting();
  69. if(res.status == 200){
  70. var html = template('li_tmpl',{list:_.map(res.data,function(o){
  71. o.jsonStr = JSON.stringify(o);
  72. return o;})
  73. })
  74. if(page == 1 && res.data.length==0){
  75. $notext.show();
  76. $scroll.hide();
  77. }else{
  78. $notext.hide();
  79. $scroll.show();
  80. if(text == 'down'){
  81. $list.empty();
  82. fun&&fun.call(this,false)
  83. }else{
  84. if(res.data.length < pagesize){
  85. fun&&fun.call(this,true)
  86. }else{
  87. fun&&fun.call(this,false)
  88. }
  89. }
  90. $list.append(html);
  91. }
  92. }else{
  93. fun&&fun.call(this,false)
  94. mui.toast("获取数据失败");
  95. }
  96. })
  97. }
  98. //局部刷新
  99. function reloadLessData(){
  100. plus.nativeUI.showWaiting();
  101. page = 1;
  102. $list.empty();
  103. mui('.mui-scroll-wrapper').pullRefresh().refresh(true);//重置
  104. queryListData();
  105. }
  106. //整体刷新
  107. function reloadPageData(){
  108. plus.nativeUI.showWaiting();
  109. page = 1;
  110. recoverTag()
  111. $list.empty();
  112. queryListData();
  113. }
  114. //恢复选项卡
  115. function recoverTag(){
  116. $('.c-panel').find('li').removeClass('list-selected');
  117. $.map($('.c-panel'),function(o,i){
  118. var $li = $('.c-panel').eq(i).find('li').eq(0);
  119. $li.addClass('list-selected');
  120. $('.j-tag').eq(i).text($li.find('a').text())
  121. })
  122. paramReset()
  123. }
  124. function paramReset(){
  125. state='';
  126. serverType='';startDate='';endDate='';
  127. }
  128. function bindEvents(){
  129. $tabs.on('click','.sanp-flex',function() {
  130. var index = $(this).index(),
  131. $panel = $panels.find('.c-panel').eq(index);
  132. $panel.siblings().hide();
  133. if($panel.css('display')=='none') {
  134. $panel.show();
  135. } else {
  136. $panel.hide();
  137. }
  138. })
  139. $panels.on('click','li',function() {
  140. var $panel = $(this).closest('.c-panel');
  141. $(this).siblings().removeClass('list-selected');
  142. $(this).addClass('list-selected');
  143. $panel.hide();
  144. $('.j-tag').eq($panel.index()).text($(this).find('a').text())
  145. if($panel.index() ==0){ state = $(this).attr('data-id') }
  146. if($panel.index() ==1){ serverType = $(this).attr('data-id') }
  147. if($panel.index() ==2){
  148. var num = $(this).attr('data-id'),
  149. now = new Date();
  150. var day = now.getDate();
  151. var month = now.getMonth() + 1;
  152. var year = now.getFullYear();
  153. var date = year+'-'+month+'-'+day
  154. endDate = date;
  155. if(num == 1){
  156. startDate = beforeWeek(date,6);
  157. }else if(num == 2){
  158. startDate = beforeMonth(date,1);
  159. }else if(num == 3){
  160. startDate = beforeMonth(date,6);
  161. }else if(num == 4){
  162. startDate = beforeMonth(date,12);
  163. }else{
  164. startDate = '';
  165. }
  166. }
  167. reloadLessData()
  168. })
  169. //点击跳转
  170. $list.on('tap','.j-detail',function(){
  171. mui.openWindow({
  172. id: "xietongfuwu-detail",
  173. url: "xietongfuwu-detail.html",
  174. extras: {
  175. code:$(this).attr('data-code')
  176. }
  177. })
  178. })
  179. $('.demo-comtop h1').on('tap', showGroupSel);
  180. $teamGroups.on('click', 'li', function(){
  181. showGroupSel(undefined, false);
  182. if(!$(this).hasClass('checked')){
  183. $(this).addClass('checked').siblings().removeClass('checked');
  184. setCurTeamName();
  185. }
  186. reloadPageData()//重新加载数据
  187. })
  188. $('#search_btn').click(function(){
  189. openWebview("xietongfuwu-search.html", {teamCode: teamCode});
  190. })
  191. }
  192. function initScroller(){
  193. var deceleration = mui.os.ios ? 0.003:0.0009;
  194. mui(".mui-scroll-wrapper").scroll({
  195. bounce: false,
  196. indicators: true, //是否显示滚动条
  197. deceleration: deceleration
  198. });
  199. mui(".mui-scroll-wrapper").pullRefresh({
  200. up: {
  201. callback: function() {
  202. var self = this;
  203. page++;
  204. queryListData(function(value){
  205. setTimeout(function(){
  206. self.endPullupToRefresh(value);
  207. },500)
  208. },'up')
  209. }
  210. }
  211. })
  212. }
  213. window.addEventListener("refreshXietong", function(){
  214. reloadPageData()
  215. })
  216. //相隔几天
  217. function getDays(sDate,eDate){
  218. var oDate1;
  219. var oDate2;
  220. var iDays;
  221. oDate1= sDate.split("-");
  222. oDate2= eDate.split("-");
  223. var strDateS = new Date(oDate1[0], oDate1[1]-1, oDate1[2]);
  224. var strDateE = new Date(oDate2[0], oDate2[1]-1, oDate2[2]);
  225. iDays = parseInt(Math.abs(strDateE - strDateS ) / 1000 / 60 / 60 /24)
  226. return iDays ;
  227. }
  228. //现在时间
  229. function getNowDate() {
  230. var date = new Date();
  231. var year = date.getFullYear();
  232. var month = date.getMonth() + 1;
  233. var day = date.getDate();
  234. var hour = date.getHours();
  235. var minute = date.getMinutes();
  236. var second = date.getSeconds();
  237. return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day);
  238. }
  239. //该上月份最后一天
  240. function lastDate(date){
  241. var arr = date.split('-');
  242. var year = arr[0];
  243. var month = arr[1]*1-1;
  244. if(month<1){
  245. month = 12;
  246. year = year - 1;
  247. }
  248. var day = new Date(year,month,0).getDate();
  249. return day;
  250. }
  251. //近一周
  252. function beforeWeek(date,num){
  253. var arr = date.split('-');
  254. var reduce = arr[2]*1-num;
  255. if(reduce>0){
  256. var sDate = arr[0]*1+'-'+arr[1]*1+'-'+reduce;
  257. return sDate;
  258. }else if(arr[1]*1 > 1){
  259. var sDate = arr[0]*1+'-'+(arr[1]*1-1)+'-'+(lastDate(date)+reduce);
  260. return sDate;
  261. }else{
  262. var sDate = (arr[0]*1-1)+'-12-'+(lastDate(date)+reduce);
  263. return sDate;
  264. }
  265. }
  266. //近几个月前
  267. function beforeMonth(date,num){
  268. var arr = date.split('-');
  269. var reduce = arr[1]*1-num;
  270. if(reduce>0){
  271. var sDate = arr[0]+'-'+reduce+'-'+arr[2];
  272. return sDate;
  273. }else{
  274. var sDate = (arr[0]*1-1)+'-'+(12+reduce*1)+'-'+arr[2];
  275. return sDate;
  276. }
  277. }
  278. template.helper('setSex',function(item){
  279. if(item == 1){
  280. return '男'
  281. }else{
  282. return '女'
  283. }
  284. })
  285. template.helper('setType',function(item){
  286. if(item == 1){return '预约挂号'}
  287. if(item == 0){return '医生咨询'}
  288. })
  289. template.helper("setPhoto", function(p) {
  290. return getImgUrl(p);
  291. });