appraise.vue 8.8 KB

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