index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: '',
  31. indexList: [],
  32. };
  33. },
  34. onLoad(option) {
  35. this.keyword = option?.keyword || '';
  36. this.loadmore();
  37. },
  38. methods: {
  39. async loadmore() {
  40. let result = [];
  41. const res = await fetchContentInfo({
  42. pageNum: 1,
  43. pageSize: 99,
  44. title: this.keyword,
  45. });
  46. if (res.rows.length > 0) {
  47. result = res.rows.map(item => {
  48. return {
  49. id: item.id,
  50. imgUrl: getImageUrl(item.thumbnail),
  51. title: item.title,
  52. date: item.createTime,
  53. };
  54. });
  55. }
  56. this.indexList = result;
  57. },
  58. onContentClick(item) {
  59. uni.navigateTo({
  60. url: `/pasb/pages/detail/index?id=${item.id}`,
  61. });
  62. },
  63. },
  64. };
  65. </script>
  66. <style lang="scss" src="./index.scss" />