appraise.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="container" v-if="total !== null">
  3. <!-- 顶部评分区域 -->
  4. <view class="header">
  5. <view class="header_box">
  6. <!-- 总评分区域 -->
  7. <view class="box_left">{{ score }}</view>
  8. <view class="box_right">
  9. <!-- 位置评分区域 -->
  10. <view class="right_item">
  11. <view class="item_info">位置 {{ scoreWz }}</view>
  12. <view class="item_progress">
  13. <progress activeColor="#0BAD8B" backgroundColor="#CCCCCC" stroke-width="10" border-radius="92" :percent="((scoreWz * 1) / 5) * 100" />
  14. </view>
  15. </view>
  16. <!-- 设施评分区域 -->
  17. <view class="right_item">
  18. <view class="item_info">设施 {{ scoreSs }}</view>
  19. <view class="item_progress">
  20. <progress activeColor="#0BAD8B" backgroundColor="#CCCCCC" stroke-width="10" border-radius="92" :percent="((scoreSs * 1) / 5) * 100" />
  21. </view>
  22. </view>
  23. <!-- 服务评分区域 -->
  24. <view class="right_item">
  25. <view class="item_info">服务 {{ scoreFw }}</view>
  26. <view class="item_progress">
  27. <progress activeColor="#0BAD8B" backgroundColor="#CCCCCC" stroke-width="10" border-radius="92" :percent="((scoreFw * 1) / 5) * 100" />
  28. </view>
  29. </view>
  30. <!-- 卫生评分区域 -->
  31. <view class="right_item">
  32. <view class="item_info">卫生 {{ scoreWs }}</view>
  33. <view class="item_progress">
  34. <progress activeColor="#0BAD8B" backgroundColor="#CCCCCC" stroke-width="10" border-radius="92" :percent="((scoreWs * 1) / 5) * 100" />
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 分段器区域 -->
  41. <view class="segmented">
  42. <uni-segmented-control styleType="text" activeColor="#096562" :current="activeCurrent" :values="headerList" @clickItem="onClickItem" />
  43. </view>
  44. <!-- 评价列表 -->
  45. <view class="body">
  46. <!-- 每一个评价区域 -->
  47. <view class="body_box" v-for="item in commentList" :key="item.id" @click="handleGoDetail(item)">
  48. <!-- 用户信息区域 -->
  49. <view class="box_userInfo">
  50. <img mode="aspectFill" :src="item.headPhoto" />
  51. <view class="userInfo_msg">
  52. <view class="msg_name">{{ item.userName }}</view>
  53. <view class="msg_star">
  54. <uni-rate readonly activeColor="#FFC300" :size="16" :value="item.score" />
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 入住时间区域 -->
  59. <view class="box_time">{{ item.liveTime.slice(0, 10) }}入住,{{ item.commentTime.slice(0, 10) }}发表 | {{ item.houseName }}</view>
  60. <!-- 评价内容区域 -->
  61. <uv-read-more show-height="85rpx" closeText="全文" color="#096663" fontSize="24rpx" textIndent="0" :toggle="true" :shadowStyle="shadowStyle">
  62. <view class="box_content">
  63. {{ item.content }}
  64. </view>
  65. </uv-read-more>
  66. <!-- 图片区域 -->
  67. <view class="box_img">
  68. <img v-for="(ele, index) in item.url" :key="index" mode="aspectFill" :src="ele" @click.stop="handleClickImg(item.url, index)" />
  69. </view>
  70. <!-- 评论按钮区域 -->
  71. <view class="box_comment">
  72. <img src="../../static/index/comment.png" />
  73. <view>评论({{ item.commentCount }})</view>
  74. </view>
  75. </view>
  76. </view>
  77. <view class="noData" v-if="commentList.length === 0">
  78. <img src="../../static/images/noData.png" />
  79. 暂无评论
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. // 分段器分类数组
  88. headerList: ['全部', '有图/视频', '商家回复'],
  89. // 当前激活的分段器索引
  90. activeCurrent: 0,
  91. // 评价内容区域阴影样式
  92. shadowStyle: {
  93. backgroundImage: 'none'
  94. },
  95. // 评价列表数据
  96. commentList: [],
  97. // 民宿id
  98. hotelId: '',
  99. // 当前页
  100. page: 1,
  101. // 每页多少条
  102. rows: 6,
  103. // 总条数
  104. total: null,
  105. // 总评分
  106. score: '',
  107. // 服务评分
  108. scoreFw: '',
  109. // 设施评分
  110. scoreSs: '',
  111. // 卫生评分
  112. scoreWs: '',
  113. // 位置评分
  114. scoreWz: ''
  115. }
  116. },
  117. onLoad(options) {
  118. this.hotelId = options.hotelId
  119. this.getData()
  120. },
  121. onReachBottom() {
  122. if (this.commentList.length < this.total) {
  123. this.page++
  124. this.getData()
  125. } else {
  126. uni.showToast({
  127. title: '没有更多数据了',
  128. icon: 'none'
  129. })
  130. }
  131. },
  132. methods: {
  133. async getData() {
  134. const res = await this.$myRequest({
  135. url: '/mhotel/abcaevaluatePage.action',
  136. data: {
  137. hotelId: this.hotelId,
  138. page: this.page,
  139. rows: this.rows,
  140. status: this.activeCurrent
  141. }
  142. })
  143. // console.log(res);
  144. if (res.code === 200) {
  145. this.headerList = [`全部(${res.score.totalCount})`, `有图/视频(${res.score.pictureCount})`, `商家回复(${res.score.commentCount})`]
  146. this.score = res.score.score.toFixed(1)
  147. this.scoreFw = res.score.scoreFw.toFixed(1)
  148. this.scoreSs = res.score.scoreSs.toFixed(1)
  149. this.scoreWs = res.score.scoreWs.toFixed(1)
  150. this.scoreWz = res.score.scoreWz.toFixed(1)
  151. this.commentList = res.page.pageList || []
  152. this.total = res.page.total
  153. }
  154. },
  155. // 点击每一个评价回调
  156. handleGoDetail(item) {
  157. uni.navigateTo({
  158. url: `/pages/appraiseDetail/appraiseDetail?id=${item.id}`
  159. })
  160. },
  161. // 切换分段器时的回调
  162. onClickItem(e) {
  163. this.activeCurrent = e.currentIndex
  164. this.page = 1
  165. this.commentList = []
  166. this.getData()
  167. },
  168. // 点击评价图片回调
  169. handleClickImg(url, index) {
  170. // 预览图片
  171. uni.previewImage({
  172. current: index,
  173. urls: url
  174. })
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .container {
  181. display: flex;
  182. flex-direction: column;
  183. min-height: 100vh;
  184. background-color: #f2f3f5;
  185. .header {
  186. height: 150rpx;
  187. background-color: #fff;
  188. .header_box {
  189. display: flex;
  190. margin: 43rpx 0 36rpx;
  191. height: 70rpx;
  192. .box_left {
  193. display: flex;
  194. justify-content: center;
  195. align-items: center;
  196. width: 140rpx;
  197. color: #096562;
  198. font-size: 60rpx;
  199. font-weight: 900;
  200. border-right: 1rpx solid #cccccc;
  201. }
  202. .box_right {
  203. flex: 1;
  204. display: flex;
  205. flex-wrap: wrap;
  206. color: #808080;
  207. font-size: 24rpx;
  208. .right_item {
  209. display: flex;
  210. align-items: center;
  211. width: 50%;
  212. .item_info {
  213. margin-left: 33rpx;
  214. }
  215. .item_progress {
  216. margin-right: 20rpx;
  217. padding: 0 13rpx;
  218. flex: 1;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. .segmented {
  225. padding-bottom: 18rpx;
  226. margin-bottom: 20rpx;
  227. background-color: #fff;
  228. }
  229. .body {
  230. .body_box {
  231. box-sizing: border-box;
  232. padding: 0 20rpx;
  233. margin: 0 auto 20rpx;
  234. width: 710rpx;
  235. border-radius: 18rpx;
  236. background-color: #fff;
  237. .box_userInfo {
  238. display: flex;
  239. align-items: center;
  240. height: 115rpx;
  241. img {
  242. width: 70rpx;
  243. height: 70rpx;
  244. border-radius: 50%;
  245. }
  246. .userInfo_msg {
  247. margin-left: 18rpx;
  248. .msg_name {
  249. font-size: 28rpx;
  250. }
  251. .msg_star {
  252. margin-left: -5rpx;
  253. margin-top: 5rpx;
  254. }
  255. }
  256. }
  257. .box_time {
  258. display: flex;
  259. align-items: center;
  260. color: #a6a6a6;
  261. font-size: 24rpx;
  262. }
  263. .box_content {
  264. margin-top: 15rpx;
  265. font-size: 24rpx;
  266. color: #000;
  267. }
  268. .box_img {
  269. display: grid;
  270. grid-template-columns: 1fr 1fr 1fr;
  271. grid-auto-rows: auto;
  272. gap: 10rpx;
  273. margin-top: 20rpx;
  274. img {
  275. width: 216rpx;
  276. height: 216rpx;
  277. border-radius: 20rpx;
  278. }
  279. }
  280. .box_comment {
  281. display: flex;
  282. justify-content: flex-end;
  283. align-items: center;
  284. padding: 20rpx 0 30rpx;
  285. font-size: 24rpx;
  286. img {
  287. margin-right: 12rpx;
  288. width: 25rpx;
  289. height: 22rpx;
  290. }
  291. }
  292. }
  293. }
  294. .noData {
  295. display: flex;
  296. flex-direction: column;
  297. justify-content: center;
  298. align-items: center;
  299. padding-bottom: 20rpx;
  300. img {
  301. margin-top: 60rpx;
  302. width: 600rpx;
  303. height: 600rpx;
  304. }
  305. }
  306. }
  307. </style>