comment.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view>
  3. <!-- 顶部导航 -->
  4. <fa-navbar title="我发表的评论"></fa-navbar>
  5. <view class="comment" v-for="(res, index) in commentList" :key="res.id" @click="goDetail(res.archives)">
  6. <view class="left"><image :src="res.archives && res.archives.image" mode="aspectFill"></image></view>
  7. <view class="right">
  8. <view class="content u-line-2">{{res.archives && res.archives.title }}</view>
  9. <view class="reply-box">
  10. <view class="item">
  11. <view class="u-tips-color"><rich-text :nodes="res.content"></rich-text></view>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 回到顶部 -->
  17. <u-back-top :scroll-top="scrollTop" :icon-style="{color:theme.bgColor}" :custom-style="{backgroundColor:lightColor}"></u-back-top>
  18. <!-- 为空 -->
  19. <view class="u-m-t-60 u-p-t-60 u-p-b-60" v-if="is_empty">
  20. <u-empty text="您还没有评论哦.." mode="list"></u-empty>
  21. </view>
  22. <!-- 更多 -->
  23. <view class="u-p-t-30 u-p-b-30"><u-loadmore :status="has_more ? status : 'nomore'" /></view>
  24. <!-- 底部导航 -->
  25. <fa-tabbar></fa-tabbar>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. commentList: [],
  33. page: 1,
  34. has_more: false,
  35. status: 'loadmore',
  36. scrollTop: 0,
  37. is_empty:false
  38. };
  39. },
  40. onLoad() {
  41. this.getComment();
  42. },
  43. methods: {
  44. // 评论列表
  45. getComment: async function() {
  46. let res = await this.$api.getMyComment({ page: this.page });
  47. this.status = 'loadmore';
  48. if (!res.code) {
  49. this.$u.toast(res.msg);
  50. return;
  51. }
  52. this.commentList = this.commentList.concat(res.data.commentList.data);
  53. this.has_more = res.data.commentList.last_page > res.data.commentList.current_page;
  54. this.is_empty = !this.commentList.length;
  55. },
  56. goDetail(item) {
  57. let p = item.model_id == 2 ? '/pages/product/detail' : '/pages/article/detail';
  58. this.$Router.push({
  59. path:p,
  60. query:{id:item.id}
  61. });
  62. }
  63. },
  64. onPageScroll(e) {
  65. this.scrollTop = e.scrollTop;
  66. },
  67. //底部加载更多
  68. onReachBottom() {
  69. if (this.has_more) {
  70. this.status = 'loading';
  71. this.page++;
  72. this.getComment();
  73. }
  74. }
  75. };
  76. </script>
  77. <style>
  78. page {
  79. background-color: #ffffff;
  80. }
  81. </style>
  82. <style lang="scss" scoped>
  83. .comment {
  84. display: flex;
  85. padding: 30rpx;
  86. border-bottom: 1px solid #eee;
  87. .left {
  88. image {
  89. width: 180rpx;
  90. height: 130rpx;
  91. background-color: #f2f2f2;
  92. border-radius: 10rpx;
  93. }
  94. }
  95. .right {
  96. flex: 1;
  97. padding-left: 20rpx;
  98. font-size: 28rpx;
  99. .content {
  100. margin-bottom: 10rpx;
  101. }
  102. .reply-box {
  103. background-color: rgb(242, 242, 242);
  104. border-radius: 12rpx;
  105. .item {
  106. padding: 20rpx;
  107. word-break: break-word;
  108. }
  109. }
  110. }
  111. }
  112. </style>