index.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 { CONTENT_TYPE } from '@/common/EnumConst';
  23. import ItemList from '@/components/ItemList/index.vue';
  24. import { getImageUrl } from '@/util';
  25. export default {
  26. components: {
  27. ItemList,
  28. },
  29. data() {
  30. return {
  31. keyword: '',
  32. indexList: [],
  33. };
  34. },
  35. onLoad(option) {
  36. this.keyword = option?.keyword || '';
  37. this.loadmore();
  38. },
  39. methods: {
  40. async loadmore() {
  41. let result = [];
  42. const res = await fetchContentInfo({
  43. pageNum: 1,
  44. pageSize: 99,
  45. contentType: CONTENT_TYPE.news,
  46. title: this.keyword,
  47. });
  48. if (res.rows.length > 0) {
  49. result = res.rows.map(item => {
  50. return {
  51. id: item.id,
  52. imgUrl: getImageUrl(item.thumbnail),
  53. title: item.title,
  54. date: item.createTime,
  55. };
  56. });
  57. }
  58. this.indexList = result;
  59. },
  60. onContentClick(item) {
  61. uni.navigateTo({
  62. url: `/pasb/pages/detail/index?id=${item.id}`,
  63. });
  64. },
  65. },
  66. };
  67. </script>
  68. <style lang="scss" src="./index.scss" />