index.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <auth-wrap class="usr-collect-info-container" ref="authWrap">
  3. <template slot="content">
  4. <view class="search-content">
  5. <u-search placeholder="请输入关键字" v-model="keyword" @custom="onSearch" @search="onSearch"></u-search>
  6. </view>
  7. <view class="u-page" v-if="indexList&&indexList.length>0">
  8. <item-list :ds="indexList" :onItemClick="onContentClick" />
  9. </view>
  10. <u-empty
  11. v-else
  12. mode="data"
  13. text="还没有收藏,赶紧去收藏吧!"
  14. >
  15. </u-empty>
  16. </template>
  17. </auth-wrap>
  18. </template>
  19. <script>
  20. import { fetchUsrContentInfo } from '@/common/api';
  21. import AuthWrap from '@/components/AuthComp/index.vue';
  22. import ItemList from '@/components/ItemList/index.vue';
  23. import { getImageUrl } from '@/util';
  24. export default {
  25. components: {
  26. AuthWrap,
  27. ItemList,
  28. },
  29. data() {
  30. return {
  31. keyword: '',
  32. indexList: [],
  33. };
  34. },
  35. onLoad() {
  36. this.$refs.authWrap.reloadPage();
  37. this.loadmore();
  38. },
  39. methods: {
  40. onContentClick(item) {
  41. uni.navigateTo({
  42. url: `/pasb/pages/detail/index?id=${item.id}`,
  43. });
  44. },
  45. async loadmore(keyword = '') {
  46. const res = await fetchUsrContentInfo({
  47. pageNum: 1,
  48. pageSize: 999,
  49. contentType: 3,
  50. title: keyword,
  51. });
  52. this.indexList = res.rows.map(item => {
  53. return {
  54. id: item.id,
  55. imgUrl: getImageUrl(item.thumbnail),
  56. title: item.title,
  57. date: item.updateTime,
  58. };
  59. });
  60. },
  61. onSearch(val) {
  62. this.loadmore(val);
  63. },
  64. },
  65. onShareAppMessage() {
  66. return {
  67. title: 'First UI组件库',
  68. };
  69. },
  70. };
  71. </script>
  72. <style lang="scss" src="./index.scss" />