index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <auth-wrap class="file-info-container" ref="authWrap">
  3. <template slot="content">
  4. <u-toast ref="uToast"></u-toast>
  5. <view class="search-content">
  6. <u-search placeholder="请输入关键字" v-model="keyword" @custom="onSearch" @search="onSearch"></u-search>
  7. </view>
  8. <view class="u-page" style="padding: 0 20rpx;">
  9. <u-list
  10. v-if="indexList.length>0"
  11. @scrolltolower="scrolltolower"
  12. >
  13. <u-list-item
  14. v-for="(item, index) in indexList"
  15. :key="index"
  16. >
  17. <view class="file-info-item" @click="onItemClick(item)">
  18. <view class="file-info-item-img">
  19. <image :src="item.imgUrl" mode="aspectFill" />
  20. </view>
  21. <view class="file-info-item-content">
  22. <view class="file-info-item-title">{{ item.title }}</view>
  23. <view class="file-info-item-date">{{ item.date }}</view>
  24. </view>
  25. </view>
  26. </u-list-item>
  27. </u-list>
  28. <u-loadmore :status="loadStatus" />
  29. </view>
  30. </template>
  31. </auth-wrap>
  32. </template>
  33. <script>
  34. import { fetchContentInfo, fetchUsrMeetingInfo } from '@/common/api';
  35. import { CONTENT_TYPE, ICON_CFG, REVIEW_STATUS } from '@/common/EnumConst';
  36. import AuthWrap from '@/components/AuthComp/index.vue';
  37. import { fileIcon, getImageUrl } from '@/util';
  38. let page = 1;
  39. export default {
  40. name: 'content',
  41. props: {},
  42. components: {
  43. AuthWrap,
  44. },
  45. data() {
  46. return {
  47. ICON_CFG,
  48. keyword: '',
  49. indexList: [],
  50. loadStatus: 'loadmore', // loadmore,loading,nomore
  51. };
  52. },
  53. created() {
  54. },
  55. onLoad() {
  56. this.$refs.authWrap.reloadPage();
  57. page = 1;
  58. this.loadmore();
  59. },
  60. methods: {
  61. fileIcon,
  62. getImageUrl,
  63. onItemClick(item) {
  64. uni.navigateTo({
  65. url: `/pasb/pages/detail/index?id=${item.id}`,
  66. });
  67. },
  68. scrolltolower() {
  69. if (page > 1 && this.loadStatus === 'nomore') {
  70. return;
  71. }
  72. this.loadmore();
  73. },
  74. async loadmore() {
  75. this.loadStatus = 'loading';
  76. const { data } = await fetchUsrMeetingInfo();
  77. if (!data) {
  78. this.$refs.uToast.show({
  79. type: 'default',
  80. message: '您暂未报名,请先报名',
  81. complete() {
  82. },
  83. });
  84. return;
  85. }
  86. const {reviewState} = data
  87. if ([REVIEW_STATUS.wait.value,REVIEW_STATUS.noPass.value].includes(reviewState)){
  88. this.$refs.uToast.show({
  89. type: 'default',
  90. message: '审核未通过,请耐心等待',
  91. complete() {
  92. },
  93. });
  94. return;
  95. }
  96. fetchContentInfo({
  97. pageNum: page,
  98. pageSize: 10,
  99. contentType: CONTENT_TYPE.conferenceMaterials,
  100. title: this.keyword,
  101. }).then(res => {
  102. page += 1;
  103. if (res.rows.length > 0) {
  104. this.indexList = this.indexList.concat(res.rows.map(item => {
  105. return {
  106. id: item.id,
  107. title: item.fileName,
  108. date: item.createTime,
  109. imgUrl: getImageUrl(item.thumbnail),
  110. ...item,
  111. };
  112. }));
  113. }
  114. if (res.rows.length < 10) {
  115. this.loadStatus = 'nomore';
  116. }
  117. });
  118. },
  119. onSearch() {
  120. page = 1;
  121. this.indexList = [];
  122. this.loadmore();
  123. },
  124. },
  125. };
  126. </script>
  127. <style lang="scss" src="./index.scss" />