123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- var d = dialog({contentType:'load', skin:'bk-popup'});
- var page = 0,
- pageSize = 10,
- userAgent = window.localStorage.getItem(agentName),
- pagetype = 2;
- // 获取链接带参
- var request = GetRequest(),
- deptId =request["deptId"] || null;
-
- $(function(){
- checkUserAgent();
- });
- function queryInit(){
- userAgent = JSON.parse(userAgent);
- initScroller();
- getDoctorList(true);
- bindEvents();
- getTemplateHelper();
- }
- function getDoctorList(isInit){
- d.show();
- if(isInit){
- page = 0;
- }
- var url = "/patient/concern/getConcernDoctors",
- params = {
- patient: userAgent.uid,
- 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){
- page ++;
- var html = template("doctor_tmp", {list: list});
- if(isInit){
- $("#docList").empty().append(html);
- }else{
- $("#docList").append(html);
- }
- if(list.length < pageSize){
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }else{
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false);
- }
- }else{
- if(isInit){
- $(".main").hide();
- $(".div-no-search-info").show();
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }else{
- mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
- }
- }
- }else{
- queryFailed(res);
- }
- })
- }
- function bindEvents(){
- //单个医生点击
- $("#docList").on("tap", "li", function(){
- var doctorCode = $(this).attr("data-code");
- window.location.href = "doctor-homepage.html?doctor="+doctorCode;
- })
- }
- function getTemplateHelper(){
- template.helper("getImgUrl", function(str){
- return getImgUrl(str);
- });
- }
- 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(){
- getDoctorList(true);
- this.endPulldownToRefresh();
- }
- },
- up: {
- callback: function() {
- var self = this;
- setTimeout(function() {
- getDoctorList(false);
- // self.endPullupToRefresh();
- }, 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();
- }
- }
-
- }
|