小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
2.6 KiB

  1. <template>
  2. <view class="my-comment-page">
  3. <navbar title="我的评论" :leftClick="true" @leftClick="$utils.navigateBack" />
  4. <uv-tabs :list="tabs"
  5. :activeStyle="{ color: '#0A2463', fontWeight: 600 }"
  6. lineColor="#0A2463" lineHeight="8rpx"
  7. lineWidth="50rpx"
  8. :scrollable="false"
  9. :current="current"
  10. @click="clickTabs"></uv-tabs>
  11. <template v-if="current == 0">
  12. <view class="comment-section">
  13. <myCommentItem :item="item"
  14. edit
  15. @getData="getData"
  16. v-for="(item, idx) in list" :key="idx"/>
  17. </view>
  18. </template>
  19. <template v-if="current == 1">
  20. <view class="comment-section">
  21. <view class="section-title">未读评论·{{ unreadComments.length }}</view>
  22. <myCommentItem :item="item" v-for="(item, idx) in unreadComments" :key="idx"/>
  23. <uv-empty mode="list" v-if="unreadComments.length == 0"></uv-empty>
  24. </view>
  25. <view class="comment-section history-section">
  26. <view class="section-title">历史评论</view>
  27. <myCommentItem
  28. :item="item"
  29. v-for="(item, idx) in list" :key="idx"/>
  30. </view>
  31. </template>
  32. <uv-empty mode="list" v-if="list.length == 0"></uv-empty>
  33. </view>
  34. </template>
  35. <script>
  36. import mixinsList from '@/mixins/list.js'
  37. import myCommentItem from '../components/comment/myCommentItem.vue'
  38. export default {
  39. mixins: [mixinsList],
  40. components: {
  41. myCommentItem,
  42. },
  43. data() {
  44. return {
  45. mixinsListApi : 'getMyCommentList',
  46. unreadComments: [],
  47. tabs: [
  48. {
  49. name: '我的评论'
  50. },
  51. {
  52. name: '回复我的'
  53. },
  54. ],
  55. current : 0,
  56. apiList : [
  57. 'getMyCommentList',
  58. 'getMyReplyCommentList'
  59. ],
  60. }
  61. },
  62. onLoad() {
  63. this.queryParams.type = 'Y'
  64. this.mixinsListApi = this.apiList[this.current]
  65. },
  66. onShow() {
  67. this.getList()
  68. },
  69. methods: {
  70. //点击tab栏
  71. clickTabs({ index }) {
  72. this.queryParams.pageSize = 10
  73. this.current = index
  74. this.mixinsListApi = this.apiList[this.current]
  75. this.getData()
  76. },
  77. //获取未读
  78. getList(){
  79. this.$fetch('getMyReplyCommentList', {
  80. type : 'N',
  81. pageNo: 1,
  82. pageSize: 100000
  83. }).then(res => {
  84. this.unreadComments = res.records
  85. this.$fetch('updateCommentRead')
  86. })
  87. },
  88. }
  89. }
  90. </script>
  91. <style scoped lang="scss">
  92. .my-comment-page {
  93. min-height: 100vh;
  94. background: #f8f8f8;
  95. display: flex;
  96. flex-direction: column;
  97. }
  98. .comment-section {
  99. background: #fff;
  100. margin: 24rpx 24rpx 0 24rpx;
  101. border-radius: 16rpx;
  102. padding: 24rpx 24rpx 0 24rpx;
  103. margin-bottom: 24rpx;
  104. }
  105. .section-title {
  106. color: #222;
  107. font-size: 28rpx;
  108. font-weight: 500;
  109. margin-bottom: 16rpx;
  110. }
  111. </style>