index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import history from '../../utils/history';
  2. import { getHospitalDistrictList } from './service';
  3. Component({
  4. props: {
  5. height: '100vh',
  6. componentData: {}
  7. },
  8. methods: {
  9. getExtInfo() {
  10. const {
  11. componentData
  12. } = this.props;
  13. const {
  14. componentExtInfo
  15. } = componentData;
  16. return componentExtInfo || {};
  17. },
  18. async onService() {
  19. const list = await getHospitalDistrictList();
  20. /* 如果只有一个院区直接跳转到挂号须知 */
  21. if (list.length === 1) {
  22. this.toNextPage(list[0], true);
  23. }
  24. return {
  25. list,
  26. pagination: {
  27. total: list.length
  28. }
  29. };
  30. },
  31. onItemTap({
  32. target: {
  33. dataset
  34. }
  35. }) {
  36. this.toNextPage(dataset.item);
  37. },
  38. toNextPage(item, replace) {
  39. const {
  40. name,
  41. hospitalDistrictId
  42. } = item;
  43. const {
  44. isNotice = 'Y'
  45. } = this.getExtInfo();
  46. /* 如果没有就诊须知跳转选择科室页面 */
  47. const pageType = isNotice === 'N' ? 'select-department' : 'follow-up-notice';
  48. history[replace ? 'replace' : 'push']({
  49. pageType,
  50. title: '挂号须知',
  51. componentData: {
  52. area: item
  53. },
  54. query: {
  55. name,
  56. hospitalDistrictId
  57. }
  58. });
  59. }
  60. }
  61. });