// 登录者相关信息(包括userAgent) var loginerInfo = null, // 基础环境信息(包括当前webview) baseEnv = null; var $orgTab = $('#org_tab'), $orgList = $('#org_list'), $hospitalList = $('#hospital_list'), $communityList = $('#community_list'); // 获取登录相关信息 var getLoginerInfo = 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; }); }, // 初始化医院列表 initHospitalList = function() { var html = template("org_li_tmpl", {list: communitiesData.list}) $hospitalList.html(html); }, // 初始化社区列表 initCommunityList = function() { var html = template("org_li_tmpl", {list: communitiesData.list}) $communityList.html(html); }, // 绑定页面事件 bindEvents = function () { $orgTab.on('click','li',function() { var type = $(this).attr('data-type'); $orgTab.find('li').removeClass('curr'); $('.org-dest-list').hide(); $(this).addClass('curr'); $('#'+type+'_list').show(); }); }; // 页面业务处理流程开始 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() { // 获取登录医生信息 loginerInfo = getLoginerInfo(); initHospitalList(); initCommunityList(); // 绑定页面事件 bindEvents(); }) }).catch(function(e) { plus.nativeUI.closeWaiting(); console && console.error(e); }); template.helper("setHosPhoto", function(p) { if(!p || p == ""){ return '../images/hospital_default.png'; } return getImgUrl(p); });