index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view class="file-info-container">
  3. <view class="search-content">
  4. <u-search placeholder="请输入关键字" v-model="keyword" @custom="onSearch" @search="onSearch"></u-search>
  5. </view>
  6. <view class="u-page">
  7. <u-list
  8. v-if="indexList.length>0"
  9. @scrolltolower="scrolltolower"
  10. >
  11. <u-list-item
  12. v-for="(item, index) in indexList"
  13. :key="index"
  14. >
  15. <view class="file-info-item" @click="onItemClick(item)">
  16. <view class="file-info-item-img">
  17. <image :src="item.imgUrl" mode="aspectFill" />
  18. </view>
  19. <view class="file-info-item-content">
  20. <view class="file-info-item-title">{{ item.title }}</view>
  21. <view class="file-info-item-date">{{ item.date }}</view>
  22. </view>
  23. </view>
  24. </u-list-item>
  25. </u-list>
  26. <u-loadmore :status="loadStatus" />
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { fetchContentInfo } from '@/common/api';
  32. import { CONTENT_TYPE, ICON_CFG } from '@/common/EnumConst';
  33. import { fileIcon, getImageUrl } from '@/util';
  34. let page = 1;
  35. export default {
  36. name: 'content',
  37. props: {},
  38. data() {
  39. return {
  40. ICON_CFG,
  41. keyword: '',
  42. indexList: [],
  43. loadStatus: 'loadmore', // loadmore,loading,nomore
  44. };
  45. },
  46. created() {
  47. },
  48. onLoad() {
  49. page = 1;
  50. this.loadmore();
  51. },
  52. methods: {
  53. fileIcon,
  54. getImageUrl,
  55. onItemClick(item) {
  56. // viewFileFn(getImageUrl(item.uri), item.title, `.${item.fileExt}`);
  57. uni.navigateTo({
  58. url: `/pasb/pages/detail/index?id=${item.id}`,
  59. });
  60. },
  61. scrolltolower() {
  62. if (page > 1 && this.loadStatus === 'nomore') {
  63. return;
  64. }
  65. this.loadmore();
  66. },
  67. loadmore() {
  68. this.loadStatus = 'loading';
  69. fetchContentInfo({
  70. pageNum: 1,
  71. pageSize: 99,
  72. contentType: CONTENT_TYPE.conferenceMaterials,
  73. title: this.keyword,
  74. }).then(res => {
  75. page += 1;
  76. if (res.rows.length > 0) {
  77. this.indexList = this.indexList.concat(res.rows.map(item => {
  78. return {
  79. id: item.id,
  80. title: item.fileName,
  81. date: item.createTime,
  82. imgUrl: getImageUrl(item.thumbnail),
  83. ...item,
  84. };
  85. }));
  86. }
  87. if (res.rows.length < 10) {
  88. this.loadStatus = 'nomore';
  89. }
  90. });
  91. },
  92. onSearch() {
  93. page = 1;
  94. this.indexList = [];
  95. this.loadmore();
  96. },
  97. },
  98. };
  99. </script>
  100. <style lang="scss" src="./index.scss" />;