index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. debugger
  37. this.$refs.authWrap.reloadPage();
  38. this.loadmore();
  39. },
  40. methods: {
  41. onContentClick(item) {
  42. uni.navigateTo({
  43. url: `/pasb/pages/detail/index?id=${item.id}`,
  44. });
  45. },
  46. async loadmore(keyword = '') {
  47. const res = await fetchUsrContentInfo({
  48. pageNum: 1,
  49. pageSize: 999,
  50. contentType: 3,
  51. title: keyword,
  52. });
  53. this.indexList = res.rows.map(item => {
  54. return {
  55. id: item.id,
  56. imgUrl: getImageUrl(item.thumbnail),
  57. title: item.title,
  58. date: item.updateTime,
  59. };
  60. });
  61. },
  62. onSearch(val) {
  63. this.loadmore(val);
  64. },
  65. },
  66. onShareAppMessage() {
  67. return {
  68. title: 'First UI组件库',
  69. };
  70. },
  71. };
  72. </script>
  73. <style lang="scss" src="./index.scss" />