xuanzejigou.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // 登录者相关信息(包括userAgent)
  2. var loginerInfo = null,
  3. // 基础环境信息(包括当前webview)
  4. baseEnv = null;
  5. var $orgTab = $('#org_tab'),
  6. $orgList = $('#org_list'),
  7. $hospitalList = $('#hospital_list'),
  8. $communityList = $('#community_list');
  9. // 获取登录相关信息
  10. var getLoginerInfo = function() {
  11. // 登录的相关信息
  12. var userAgent = plus && JSON.parse(plus.storage.getItem("userAgent"))
  13. return {
  14. userAgent: userAgent
  15. }
  16. },
  17. // 获取基础环境信息
  18. getBaseEnvPromise = function () {
  19. var env = {
  20. webview: plus&&plus.webview.currentWebview()
  21. };
  22. return Promise.resolve().then(function(res) {
  23. return env;
  24. });
  25. },
  26. // 初始化医院列表
  27. initHospitalList = function() {
  28. var html = template("org_li_tmpl", {list: communitiesData.list})
  29. $hospitalList.html(html);
  30. },
  31. // 初始化社区列表
  32. initCommunityList = function() {
  33. var html = template("org_li_tmpl", {list: communitiesData.list})
  34. $communityList.html(html);
  35. },
  36. // 绑定页面事件
  37. bindEvents = function () {
  38. $orgTab.on('click','li',function() {
  39. var type = $(this).attr('data-type');
  40. $orgTab.find('li').removeClass('curr');
  41. $('.org-dest-list').hide();
  42. $(this).addClass('curr');
  43. $('#'+type+'_list').show();
  44. });
  45. };
  46. // 页面业务处理流程开始
  47. new Promise(function(resolve, reject) {
  48. // TODO 临时放开
  49. resolve(true);
  50. mui.plusReady(function() {
  51. // plus已经准备好,可以往下执行
  52. resolve(true);
  53. });
  54. }).then(function() {
  55. // 获取基础环境信息
  56. return getBaseEnvPromise().then(function(env) {
  57. baseEnv = env;
  58. }).then(function() {
  59. // 获取登录医生信息
  60. loginerInfo = getLoginerInfo();
  61. initHospitalList();
  62. initCommunityList();
  63. // 绑定页面事件
  64. bindEvents();
  65. })
  66. }).catch(function(e) {
  67. plus.nativeUI.closeWaiting();
  68. console && console.error(e);
  69. });
  70. template.helper("setHosPhoto", function(p) {
  71. if(!p || p == ""){
  72. return '../images/hospital_default.png';
  73. }
  74. return getImgUrl(p);
  75. });