evaluate.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="evaluate">
  3. <view class="title">全部</view>
  4. <view class="eva_con" v-for="item in evaList" :key="item.id">
  5. <image :src="item.user.avatar" v-if="item.user" style="flex-shrink: 0;"></image>
  6. <view class="eva_detail">
  7. <view class="flexB">
  8. <view>
  9. <view style="font-size:32rpx;font-weight: bold;" v-if="item.user">{{ item.user.nickname }}</view>
  10. <text style="font-size:28rpx;">{{ item.created_at }}</text>
  11. </view>
  12. <view class="copy_btn flexC" @click="replay(item.id, item.user.nickname)">回复</view>
  13. </view>
  14. <view style="word-wrap: break-word">{{ item.content }}</view>
  15. <view class="reply">
  16. <view v-for="temp in item.comment" :key="temp.id">
  17. <view class="reply_photo flexS">
  18. <image :src="item.store.img"></image>
  19. <text>{{ item.store.name }}</text>
  20. </view>
  21. <view class="reply_con">
  22. <text>回复</text>
  23. <text style="color:#B5B5B5;margin:0 10rpx;" v-if="item.user">{{ item.user.nickname }}</text>
  24. <text>:{{ temp.content }}</text>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="noData" v-if="evaList.length == 0">
  31. <image src="../../static/imgs/default/no_comment.png"></image>
  32. <view>暂无评价</view>
  33. </view>
  34. <view class="eval flexC" v-if="isReplay">
  35. <input type="text" :placeholder="'@' + name" v-model="content" />
  36. <view class="flexC base_btn" @click="send">回复</view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { getComment, replyCommet } from '@/apis/shop.js';
  42. export default {
  43. data() {
  44. return {
  45. isReplay: false, //是否显示回复输入框
  46. evaList: [], //评论列表
  47. params: {
  48. page_index: 1,
  49. page_size: 15
  50. },
  51. id: '', //回复当前评论的id
  52. name: '', //回复的对象
  53. content: '', //回复内容
  54. total: '' //总条数
  55. };
  56. },
  57. onLoad() {
  58. this.getList();
  59. },
  60. methods: {
  61. /*获取评论列表*/
  62. getList() {
  63. let { page_index, page_size } = this.params;
  64. getComment({ page_index, page_size }).then(res => {
  65. this.total = Math.ceil(this.page_size / res.data.total);
  66. this.evaList = res.data.list;
  67. });
  68. },
  69. /*点击回复按钮
  70. *@ name 回复的对象
  71. *@ id 回复的评论的id
  72. */
  73. replay(id, name) {
  74. this.id = id;
  75. this.isReplay = true;
  76. this.name = name;
  77. },
  78. /*回复评论
  79. *@params content 回复内容
  80. *@params comment_id 此条评论的id
  81. */
  82. send() {
  83. if (!this.content) {
  84. uni.showModal({
  85. content: '请输入回复内容',
  86. showCancel: false
  87. });
  88. return false;
  89. }
  90. replyCommet({ content: this.content, comment_id: this.id }).then(res => {
  91. if (res.code == 200) {
  92. this.isReplay = false;
  93. this.content = '';
  94. this.getList();
  95. uni.showToast({
  96. title: '回复成功',
  97. duration: 3000
  98. });
  99. } else {
  100. uni.showModal({
  101. content: res.data,
  102. showCancel: false
  103. });
  104. }
  105. });
  106. }
  107. }
  108. };
  109. </script>
  110. <style lang="scss">
  111. .evaluate {
  112. width: 100%;
  113. padding: 30rpx;
  114. box-sizing: border-box;
  115. // margin: 0 auto;
  116. min-height: 100%;
  117. background: #fff;
  118. position: relative;
  119. padding-bottom: 120rpx;
  120. .title {
  121. font-size: 32rpx;
  122. font-weight: bold;
  123. margin-top: 20rpx;
  124. &::after {
  125. content: '';
  126. display: block;
  127. width: 32rpx;
  128. height: 6rpx;
  129. background: linear-gradient(180deg, #fc9863 0%, #f76454 100%);
  130. border-radius: 6rpx;
  131. margin: 3rpx 0 0 15rpx;
  132. }
  133. }
  134. .eva_con {
  135. width: 100%;
  136. display: flex;
  137. justify-content: space-between;
  138. margin-top: 30rpx;
  139. box-sizing: border-box;
  140. image {
  141. width: 68rpx;
  142. height: 68rpx;
  143. border-radius: 50%;
  144. margin-right: 10rpx;
  145. }
  146. .eva_detail {
  147. width: 90%;
  148. border-bottom: 2rpx solid #f5f5f5;
  149. padding-bottom: 30rpx;
  150. > view {
  151. view {
  152. font-size: 28rpx;
  153. margin-bottom: 15rpx;
  154. }
  155. text {
  156. font-size: 24rpx;
  157. color: #999;
  158. }
  159. // .reply_btn {
  160. // width: 116rpx;
  161. // height: 54rpx;
  162. // background: linear-gradient(92deg, #fc9863 0%, #f76454 100%);
  163. // border-radius: 28rpx;
  164. // color: #fff;
  165. // font-size: 28rpx;
  166. // }
  167. }
  168. .reply_count {
  169. margin-top: 20rpx;
  170. color: $base-color;
  171. font-size: 24rpx;
  172. }
  173. .reply {
  174. margin-top: 40rpx;
  175. .reply_photo {
  176. image {
  177. height: 50rpx;
  178. width: 50rpx;
  179. margin-right: 20rpx;
  180. }
  181. text {
  182. font-size: 28rpx;
  183. color: #ea4a41;
  184. }
  185. }
  186. .reply_con {
  187. margin-top: 15rpx;
  188. text {
  189. font-size: 28rpx;
  190. color: #333;
  191. }
  192. }
  193. }
  194. }
  195. }
  196. .eval {
  197. width: 100%;
  198. height: 98rpx;
  199. position: fixed;
  200. left: 0;
  201. bottom: 0;
  202. z-index: 9999;
  203. background-color: #fff;
  204. input {
  205. width: 418rpx;
  206. height: 68rpx;
  207. background: #f8f8f8;
  208. border-radius: 34rpx;
  209. padding-left: 20rpx;
  210. color: #333;
  211. }
  212. }
  213. }
  214. </style>