小说小程序前端代码仓库(小程序)
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.

128 lines
2.8 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.unreadComments.forEach(n => {
  86. this.updateCommentRead(n.id)
  87. })
  88. })
  89. },
  90. updateCommentRead(commentId){
  91. this.$fetch('updateCommentRead', {
  92. commentId
  93. })
  94. },
  95. }
  96. }
  97. </script>
  98. <style scoped lang="scss">
  99. .my-comment-page {
  100. min-height: 100vh;
  101. background: #f8f8f8;
  102. display: flex;
  103. flex-direction: column;
  104. }
  105. .comment-section {
  106. background: #fff;
  107. margin: 24rpx 24rpx 0 24rpx;
  108. border-radius: 16rpx;
  109. padding: 24rpx 24rpx 0 24rpx;
  110. margin-bottom: 24rpx;
  111. }
  112. .section-title {
  113. color: #222;
  114. font-size: 28rpx;
  115. font-weight: 500;
  116. margin-bottom: 16rpx;
  117. }
  118. </style>