index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <!-- 专家分析列表 -->
  3. <view>
  4. <ui-sticky>
  5. <ui-search placeholder="请输入关键字" @confirm="searchArticle"></ui-search>
  6. </ui-sticky>
  7. <view class="ui-card article-item" v-for="(item,index) in articleList" :key="index">
  8. <view class="row-between">
  9. <view class="title">分析人:{{item.user_name}}</view>
  10. <view class="time">{{item.create_time }}</view>
  11. </view>
  12. <!-- <view class="">
  13. {{item.foreword}}
  14. </view> -->
  15. <view class="text" :class="item.toggle?'':'shadow'">
  16. <rich-text :nodes="item.content"></rich-text>
  17. </view>
  18. <view class="row-center more" :class="item.toggle?'':'shadow'" @click="toggleReadMore(index)">
  19. {{item.toggle?'收起':'展开'}}
  20. <uni-icons :type="item.toggle?'top':'bottom'" color="#317afd" size="16"></uni-icons>
  21. </view>
  22. </view>
  23. <ui-empty v-if="articleList.length==0" text="暂无分析信息"></ui-empty>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. getArticleList,
  29. } from '@/api/common.js'
  30. export default {
  31. data() {
  32. return {
  33. // 专家分析列表
  34. articleList: [],
  35. params: {
  36. key_word: '',
  37. start_time: '',
  38. end_time: '',
  39. article_type: 3, // 3 表示虫情,5 表示气象, 8 表示墒情
  40. page: 1, //页数 默认为1
  41. page_size: 10, //数据条数据 默认为10
  42. },
  43. total: 0,
  44. }
  45. },
  46. async onLoad(options) {
  47. await this.$onLaunched;
  48. this.params.article_type = options.type ?? 3;
  49. this.getArticleList();
  50. },
  51. // 触底请求
  52. onReachBottom(e) {
  53. if (this.articleList.length >= this.total) {
  54. return;
  55. }
  56. this.params.page += 1;
  57. this.getArticleList();
  58. },
  59. //下拉刷新
  60. onPullDownRefresh() {
  61. this.refreshArticleList();
  62. uni.stopPullDownRefresh()
  63. },
  64. methods: {
  65. searchArticle(e) {
  66. this.params.key_word = e;
  67. this.refreshArticleList();
  68. },
  69. // 刷新列表
  70. refreshArticleList() {
  71. this.params.page = 1;
  72. this.articleList = [];
  73. this.getArticleList();
  74. },
  75. // 获取分析列表
  76. async getArticleList() {
  77. const {
  78. total_num,
  79. data
  80. } = await getArticleList(this.params);
  81. this.articleList = [...this.articleList, ...data];
  82. this.total = total_num ?? 0;
  83. },
  84. // 切换文章状态
  85. toggleReadMore(index) {
  86. let article = this.articleList[index];
  87. article.toggle = !article.toggle;
  88. this.$set(this.articleList, index, article);
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .article-item {
  95. padding: 26rpx 24rpx;
  96. overflow: hidden;
  97. .title {
  98. font-size: $font-size-title;
  99. font-weight: bold;
  100. color: $color-primary;
  101. line-height: $line-height-title;
  102. }
  103. .text {
  104. margin-top: 10rpx;
  105. margin-bottom: 10rpx;
  106. font-size: $font-size-subtitle;
  107. color: $color-subtitle;
  108. line-height: $line-height-subtitle;
  109. overflow: hidden;
  110. &.shadow {
  111. max-height: 200rpx;
  112. }
  113. }
  114. .more {
  115. font-size: 26rpx;
  116. color: $color-primary;
  117. text-align: center;
  118. &.shadow {
  119. position: relative;
  120. background-image: linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, #fff 80%);
  121. padding-top: 160rpx;
  122. margin-top: -160rpx;
  123. }
  124. }
  125. .time {
  126. padding: 6rpx 15rpx;
  127. font-size: 28rpx;
  128. color: #333;
  129. line-height: 1;
  130. border-radius: 4rpx;
  131. }
  132. }
  133. </style>