index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="scan-v">
  3. <mescroll-body ref="mescrollRef" @down="downCallback" :down="downOption" :sticky="true" @up="upCallback"
  4. :up="upOption" :bottombar="false" style="min-height: 100%" @init="mescrollInit">
  5. <view class="portal-v">
  6. <view v-if="formData.length">
  7. <view class="portal-box" v-for="(item,index) in formData" :key="index">
  8. <portalItem :item='item' ref="portalItem"></portalItem>
  9. </view>
  10. </view>
  11. <JnpfEmpty v-else></JnpfEmpty>
  12. </view>
  13. </mescroll-body>
  14. </view>
  15. </template>
  16. <script>
  17. import portalItem from '@/pages/portal//components/index.vue'
  18. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js"
  19. import {
  20. getPreviewPortal,
  21. auth
  22. } from '@/api/portal/portal.js'
  23. export default {
  24. mixins: [MescrollMixin],
  25. components: {
  26. portalItem
  27. },
  28. data() {
  29. return {
  30. id: '',
  31. show: false,
  32. formData: [],
  33. dataList: [],
  34. downOption: {
  35. use: true,
  36. auto: true
  37. },
  38. upOption: {
  39. page: {
  40. num: 0,
  41. size: 50,
  42. time: null
  43. },
  44. empty: {
  45. use: false,
  46. },
  47. textNoMore: this.$t('app.apply.noMoreData'),
  48. }
  49. }
  50. },
  51. onLoad(e) {
  52. uni.setStorageSync('token', e.token)
  53. this.id = e.id
  54. uni.$on('refresh', () => {
  55. this.formData = [];
  56. this.mescroll.resetUpScroll();
  57. })
  58. },
  59. methods: {
  60. upCallback(keyword) {
  61. this.mescroll.lockDownScroll(true);
  62. auth(this.id).then(res => {
  63. let data = res.data.formData ? JSON.parse(res.data.formData) : {};
  64. this.formData = data.layout ? JSON.parse(JSON.stringify(data.layout)) : [];
  65. this.mescroll.endSuccess(this.formData.length);
  66. if (!this.formData.length) return
  67. this.handelFormData(data)
  68. }).catch(() => {
  69. this.mescroll.endSuccess(0);
  70. this.mescroll.endErr();
  71. })
  72. },
  73. handelFormData(data) {
  74. const loop = (list) => {
  75. list.forEach(o => {
  76. o.allRefresh = data.refresh
  77. o.show = false
  78. if (o.visibility && o.visibility.length && o.visibility.includes('app')) o.show =
  79. true
  80. if (o.children && o.children.length) loop(o.children)
  81. })
  82. this.key = +new Date()
  83. }
  84. loop(this.formData)
  85. this.dataList = this.formData.filter(o => o.show)
  86. if (this.dataList.length < 1) {
  87. this.formData = this.dataList
  88. }
  89. },
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. page {
  95. background-color: #f0f2f6;
  96. }
  97. .portal-nodata {
  98. position: absolute;
  99. top: 450rpx;
  100. width: 100%;
  101. text-align: center;
  102. z-index: 100;
  103. background-color: #f0f2f6;
  104. }
  105. </style>