index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="discover_note_topic" :data-theme="theme">
  3. <view class="header">
  4. <view class="name color28 mb20"><text class="iconfont icon-huati mr20"></text>{{topicDetails.name?topicDetails.name:''}}</view>
  5. <view class="noteNum">
  6. {{ (topicDetails.noteNum && topicDetails.noteNum<10000) ? topicDetails.noteNum+'篇内容' : topicDetails.noteNum &&(topicDetails.noteNum/10000).toFixed(2)+'万篇内容'}}
  7. </view>
  8. </view>
  9. <view class="borderPad">
  10. <view class="acea-row row-center-wrapper tab">
  11. <view :class="params.type == 'hot'? 'on' : ''" class="nav-item" @click="onChange('hot')">最热</view>
  12. <view :class="params.type == 'new'? 'on' : ''" class="nav-item" @click="onChange('new')">最新</view>
  13. </view>
  14. </view>
  15. <view class="borderPad">
  16. <WaterfallsFlow v-if="noteTopicList.length" :wfList="noteTopicList" :fromType="1">
  17. </WaterfallsFlow>
  18. </view>
  19. <view class="publish" @click="publish"><text class="iconfont icon-fabu2"></text>立即发布</view>
  20. </view>
  21. </template>
  22. <script>
  23. import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlow.vue';
  24. import animationType from '@/utils/animationType.js';
  25. import {
  26. topicCountApi,
  27. noteTopicListApi
  28. } from '@/api/discover.js';
  29. let app = getApp();
  30. export default {
  31. components: {
  32. WaterfallsFlow
  33. },
  34. data() {
  35. return {
  36. theme: app.globalData.theme,
  37. params: {
  38. page: 1,
  39. limit: 10,
  40. topicId: 0,
  41. type: 'hot'
  42. },
  43. loadend: false,
  44. loading: false,
  45. noteTopicList: [],
  46. topicDetails: {}
  47. }
  48. },
  49. watch: {
  50. 'params.type': {
  51. handler: function(newV, oldV) {
  52. if (newV) {
  53. this.noteTopicList = [];
  54. this.getNoteTopicList();
  55. }
  56. },
  57. deep: true
  58. }
  59. },
  60. onLoad(options) {
  61. this.params.topicId = options.topicId;
  62. this.getTopicCount();
  63. this.getNoteTopicList();
  64. },
  65. onReachBottom() {
  66. this.getNoteTopicList(); // 推荐
  67. },
  68. // 滚动监听
  69. onPageScroll(e) {
  70. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  71. uni.$emit('scroll');
  72. },
  73. methods: {
  74. //发布内容
  75. publish() {
  76. // #ifdef MP || H5
  77. uni.navigateTo({
  78. url: `/pages/discover/discover_release/index`
  79. })
  80. // #endif
  81. // #ifdef APP-PLUS
  82. uni.navigateTo({
  83. animationType: animationType.type,
  84. animationDuration: animationType.duration,
  85. url: `/pages/discover/discover_release/index`
  86. })
  87. // #endif
  88. },
  89. //点击切换
  90. onChange(type) {
  91. this.params.page = 1;
  92. this.params.type = type;
  93. this.loading = false;
  94. this.loadend = false;
  95. },
  96. //话题
  97. getTopicCount() {
  98. topicCountApi(this.params.topicId).then(res => {
  99. this.topicDetails = res.data;
  100. }).catch(err => {
  101. uni.showToast({
  102. title: err,
  103. icon: 'none'
  104. })
  105. });
  106. },
  107. //关注内容
  108. getNoteTopicList() {
  109. if (this.loadend) return;
  110. this.loading = true;
  111. noteTopicListApi(this.params).then(res => {
  112. this.$set(this.params, 'page', this.params.page + 1);
  113. this.loadend = this.params.page > res.data.totalPage;
  114. this.noteTopicList = this.noteTopicList.concat(res.data.list || []);
  115. this.loading = false
  116. }).catch(err => {
  117. this.loading = false;
  118. uni.showToast({
  119. title: err,
  120. icon: 'none'
  121. })
  122. });
  123. },
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .publish {
  129. position: fixed;
  130. z-index: 9999;
  131. width: 240rpx;
  132. height: 76rpx;
  133. opacity: 1;
  134. border-radius: 38rpx;
  135. bottom: 142rpx;
  136. right: 50%;
  137. margin-right: -60px;
  138. color: #fff;
  139. line-height: 76rpx;
  140. text-align: center;
  141. @include linear-gradient(theme);
  142. font-size: 30rpx;
  143. .iconfont {
  144. font-size: 28rpx;
  145. margin-right: 16rpx;
  146. }
  147. }
  148. .nav-item {
  149. font-size: 32rpx;
  150. color: #999;
  151. &:first-child {
  152. margin-right: 70rpx;
  153. }
  154. &.on {
  155. position: relative;
  156. font-size: 38rpx;
  157. color: #333;
  158. font-weight: bold;
  159. &::after {
  160. content: "";
  161. width: 40rpx;
  162. height: 5rpx;
  163. @include main_bg_color(theme);
  164. position: absolute;
  165. bottom: -10rpx;
  166. left: 14rpx;
  167. }
  168. }
  169. }
  170. .discover_note_topic {
  171. background-color: #fff;
  172. position: relative;
  173. }
  174. .tab {
  175. border-top: 1px solid #EEEEEE;
  176. padding: 30rpx 0 37rpx 0;
  177. }
  178. .header {
  179. padding: 40rpx 24rpx;
  180. .name {
  181. font-size: 34rpx;
  182. font-weight: 600;
  183. }
  184. .noteNum {
  185. font-size: 24rpx;
  186. color: #666666;
  187. }
  188. }
  189. </style>