index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view @touchmove.stop.prevent="moveHandle">
  3. <u-popup :show="show" :round="10">
  4. <view class="content">
  5. <view class="title">
  6. <text>共{{total}}条评论</text>
  7. <u-icon name="close" @click="close"></u-icon>
  8. </view>
  9. <scroll-view style="maxHeight:60vh" :scroll-y="true" :refresher-enabled="true"
  10. :refresher-triggered="triggered" @scrolltolower="scrolltolower" @refresherrefresh="onRefresh"
  11. refresher-default-style="black">
  12. <!-- 需要滚动的区域 -->
  13. <view class="commentBox" v-for="item in 10" :key="item">
  14. <view class="left">
  15. <!-- 圆形标记 -->
  16. <view class="comment_round"></view>
  17. <!-- 头像 -->
  18. <u-avatar :src="avatarSrc" shape="square"></u-avatar>
  19. </view>
  20. <!-- 名称、内容等 -->
  21. <view class="comment_detail">
  22. <view class="comment_info">
  23. <view class="name">开心小市民</view>
  24. <view class="likeNum">
  25. <i class="custom-icon custom-icon-thumb-up"></i>
  26. 543
  27. </view>
  28. </view>
  29. <view class="comment_content">我还在用果6</view>
  30. <view class="comment_func">
  31. <view>
  32. <text class="reply" @click="handleApply">回复></text>
  33. <text class="time">2分钟前</text>
  34. </view>
  35. <view class="delete">删除</view>
  36. </view>
  37. </view>
  38. </view>
  39. </scroll-view>
  40. <!-- 评论框 -->
  41. <u--input placeholder="写评论" prefixIcon="edit-pen"
  42. prefixIconStyle="font-size: 22px;color: #909399;margin-left:10px" border="none"
  43. :customStyle="{height:'80rpx',marginTop: '50rpx',backgroundColor: '#eee'}"></u--input>
  44. </view>
  45. </u-popup>
  46. <!-- 回复弹出组件 -->
  47. <Reply :show="replyShow" @close="closeReply" />
  48. </view>
  49. </template>
  50. <script>
  51. import Reply from '@/components/Reply/index.vue'
  52. export default {
  53. components: {
  54. Reply
  55. },
  56. props: {
  57. // 弹出层是否展示
  58. show: {
  59. type: Boolean,
  60. default: false
  61. },
  62. },
  63. data() {
  64. return {
  65. total: 0, // 总评论量
  66. triggered: false, // 下拉是否激活
  67. list: [], // 列表数据
  68. pageNum: 1,
  69. pageSize: 10,
  70. isRequesting: false, // 是否正在请求,如果是则返回,用于节流
  71. replyShow: false,
  72. avatarSrc: "http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg",
  73. };
  74. },
  75. methods: {
  76. closeReply() {
  77. this.replyShow = false
  78. },
  79. // 点击弹出回复框
  80. handleApply() {
  81. this.replyShow = true
  82. },
  83. // 关闭弹出框
  84. close() {
  85. this.$emit('close')
  86. },
  87. // 禁止外层容器滚动
  88. moveHandle() {},
  89. // 上拉加载
  90. scrolltolower() {
  91. if (this.list.length < this.total) {
  92. this.pageNum += 1;
  93. // 继续请求下一页,记得保留原先数组
  94. this.loadmore();
  95. } else {
  96. uni.showToast({
  97. title: "没有更多了",
  98. icon: "none",
  99. duration: 2000,
  100. });
  101. return;
  102. }
  103. },
  104. // 自定义下拉刷新被触发
  105. onRefresh() {
  106. // 开启下拉自定义样式
  107. this.triggered = true;
  108. // 重新调用
  109. this.loadmore();
  110. // 1秒之后复位
  111. setTimeout(() => {
  112. this.triggered = false;
  113. }, 1000);
  114. },
  115. scrolltolower() {
  116. this.loadmore();
  117. },
  118. loadmore() {
  119. this.request('/info/InfoContent/list', 'GET').then(res => {
  120. console.log("res:", res)
  121. if (res) {}
  122. })
  123. },
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .u-popup {
  129. .content {
  130. // min-height: 600rpx;
  131. padding: 40rpx;
  132. max-height: 80%;
  133. }
  134. .title {
  135. display: flex;
  136. justify-content: space-between;
  137. font-size: 50rpx;
  138. font-weight: 900;
  139. margin-bottom: 60rpx;
  140. }
  141. .commentBox {
  142. width: 100%;
  143. display: flex;
  144. color: #000;
  145. font-size: 32rpx;
  146. margin-bottom: 20rpx;
  147. .left {
  148. height: 80rpx;
  149. // background-color: red;
  150. display: flex;
  151. align-items: center;
  152. margin-right: 30rpx;
  153. .comment_round {
  154. width: 20rpx;
  155. height: 20rpx;
  156. background-color: #ff2950;
  157. border-radius: 50%;
  158. margin-right: 20rpx;
  159. }
  160. }
  161. .comment_detail {
  162. width: 100%;
  163. .comment_info {
  164. display: flex;
  165. justify-content: space-between;
  166. .name {
  167. font-weight: 600;
  168. }
  169. .likeNum {
  170. font-size: 28rpx;
  171. }
  172. .custom-icon {
  173. margin-right: 10rpx;
  174. font-size: 40rpx;
  175. &::before {
  176. background: -webkit-linear-gradient(top, #f84a1a, #ffa53e);
  177. -webkit-background-clip: text;
  178. -webkit-text-fill-color: transparent;
  179. font-weight: bold;
  180. }
  181. }
  182. }
  183. .comment_content {
  184. margin: 20rpx 0;
  185. color: #333;
  186. }
  187. .comment_func {
  188. display: flex;
  189. justify-content: space-between;
  190. align-items: center;
  191. .reply {
  192. color: #f87f2d;
  193. font-size: 28rpx;
  194. margin-right: 10rpx;
  195. font-weight: 600;
  196. }
  197. .time {
  198. color: #999;
  199. font-size: 28rpx;
  200. }
  201. .delete {
  202. font-size: 28rpx;
  203. ;
  204. width: 100rpx;
  205. height: 50rpx;
  206. line-height: 50rpx;
  207. background-color: #eae8e7;
  208. text-align: center;
  209. border-radius: 50rpx;
  210. }
  211. }
  212. }
  213. }
  214. }
  215. </style>