uni-evaluate.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!-- components/evaluate-components/index.wxml -->
  2. <template>
  3. <view class="evaluateBox">
  4. <view class="evaluate-header">
  5. <view class="title">
  6. <text v-if="isShowIcon" class="iconfont" style="color:#999">&#xe640;</text>
  7. <text v-if="isShowTotal" style="margin-left: 10upx;">评价 ({{ listData.length }})</text>
  8. </view>
  9. <view class="total">
  10. <view class="stars">
  11. <view class="stars-normal">
  12. <view class="box">
  13. <block v-for="i in 5" :key="i"><text class="iconfont">&#xe870;</text></block>
  14. </view>
  15. </view>
  16. <view class="stars-selected" :style="{ width: (rate / 5) * 100 + '%' }">
  17. <view class="box">
  18. <block v-for="j in 5" :key="j"><text class="iconfont">&#xe870;</text></block>
  19. </view>
  20. </view>
  21. </view>
  22. <text>{{ rate }}{{ (rate * 10) % 10 == 0 ? '.0' : '' }}</text>
  23. </view>
  24. </view>
  25. <view class="lists" v-if="listData.length > 0">
  26. <block v-for="(item, index_) in listData" :key="index_">
  27. <view class="item">
  28. <view class="icon"><image :src="item.header_img" mode="widthFix" style="width:100%" /></view>
  29. <view class="info">
  30. <view class="name-time">
  31. <text class="name">{{ item.user_name }}</text>
  32. <text class="time">{{ item.create_time }}</text>
  33. </view>
  34. <view class="stars">
  35. <view class="stars-normal">
  36. <view class="box">
  37. <block v-for="i_ in 5" :key="i_"><text class="iconfont">&#xe870;</text></block>
  38. </view>
  39. </view>
  40. <view class="stars-selected" :style="{ width: (item.rate / 5) * 100 + '%' }">
  41. <view class="box">
  42. <block v-for="j_ in 5" :key="j_"><text class="iconfont">&#xe870;</text></block>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="evaluate-content">
  47. <text>{{ item.content || '用户暂未评价' }}</text>
  48. <view class="imgs" v-if="item.imgs">
  49. <block v-for="(imgurl, index) in item.imgs" :key="index">
  50. <view class="imgs-box"><image :src="imgurl" mode="widthFix" style="width: 100%;" @click="previewImg(imgurl,item.imgs)"></image></view>
  51. </block>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </block>
  57. </view>
  58. <view class="no-lists" v-else>暂无评论</view>
  59. </view>
  60. </template>
  61. <script>
  62. //数据模拟
  63. import data from './list.js';
  64. export default {
  65. props: {
  66. //评价列表数据
  67. listData: {
  68. type: Array,
  69. default: data
  70. },
  71. //是否显示总评价数量
  72. isShowTotal: {
  73. type: Boolean,
  74. default: true
  75. },
  76. //是否显示评价前面的图标
  77. isShowIcon: {
  78. type: Boolean,
  79. default: true
  80. },
  81. //总评分
  82. rate: {
  83. type: Number,
  84. default: 4.6
  85. }
  86. },
  87. data() {
  88. return {}
  89. },
  90. methods: {
  91. previewImg(src,urls){
  92. uni.previewImage({
  93. current:src,
  94. urls
  95. })
  96. }
  97. }
  98. };
  99. </script>
  100. <style scoped>
  101. @import './iconfont.css';
  102. .evaluateBox {
  103. width: 100%;
  104. margin-bottom: 120upx;
  105. }
  106. .evaluate-header {
  107. width: 100%;
  108. height: 80upx;
  109. display: flex;
  110. justify-content: space-between;
  111. padding: 20upx;
  112. align-items: center;
  113. margin-bottom: 12upx;
  114. box-sizing: border-box;
  115. border-bottom: 1upx solid #e5e5e5;
  116. }
  117. .evaluateBox .title {
  118. display: flex;
  119. align-items: center;
  120. color: #000000;
  121. font-size: 30upx;
  122. }
  123. .total {
  124. /* flex: 1; */
  125. height: 100%;
  126. font-size: 30upx;
  127. color: #d76d9d;
  128. display: flex;
  129. align-items: center;
  130. justify-content: flex-end;
  131. }
  132. .stars {
  133. width: 180upx;
  134. height: 36upx;
  135. position: relative;
  136. }
  137. .stars .box {
  138. width: 180upx;
  139. }
  140. .stars-normal {
  141. width: 100%;
  142. position: absolute;
  143. left: 0;
  144. top: 0;
  145. color: #ccc;
  146. }
  147. .stars-selected {
  148. position: absolute;
  149. left: 0;
  150. top: 0;
  151. z-index: 1;
  152. color: #fde16d;
  153. overflow: hidden;
  154. }
  155. .stars-selected .iconfont,
  156. .stars-normal .iconfont {
  157. font-size: 36upx;
  158. }
  159. .lists .item {
  160. padding: 20upx;
  161. display: flex;
  162. /* height: auto; */
  163. /* align-items: center; */
  164. font-size: 22upx;
  165. color: #999;
  166. }
  167. .lists .item .icon {
  168. width: 60upx;
  169. height: 60upx;
  170. border-radius: 50%;
  171. overflow: hidden;
  172. margin-right: 26upx;
  173. /* align-self: flex-start; */
  174. }
  175. .lists .item .info {
  176. flex: 1;
  177. font-size: 26upx;
  178. color: #666;
  179. }
  180. .info .name-time {
  181. display: flex;
  182. align-items: center;
  183. justify-content: space-between;
  184. padding-bottom: 6upx;
  185. }
  186. .lists .info .stars {
  187. width: 140upx;
  188. }
  189. .info .stars-normal .iconfont,
  190. .info .stars-selected .iconfont {
  191. font-size: 28upx;
  192. }
  193. .info .stars .box {
  194. width: 140upx;
  195. }
  196. .lists .info .evaluate-content {
  197. color: #000;
  198. font-size: 28upx;
  199. text-align: left;
  200. padding-top: 6upx;
  201. }
  202. .info .evaluate-content .imgs {
  203. display: flex;
  204. flex-wrap: wrap;
  205. padding-top: 6upx;
  206. }
  207. .evaluate-content .imgs .imgs-box {
  208. width: 25%;
  209. padding-right: 10upx;
  210. box-sizing: border-box;
  211. }
  212. /* .evaluate-content .imgs .imgs-box:nth-child(4n+1){
  213. padding-left: 0;
  214. }
  215. .evaluate-content .imgs .imgs-box:nth-child(4n){
  216. padding-right: 0;
  217. } */
  218. .no-lists {
  219. padding: 20upx 0;
  220. text-align: center;
  221. font-size: 24upx;
  222. color: #666;
  223. }
  224. </style>