// TODO 临时构造plus对象,使得能够在浏览器中进行调试 // var plus = null; // 基本信息(包括userAgent、上个页面传递的数据) var baseInfo = null, // 基础环境信息(包括当前webview) baseEnv = null, pages = {}, //记录个分组内数据页数 docInfo; var $searchbarInput = $('.searchbar .search-input'), // 搜索无结果时显示 $noResultWrap = $('#no_result_wrap'), // 页面顶部分类标签列表(四个列表项) $groupLabelList = $('#group_label_list'), patientInfo = null; // 获取基本信息(包括userAgent、上个页面传递的数据) var getBaseInfoPromise = function() { // 登录的相关信息 var userAgent = plus && JSON.parse(plus.storage.getItem("userAgent")) return { userAgent: userAgent } }, // 获取基础环境信息 getBaseEnvPromise = function () { var env = { webview: plus&&plus.webview.currentWebview() }; return Promise.resolve().then(function(res) { return env; }); }, //获取分组信息 getGroupData = function(){ docInfo = JSON.parse(plus.storage.getItem("docInfo")); var url = "doctor/dept_group_list", params = {}; plus.nativeUI.showWaiting(); sendGet(url, params, null,function(res){ if(res.status == 200){ var html = template("pati_group_tmpl", {list: res.data}); $("#groupList").empty().append(html); plus.nativeUI.closeWaiting(); }else{ plus.nativeUI.closeWaiting(); mui.toast(res.msg); } }); }, // 滚动条分页实例初始化 initScroller = function() { //阻尼系数 var deceleration = mui.os.ios?0.003:0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration:deceleration }); mui(".mui-scroll").pullToRefresh({ down: { callback: function() { var self = this; setTimeout(function() { getGroupData(); self.endPullDownToRefresh(); }, 1000); } } }); }, // 绑定页面事件 bindEvents = function () { $("#groupList").on('tap','.group-info li[data-code]',function(e) { var code = $(this).attr("data-code"); var name = $(this).attr("data-name"); mui.openWindow('../../mine/html/zuyuanziliao.html', 'zuyuanziliao', { extras: { docCode: code, docName:name, teamCode: docInfo.adminTeamCode, // isTeamOwner: isTeamOwner } }); return false; }); $("#groupList").on('tap', ".group-item", function(){ var $el = $(this), code = $.trim($el.attr("data-group")), isOpen = $el.hasClass("current"), $groupInfo = $el.find('.group-info'); if(isOpen) { $el.removeClass("current"); $el.find(".ui-arrow").removeClass("ui-arrow-b"); $el.find(".ui-arrow").addClass("ui-arrow-r"); $groupInfo.hide(); }else{ var $opened = $(".group-item.current"); $el.addClass("current"); $el.find(".ui-arrow").removeClass("ui-arrow-r"); $el.find(".ui-arrow").addClass("ui-arrow-b"); if($opened.length > 0){ $opened.removeClass('current').find(".group-info").hide(); $opened.find(".ui-arrow").removeClass("ui-arrow-b"); $opened.find(".ui-arrow").addClass("ui-arrow-r"); } $groupInfo.show(); } }); $searchbarInput.on('tap',function() { mui.openWindow({ id: "searchhuanzhe2", url: "../../tuandui/html/searchdoctor.html", extras: {} }) }); /*刷新事件*/ window.addEventListener("refresh", function group(e) { getGroupData(); }); }; // 页面业务处理流程开始 new Promise(function(resolve, reject) { // TODO 临时放开 //resolve(true); mui.plusReady(function() { // plus已经准备好,可以往下执行 resolve(true); }); }).then(function() { // 获取基础环境信息 return getBaseEnvPromise().then(function(env) { baseEnv = env; }).then(function() { // 获取登录医生信息 baseInfo = getBaseInfoPromise(); initScroller(); getGroupData(); // 绑定页面事件 bindEvents(); if(baseEnv.webview.origin){//“随访”功能,需要返回按钮 $(".mui-action-back").show(); } }) }).catch(function(e) { plus.nativeUI.closeWaiting(); console && console.error(e); }); function setAge(age) { if(age == 0) { return "<1"; } if(age == -1) return "未知"; return age; } template.helper("setAge", setAge); function setSex(s) { if(s == 1) { return "男"; } else if(s == 2) { return "女"; } } template.helper("setSex", setSex); template.helper("getPhoto", function(str){ return getImgUrl(str); })