123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var page = 1,
- pageSize = 100;
- $(function(){
- initScroller();
- getDeptList(true);
- bindEvents();
- })
- function getDeptList(isInit){
- d.show();
- if(isInit){
- page = 1;
- }
- var url = "patient/consult/dept_list",
- params = {
- page: page,
- pagesize: pageSize
- };
- sendPost(url, params, 'json', 'get', queryFailed, function(res){
- if(res.status == 200){
- d.close();
- var list = res.data;
- if(list.length > 0){
- var html = template('dept_tmp', {list: list});
- if(isInit){
- var all = '<li class="c-list-cover list-arrow-r ptb10 plr10" data-code="">全部</li>';
- $("#deptList").empty().append(all+html);
- }else{
- $("#deptList").append(html);
- }
- if(list.length < pageSize){
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }else{
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false);
- }
- }else{
- if(isInit){
- $(".c-main").hide();
- $(".div-no-info").show();
- }else{
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }
- }
- }else{
- queryFailed(res);
- }
- });
- }
- function bindEvents(){
- $("#deptList").on('tap', 'li', function(){
- var deptId = $(this).attr("data-code"),
- deptName = $(this).attr("data-name") || '';
- var url = "select-consult-doctor.html?deptId="+deptId+"&deptName="+deptName;
- window.location.replace(url);
- })
- }
- function initScroller(){
- //阻尼系数
- var deceleration = mui.os.ios?0.003:0.0009;
- mui('.mui-scroll-wrapper').scroll({
- bounce: false,
- indicators: true, //是否显示滚动条
- deceleration:deceleration
- });
- mui.ready(function() {
- mui(".mui-scroll-wrapper").pullRefresh({
- down:{
- callback: function(){
- getDeptList(true);
- this.endPulldownToRefresh();
- }
- },
- up: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- getDeptList(false);
- }, 1000);
- }
- }
- });
- });
- }
- //请求失败处理事件
- function queryFailed(res, message){
- d.close();
- if(message){
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content: message}).show();
- }else{
- if (res && res.msg) {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
- } else {
- dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
- }
- }
-
- }
|