testingRoom.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view class="container">
  3. <uni-card>
  4. <uni-section v-for="(item, index) in dataList" :title="item.typeName" :key="index" type="line">
  5. <uni-list border class="list">
  6. <uni-list-item v-for="(i, idx) in item.children" :key="idx" :ellipsis="1" :title="i.typeName" link clickable @click="listItemBtn(i)" ></uni-list-item>
  7. </uni-list>
  8. </uni-section>
  9. <!-- <uni-load-more :status="more" /> -->
  10. </uni-card>
  11. </view>
  12. </template>
  13. <script>
  14. import request from '../../api/cms.js';
  15. export default {
  16. onLoad: function (option) {
  17. },
  18. data() {
  19. return {
  20. dataList: [],
  21. // more: 'more',
  22. page: 0,
  23. size: 20,
  24. type: ''
  25. }
  26. },
  27. async mounted() {
  28. await this.getList();
  29. },
  30. methods: {
  31. listItemBtn(e) {
  32. console.log(e)
  33. uni.navigateTo({ url: `/pages/illness/testingRoomList?alias=${e.alias}` });
  34. },
  35. // 查询列表函数
  36. async getList() {
  37. this.page += 1;
  38. this.more = 'loading';
  39. const res = await request.getTypeList({ alias: 'hsjc' });
  40. const data = res.data.map(e => {
  41. const list = e.ancestors.split(',')
  42. if (list.length <= 2) e.parent = true;
  43. return e;
  44. })
  45. const list = data.filter(j => j.parent).map(e => this.children(e, data))
  46. this.dataList = list;
  47. // 根据总数 算页数 如果当前页 = 总页数就是没有数据 否则就是上拉加载
  48. // this.more = this.page >= Math.ceil(res.total / this.size) ? 'noMore' : 'more';
  49. },
  50. children(item, list) {
  51. const childrenList = list.filter(j => j.parentId == item.typeId).map(e => this.children(e, list));
  52. // 如果当前子菜单项存在 就添加children属性
  53. if (childrenList.length > 0) {
  54. return { ...item, children: childrenList };
  55. }
  56. // 不存在就不添加
  57. return { ...item };
  58. }
  59. },
  60. // 页面生命周期中onReachBottom(页面滚动到底部的事件)
  61. // onReachBottom() {
  62. // if(this.more != 'noMore') {
  63. // this.more = 'more';
  64. // this.getList();
  65. // }
  66. // }
  67. }
  68. </script>
  69. <style>
  70. </style>