ProductEvaluate.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="ProductDetails">
  3. <!-- 评论 -->
  4. <view class="comment">
  5. <view class="commentTop">
  6. <view class="commentTop_left">
  7. 评价
  8. </view>
  9. </view>
  10. <view class="commentTop">
  11. <view @click="checkCommentbtn(item,index)" :class="iscommentbtn==index?'check_commentbtn':'commentbtn'" v-for="(item,index) in commentbtnList" :key="index">
  12. {{item.name}}
  13. </view>
  14. </view>
  15. <view v-for="(item,index) in plList" :key="index">
  16. <view class="commentTop">
  17. <view class="commentUser">
  18. <view class="Userimg">
  19. <u--image width="60rpx" height="60rpx" src="/static/btn_mine.png" ></u--image>
  20. </view>
  21. <view class="Userimg_r">
  22. <view style="font-size: 28rpx;font-weight: 500;color: #666666;margin-left: 8rpx;">
  23. {{item.author}}
  24. </view>
  25. <view>
  26. <u-rate readonly active-color="#ffcf00" inactive-color="#b2b2b2" :count="5" v-model="item.score"></u-rate>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="commentTop">
  32. <view class="commentcontent">
  33. {{item.content}}
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {productPage,productdetail,productcollection,reviewsPage,addShoppingCart,cancelCollection} from '@/http/api/common.js'
  42. export default {
  43. components:{
  44. },
  45. data() {
  46. return {
  47. TermServiceList:[],
  48. ProductId:'',
  49. rating:'',
  50. plList:[],
  51. commentbtnList:[
  52. {
  53. name:'全部',
  54. key:''
  55. },
  56. {
  57. name:'好评',
  58. key:'3'
  59. },
  60. {
  61. name:'中评',
  62. key:'2'
  63. },
  64. {
  65. name:'差评',
  66. key:'1'
  67. },
  68. ],
  69. iscommentbtn:0,
  70. showtypetopl:null
  71. }
  72. },
  73. async onLoad(e) {
  74. if (e?.id) {
  75. this.ProductId = e?.id
  76. //获取评论列表
  77. await this.getreviewsPage()
  78. }
  79. },
  80. methods: {
  81. async getreviewsPage(){
  82. //获取评论列表
  83. // 1=差评;2=中评;3=好评
  84. let res = await reviewsPage({
  85. rating:this.rating,
  86. productId:this.ProductId
  87. })
  88. if (res.data.code == 200) {
  89. this.plList = res.data.data.rows
  90. //默认选中全部类型
  91. // this.checkCommentbtn(this.commentbtnList[0],0)
  92. }
  93. },
  94. checkCommentbtn(item,index){
  95. this.iscommentbtn = index
  96. this.rating = item.key
  97. this.getreviewsPage()
  98. },
  99. }
  100. }
  101. </script>
  102. <style>
  103. .ProductDetails{
  104. width: 750rpx;
  105. min-height: 100vh;
  106. background: #F1F1F1;
  107. display: flex;
  108. flex-direction: column;
  109. align-items: center;
  110. }
  111. .comment{
  112. width: 702rpx;
  113. /* height: 434rpx; */
  114. background: #FFFFFF;
  115. border-radius: 16rpx 16rpx 16rpx 16rpx;
  116. display: flex;
  117. flex-direction: column;
  118. align-items: center;
  119. margin-top: 24rpx;
  120. }
  121. .commentTop{
  122. width: 640rpx;
  123. min-height: 45rpx;
  124. margin-top: 24rpx;
  125. display: flex;
  126. justify-content: space-between;
  127. }
  128. .commentTop_left{
  129. width: 220rpx;
  130. height: 45rpx;
  131. font-size: 32rpx;
  132. font-weight: bold;
  133. color: #333333;
  134. line-height: 36rpx;
  135. display: flex;
  136. justify-content: space-between;
  137. }
  138. .commentTop_left_num{
  139. width: 124rpx;
  140. height: 37rpx;
  141. font-size: 28rpx;
  142. font-weight: 500;
  143. color: #999999;
  144. line-height: 36rpx;
  145. }
  146. .commentTop_right{
  147. display: flex;
  148. width: 160rpx;
  149. height: 40rpx;
  150. font-size: 28rpx;
  151. font-weight: 500;
  152. color: #999999;
  153. line-height: 36rpx;
  154. }
  155. .commentbtn{
  156. width: 151rpx;
  157. height: 64rpx;
  158. background: #DDDDDD;
  159. border-radius: 60rpx 60rpx 60rpx 60rpx;
  160. opacity: 1;
  161. font-size: 28rpx;
  162. font-weight: 500;
  163. color: #666666;
  164. line-height: 64rpx;
  165. text-align: center;
  166. }
  167. .check_commentbtn{
  168. width: 151rpx;
  169. height: 64rpx;
  170. background: #46A6FF;
  171. border-radius: 60rpx 60rpx 60rpx 60rpx;
  172. opacity: 1;
  173. font-size: 28rpx;
  174. font-weight: 500;
  175. color: #FFF;
  176. line-height: 64rpx;
  177. text-align: center;
  178. }
  179. .commentcontent{
  180. width: 644rpx;
  181. height: 80rpx;
  182. font-size: 28rpx;
  183. font-weight: 500;
  184. color: #333333;
  185. line-height: 40rpx;
  186. display: -webkit-box;
  187. word-break: break-all;
  188. text-overflow: ellipsis;
  189. overflow: hidden;
  190. -webkit-box-orient: vertical;
  191. -webkit-line-clamp:2;
  192. }
  193. .Userimg{
  194. width: 80rpx;
  195. height: 80rpx;
  196. background: #EEEEEE;
  197. border-radius: 50%;
  198. display: flex;
  199. align-items: center;
  200. justify-content: center;
  201. }
  202. .commentUser{
  203. display: flex;
  204. }
  205. .Userimg_r{
  206. margin-left: 24rpx;
  207. }
  208. </style>