appraise.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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" v-if="item.liveTime && item.commentTime">
  60. {{ item.liveTime.slice(0, 10) }}入住,{{ item.commentTime.slice(0, 10) }}发表 | {{ item.houseName }}
  61. </view>
  62. <!-- 评价内容区域 -->
  63. <uv-read-more show-height="85rpx" closeText="全文" color="#096663" fontSize="24rpx" textIndent="0" :toggle="true" :shadowStyle="shadowStyle">
  64. <view class="box_content">
  65. {{ item.content }}
  66. </view>
  67. </uv-read-more>
  68. <!-- 图片区域 -->
  69. <view class="box_img">
  70. <img
  71. v-for="(ele, index) in item.url"
  72. :key="index"
  73. mode="aspectFill"
  74. v-if="ele.indexOf('jpg') !== -1 || ele.indexOf('png') !== -1"
  75. :src="ele"
  76. @click.stop="handleClickImg(ele, index)"
  77. />
  78. <video
  79. :id="item.id + index2"
  80. class="video"
  81. :show-fullscreen-btn="false"
  82. :show-play-btn="false"
  83. v-for="(video, index2) in item.url"
  84. :key="index2"
  85. v-if="video.indexOf('mp4') !== -1"
  86. :src="video"
  87. @fullscreenchange="fullscreenchange"
  88. @click.stop="handleClickVideo(item.id + index2)"
  89. ></video>
  90. </view>
  91. <!-- 评论按钮区域 -->
  92. <view class="box_comment">
  93. <img src="../../static/index/comment.png" />
  94. <view>评论({{ item.commentCount }})</view>
  95. </view>
  96. </view>
  97. </view>
  98. <view class="noData" v-if="commentList.length === 0">
  99. <img src="../../static/images/noData.png" />
  100. 暂无评论
  101. </view>
  102. </view>
  103. </template>
  104. <script>
  105. export default {
  106. data() {
  107. return {
  108. // 分段器分类数组
  109. headerList: ['全部', '有图/视频', '商家回复'],
  110. // 当前激活的分段器索引
  111. activeCurrent: 0,
  112. // 评价内容区域阴影样式
  113. shadowStyle: {
  114. backgroundImage: 'none'
  115. },
  116. // 评价列表数据
  117. commentList: [],
  118. // 民宿id
  119. hotelId: '',
  120. // 当前页
  121. page: 1,
  122. // 每页多少条
  123. rows: 6,
  124. // 总条数
  125. total: null,
  126. // 总评分
  127. score: '',
  128. // 服务评分
  129. scoreFw: '',
  130. // 设施评分
  131. scoreSs: '',
  132. // 卫生评分
  133. scoreWs: '',
  134. // 位置评分
  135. scoreWz: '',
  136. // video 上下文 videoContext 对象
  137. videoContext: null,
  138. // 是否是全屏状态
  139. isFullScreen: false
  140. }
  141. },
  142. onLoad(options) {
  143. this.hotelId = options.hotelId
  144. this.getData()
  145. },
  146. onReachBottom() {
  147. if (this.commentList.length < this.total) {
  148. this.page++
  149. this.getData()
  150. } else {
  151. uni.showToast({
  152. title: '没有更多数据了',
  153. icon: 'none'
  154. })
  155. }
  156. },
  157. methods: {
  158. // 进入全屏和退出全屏时触发的回调
  159. fullscreenchange(e) {
  160. this.isFullScreen = e.detail.fullScreen
  161. },
  162. // 点击视频控件时触发的回调
  163. handleClickVideo(id) {
  164. this.videoContext = uni.createVideoContext(id)
  165. if (this.isFullScreen) {
  166. this.videoContext.stop()
  167. this.videoContext.exitFullScreen()
  168. } else {
  169. this.videoContext.requestFullScreen()
  170. this.videoContext.play()
  171. }
  172. },
  173. async getData() {
  174. const res = await this.$myRequest({
  175. url: '/mhotel/abcaevaluatePage.action',
  176. data: {
  177. hotelId: this.hotelId,
  178. page: this.page,
  179. rows: this.rows,
  180. status: this.activeCurrent
  181. }
  182. })
  183. // console.log(res);
  184. if (res.code === 200) {
  185. this.headerList = [`全部(${res.score.totalCount})`, `有图/视频(${res.score.pictureCount})`, `商家回复(${res.score.commentCount})`]
  186. this.score = res.score.score.toFixed(1)
  187. this.scoreFw = res.score.scoreFw.toFixed(1)
  188. this.scoreSs = res.score.scoreSs.toFixed(1)
  189. this.scoreWs = res.score.scoreWs.toFixed(1)
  190. this.scoreWz = res.score.scoreWz.toFixed(1)
  191. this.commentList = [...this.commentList, ...(res.page.pageList || [])]
  192. this.total = res.page.total
  193. }
  194. },
  195. // 点击每一个评价回调
  196. handleGoDetail(item) {
  197. uni.navigateTo({
  198. url: `/pages/appraiseDetail/appraiseDetail?id=${item.id}`
  199. })
  200. },
  201. // 切换分段器时的回调
  202. onClickItem(e) {
  203. this.activeCurrent = e.currentIndex
  204. this.page = 1
  205. this.commentList = []
  206. this.getData()
  207. },
  208. // 点击评价图片回调
  209. handleClickImg(url, index) {
  210. if (this.videoContext) {
  211. this.videoContext.stop()
  212. }
  213. // 预览图片
  214. uni.previewImage({
  215. current: index,
  216. urls: [url]
  217. })
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .container {
  224. display: flex;
  225. flex-direction: column;
  226. min-height: 100vh;
  227. background-color: #f2f3f5;
  228. .header {
  229. height: 150rpx;
  230. background-color: #fff;
  231. .header_box {
  232. display: flex;
  233. margin: 43rpx 0 36rpx;
  234. height: 70rpx;
  235. .box_left {
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. width: 140rpx;
  240. color: #096562;
  241. font-size: 60rpx;
  242. font-weight: 900;
  243. border-right: 1rpx solid #cccccc;
  244. }
  245. .box_right {
  246. flex: 1;
  247. display: flex;
  248. flex-wrap: wrap;
  249. color: #808080;
  250. font-size: 24rpx;
  251. .right_item {
  252. display: flex;
  253. align-items: center;
  254. width: 50%;
  255. .item_info {
  256. margin-left: 33rpx;
  257. }
  258. .item_progress {
  259. margin-right: 20rpx;
  260. padding: 0 13rpx;
  261. flex: 1;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. .segmented {
  268. padding-bottom: 18rpx;
  269. margin-bottom: 20rpx;
  270. background-color: #fff;
  271. }
  272. .body {
  273. .body_box {
  274. box-sizing: border-box;
  275. padding: 0 20rpx;
  276. margin: 0 auto 20rpx;
  277. width: 710rpx;
  278. border-radius: 18rpx;
  279. background-color: #fff;
  280. .box_userInfo {
  281. display: flex;
  282. align-items: center;
  283. height: 115rpx;
  284. img {
  285. width: 70rpx;
  286. height: 70rpx;
  287. border-radius: 50%;
  288. }
  289. .userInfo_msg {
  290. margin-left: 18rpx;
  291. .msg_name {
  292. font-size: 28rpx;
  293. }
  294. .msg_star {
  295. margin-left: -5rpx;
  296. margin-top: 5rpx;
  297. }
  298. }
  299. }
  300. .box_time {
  301. display: flex;
  302. align-items: center;
  303. color: #a6a6a6;
  304. font-size: 24rpx;
  305. }
  306. .box_content {
  307. margin-top: 15rpx;
  308. font-size: 24rpx;
  309. color: #000;
  310. }
  311. .box_img {
  312. display: grid;
  313. grid-template-columns: 1fr 1fr 1fr;
  314. grid-auto-rows: auto;
  315. gap: 10rpx;
  316. margin-top: 20rpx;
  317. img {
  318. width: 216rpx;
  319. height: 216rpx;
  320. border-radius: 20rpx;
  321. }
  322. .video {
  323. width: 216rpx;
  324. height: 216rpx;
  325. border-radius: 20rpx;
  326. }
  327. }
  328. .box_comment {
  329. display: flex;
  330. justify-content: flex-end;
  331. align-items: center;
  332. padding: 20rpx 0 30rpx;
  333. font-size: 24rpx;
  334. img {
  335. margin-right: 12rpx;
  336. width: 25rpx;
  337. height: 22rpx;
  338. }
  339. }
  340. }
  341. }
  342. .noData {
  343. display: flex;
  344. flex-direction: column;
  345. justify-content: center;
  346. align-items: center;
  347. padding-bottom: 20rpx;
  348. img {
  349. margin-top: 60rpx;
  350. width: 600rpx;
  351. height: 600rpx;
  352. }
  353. }
  354. }
  355. </style>