index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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">
  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 } 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 } = fetchUsrMeetingInfo();
  77. if (!data) {
  78. this.$refs.uToast.show({
  79. type: 'default',
  80. message: '您暂未报名,请先报名',
  81. complete() {
  82. },
  83. });
  84. return;
  85. }
  86. fetchContentInfo({
  87. pageNum: page,
  88. pageSize: 10,
  89. contentType: CONTENT_TYPE.conferenceMaterials,
  90. title: this.keyword,
  91. }).then(res => {
  92. page += 1;
  93. if (res.rows.length > 0) {
  94. this.indexList = this.indexList.concat(res.rows.map(item => {
  95. return {
  96. id: item.id,
  97. title: item.fileName,
  98. date: item.createTime,
  99. imgUrl: getImageUrl(item.thumbnail),
  100. ...item,
  101. };
  102. }));
  103. }
  104. if (res.rows.length < 10) {
  105. this.loadStatus = 'nomore';
  106. }
  107. });
  108. },
  109. onSearch() {
  110. page = 1;
  111. this.indexList = [];
  112. this.loadmore();
  113. },
  114. },
  115. };
  116. </script>
  117. <style lang="scss" src="./index.scss" />