jiankangtijianxiangqing.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // 基本信息(包括userAgent、上个页面传递的数据)
  2. var baseInfo = null,
  3. // 基础环境信息(包括当前webview)
  4. baseEnv = null;
  5. // 获取基本信息(包括userAgent、上个页面传递的数据)
  6. var getBaseInfo = function() {
  7. // 登录的相关信息
  8. var userAgent = plus && JSON.parse(plus.storage.getItem("userAgent"))
  9. return {
  10. userAgent: userAgent,
  11. eventInfo: baseEnv.webview.eventInfo,
  12. patiInfo: baseEnv.webview.patiInfo
  13. }
  14. },
  15. // 获取基础环境信息
  16. getBaseEnvPromise = function () {
  17. var env = {
  18. webview: plus&&plus.webview.currentWebview()
  19. };
  20. return Promise.resolve().then(function(res) {
  21. return env;
  22. });
  23. };
  24. // 页面业务处理流程开始
  25. new Promise(function(resolve, reject) {
  26. mui.plusReady(function() {
  27. // plus已经准备好,可以往下执行
  28. resolve(true);
  29. });
  30. })
  31. .then(function() {
  32. plus.nativeUI.showWaiting();
  33. // 获取基础环境信息
  34. return getBaseEnvPromise().then(function(env) {
  35. baseEnv = env;
  36. // 获取登录医生信息
  37. baseInfo = getBaseInfo();
  38. })
  39. })
  40. .then(function() { //cy
  41. return getReqPromise('doctor/health_record/medical_detail',{
  42. medicalNo: baseInfo.eventInfo.medicalNo,patient:baseInfo.patiInfo.code
  43. },'POST').then(function(res){
  44. plus.nativeUI.closeWaiting();
  45. var data = {};
  46. if(res.status == 200) {
  47. data = res.medical_detail;
  48. } else {
  49. mui.toast(res.msg);
  50. }
  51. var vm = avalon.define($.extend({},{"$id": "viewController"},{
  52. data: data
  53. }));
  54. avalon.scan();
  55. }).catch(function(e) {
  56. plus.nativeUI.closeWaiting();
  57. console && console.error(e);
  58. })
  59. })
  60. .then(function() {
  61. function showAutoItems(el) {
  62. var $item = $(el).closest('[auto-item]');
  63. if($item.length && $item.is(":hidden")) {
  64. $item.removeClass('elastic-columns-ignore')
  65. $item.show();
  66. showAutoItems($item.parent());
  67. }
  68. }
  69. _.each($('[item-value]'),function(el) {
  70. var $el = $(el);
  71. var text = $.trim($el.text());
  72. if(text) {
  73. showAutoItems($el);
  74. }
  75. })
  76. })
  77. .then(function() {
  78. $('.c-panel').on('click','.c-panel-bar',function() {
  79. var $panel = $(this).closest('.c-panel'),
  80. $content = $panel.find('.c-panel-content');
  81. $('.c-panel.expanding').not($panel[0]).removeClass('expanding').find('.c-panel-content').slideUp();
  82. $panel.toggleClass('expanding');
  83. if($panel.hasClass('expanding')) {
  84. var $container = $panel.find('.card-layout');
  85. $content.slideDown(function() {
  86. if($container.length) {
  87. $container.elasticColumns(
  88. {
  89. columns: 2, // the number of colums
  90. innerMargin: 5, // the gap between two tiles
  91. outerMargin: 5 // the gap between the tiles and
  92. // the edge of the container
  93. });
  94. }
  95. });
  96. } else {
  97. $content.slideUp();
  98. }
  99. });
  100. }).catch(function(e) {
  101. plus.nativeUI.closeWaiting();
  102. console && console.error(e);
  103. })