index.vue 2.9 KB

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