index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <view class="fui-wrap">
  3. <view class="search-content">
  4. <u-search placeholder="请输入关键字" v-model="keyword"></u-search>
  5. </view>
  6. <view class="u-page">
  7. <view class="u-page-title">
  8. <view class="line"></view>
  9. <view class="rectangle"></view>
  10. <view class="rectangle"></view>
  11. <view class="title-content">最新资讯</view>
  12. <view class="rectangle"></view>
  13. <view class="rectangle"></view>
  14. <view class="line"></view>
  15. </view>
  16. <item-list :ds="indexList" :onItemClick="onContentClick" />
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import { fetchContentInfo } from '@/common/api';
  22. import ItemList from '@/components/ItemList/index.vue';
  23. import { getImageUrl } from '@/util';
  24. export default {
  25. components: {
  26. ItemList,
  27. },
  28. data() {
  29. return {
  30. keyword: this.queryParams?.keyword || '',
  31. indexList: [],
  32. };
  33. },
  34. watch: {
  35. keyword(val) {
  36. this.indexList = [];
  37. this.loadmore();
  38. },
  39. },
  40. onLoad() {
  41. this.loadmore();
  42. },
  43. methods: {
  44. async loadmore() {
  45. const res = await fetchContentInfo({
  46. pageNum: 1,
  47. pageSize: 99,
  48. title: this.keyword,
  49. });
  50. this.indexList = res.rows.map(item => {
  51. return {
  52. id: item.id,
  53. imgUrl: getImageUrl(item.thumbnail),
  54. title: item.title,
  55. date: item.createTime,
  56. };
  57. });
  58. },
  59. onContentClick(item) {
  60. uni.navigateTo({
  61. url: `/pages/detail/index?id=${item.id}`,
  62. });
  63. },
  64. },
  65. };
  66. </script>
  67. <style lang="scss" src="./index.scss" />