index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="con">
  3. <view class="search ddflex">
  4. <image src="../../static/images/ssico.png" class="ssico"></image>
  5. <input v-model="searchTitle" @input="inputEvn" placeholder="搜索更多话题" placeholder-class="placeholder" class="ipt fflex" />
  6. </view>
  7. <view class="list" v-if="hotTopicList && hotTopicList.length > 0">
  8. <view :class="'li ' + item.bg" v-for="(item, index) in hotTopicList" :key="index" @click="jumpUrl('/topics/detail/detail?topicId=' + item.id)">
  9. <view class="topic ddflex">
  10. <view class="fflex">
  11. <view class="title"># {{ item.title }}</view>
  12. <view class="cy">{{ item.participantsNO }}参与</view>
  13. </view>
  14. <!-- <view class="gzbtn">+关注</view> -->
  15. </view>
  16. <view class="lis ddflex" v-if="item.momentsList && item.momentsList.length > 0" v-for="(it, idx) in item.momentsList" :key="idx">
  17. <image :src="'../static/images/' + (idx == 0 ? 'ht_jing' : 'ht_li') + '.png'"></image>
  18. <!-- <view class="fflex tover">{{ removeHtml(it.content) }}</view> -->
  19. <view class="fflex"><rich-text :nodes="it.content"></rich-text></view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="nodata" v-else>
  24. <image :src="picUrlss + 'empty_jl.png'"></image>
  25. <text>没有相关话题</text>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. const app = getApp();
  31. const req = require('../../utils/request.js');
  32. const util = require('../../utils/util.js');
  33. export default {
  34. data() {
  35. return {
  36. picUrlss: req.public.picUrls,
  37. isLoad: true,
  38. form: {
  39. page: 1,
  40. limit: 10
  41. },
  42. bgList: ['bg1', 'bg2', 'bg3', 'bg4'],
  43. hotTopicList: [],
  44. searchTitle: '',
  45. config: {}
  46. };
  47. },
  48. onLoad() {
  49. },
  50. onShow() {
  51. this.isLoad = true
  52. this.form.page = 1
  53. this.getHotTopic();
  54. },
  55. onReachBottom() {
  56. this.form.page++;
  57. this.getHotTopic();
  58. },
  59. methods: {
  60. removeHtml(content) {
  61. return util.removeHtml(content);
  62. },
  63. randomBg() {
  64. let random = this.bgList[Math.floor(Math.random() * this.bgList.length)];
  65. return random;
  66. },
  67. inputEvn(e) {
  68. this.form.page = 1;
  69. this.isLoad = true;
  70. this.getHotTopic();
  71. },
  72. jumpUrl(url) {
  73. uni.navigateTo({
  74. url: url
  75. });
  76. },
  77. getHotTopic() {
  78. var tha = this;
  79. if (!this.isLoad) return false;
  80. this.isLoad = false;
  81. var dataPram = {};
  82. dataPram.page = this.form.page;
  83. dataPram.limit = this.form.limit;
  84. if (this.searchTitle) {
  85. console.log('关键词====', this.searchTitle);
  86. dataPram.search = this.searchTitle;
  87. }
  88. dataPram.orderType = 1;
  89. req.getRequest('/api/v3/dialogue/listV2', dataPram, data => {
  90. if (data && data.length >= this.form.limit) {
  91. this.isLoad = true;
  92. }
  93. if (data) {
  94. data.map(item => {
  95. let random = tha.randomBg();
  96. item.bg = random;
  97. return item;
  98. });
  99. }
  100. if (this.form.page > 1) {
  101. data = this.hotTopicList.concat(data);
  102. }
  103. this.hotTopicList = data;
  104. });
  105. }
  106. }
  107. };
  108. </script>
  109. <style>
  110. @import './index.css';
  111. </style>