evaluate.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <view class="container">
  3. <!-- 页面标题区域 -->
  4. <view class="header" :style="{ height: customBarH * 2 + 'rpx', paddingTop: statusBarH * 2 + 'rpx' }">
  5. <img src="../../static/index/left2.png" :style="{ paddingTop: statusBarH * 2 + 'rpx' }" @click="handleBack" />
  6. <view class="header_text">评价</view>
  7. </view>
  8. <!-- 评分区域 -->
  9. <view class="rate">
  10. <view class="rate_key">民宿评分</view>
  11. <uni-rate v-model="rateValue" size="18" @change="onChange($event, 1)" />
  12. <view class="rate_value">{{ msg }}</view>
  13. </view>
  14. <!-- 评价上传图片视频区域 -->
  15. <view class="operation">
  16. <!-- 输入框区域 -->
  17. <view class="operation_input">
  18. <textarea
  19. maxlength="1000"
  20. class="textarea"
  21. placeholder-style="color:#B3B3B3;font-size:24rpx"
  22. placeholder="写出你的感受,可以帮助其他小伙伴哦~"
  23. v-model="textareaValue"
  24. @input="handleInput"
  25. />
  26. <view class="operation_count">({{ textareaValuelength }}/1000)</view>
  27. </view>
  28. <!-- 上传区域 -->
  29. <view class="operation_uploading">
  30. <view class="uploading_box" @click="handleUpLoad">
  31. <img class="img" src="../../static/index/photo.png" />
  32. <view class="msg">照片/视频</view>
  33. </view>
  34. <view class="uploading_box" v-for="(ele, index) in subImgList" :key="index">
  35. <img class="img2" mode="aspectFill" :src="ele" />
  36. <view class="icon" @click="handleDelete(index)">
  37. <img src="../../static/index/close2.png" />
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 总体评价区域 -->
  43. <view class="foot">
  44. <!-- 民宿位置评价 -->
  45. <view class="foot_box">
  46. <view class="box_key">民宿位置</view>
  47. <uni-rate v-model="rateLocation" size="18" @change="onChange($event, 2)" />
  48. <view class="box_value">{{ msgLocation }}</view>
  49. </view>
  50. <!-- 民宿设施评价 -->
  51. <view class="foot_box">
  52. <view class="box_key">民宿设施</view>
  53. <uni-rate v-model="rateFacility" size="18" @change="onChange($event, 3)" />
  54. <view class="box_value">{{ msgFacility }}</view>
  55. </view>
  56. <!-- 民宿服务评价 -->
  57. <view class="foot_box">
  58. <view class="box_key">民宿服务</view>
  59. <uni-rate v-model="rateServe" size="18" @change="onChange($event, 4)" />
  60. <view class="box_value">{{ msgServe }}</view>
  61. </view>
  62. <!-- 民宿卫生评价 -->
  63. <view class="foot_box">
  64. <view class="box_key">民宿卫生</view>
  65. <uni-rate v-model="rateHygiene" size="18" @change="onChange($event, 5)" />
  66. <view class="box_value">{{ msgHygiene }}</view>
  67. </view>
  68. </view>
  69. <!-- 提交按钮区域 -->
  70. <view class="foot_btn" @click="handleSub">提交</view>
  71. <!-- 用于图片压缩的canvas画布 -->
  72. <canvas
  73. :style="{
  74. width: cw + 'px',
  75. height: cw + 'px',
  76. position: 'absolute',
  77. zIndex: -1,
  78. left: '-10000rpx',
  79. top: '-10000rpx'
  80. }"
  81. canvas-id="zipCanvas"
  82. ></canvas>
  83. <!--画布结束-->
  84. </view>
  85. </template>
  86. <script>
  87. // 图片压缩方法
  88. import getLessLimitSizeImage from '@/util/imageCompress.js'
  89. var dayjs = require('dayjs')
  90. export default {
  91. data() {
  92. return {
  93. // 状态栏高度
  94. statusBarH: 0,
  95. // 胶囊按钮栏高度
  96. customBarH: 0,
  97. // 民宿评分
  98. rateValue: 0,
  99. msg: '',
  100. // 评价绑定数据
  101. textareaValue: '',
  102. // 评价文字长度
  103. textareaValuelength: 0,
  104. // 上传的图片数据
  105. subImgList: [],
  106. // 民宿位置评分
  107. rateLocation: 0,
  108. msgLocation: '',
  109. // 民宿设施评分
  110. rateFacility: 0,
  111. msgFacility: '',
  112. // 民宿服务评分
  113. rateServe: 0,
  114. msgServe: '',
  115. // 民宿卫生评分
  116. rateHygiene: 0,
  117. msgHygiene: '',
  118. // 订单id
  119. bookingId: '',
  120. // 民宿id
  121. hotelId: '',
  122. // 房间id
  123. houseId: ''
  124. }
  125. },
  126. created() {
  127. // 获取系统信息
  128. uni.getSystemInfo({
  129. success: (e) => {
  130. // 获取状态栏高度
  131. this.statusBarH = e.statusBarHeight + 10
  132. // // 获取菜单按钮栏高度
  133. let custom = uni.getMenuButtonBoundingClientRect()
  134. this.customBarH = custom.height + 10
  135. }
  136. })
  137. },
  138. onLoad(options) {
  139. // console.log(options)
  140. this.bookingId = options.bookingId
  141. this.hotelId = options.hotelId
  142. this.houseId = options.houseId
  143. },
  144. methods: {
  145. // 点击页面标题返回箭头回调
  146. handleBack() {
  147. uni.showModal({
  148. content: '确认退出评价吗,已编辑的内容将不保存',
  149. cancelText: '退出评价',
  150. cancelColor: '#808080',
  151. confirmText: '继续写评',
  152. confirmColor: '#000000',
  153. success: (res) => {
  154. if (res.confirm) {
  155. } else if (res.cancel) {
  156. uni.navigateBack(1)
  157. }
  158. }
  159. })
  160. },
  161. // 点击提交按钮回调
  162. handleSub() {
  163. if (!this.rateValue || !this.rateLocation || !this.rateFacility || !this.rateHygiene || !this.rateServe) {
  164. uni.showToast({
  165. title: '请评分后再提交',
  166. icon: 'none',
  167. mask: true
  168. })
  169. return
  170. }
  171. let userInfo = uni.getStorageSync('userInfo')
  172. let time = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  173. uni.request({
  174. url: 'http://192.168.161.224:8088/mhotel/abcaorderRate.action',
  175. method: 'post',
  176. data: {
  177. bookingId: this.bookingId,
  178. hotelId: this.hotelId,
  179. houseId: this.houseId,
  180. content: this.textareaValue,
  181. commentStatus: 1,
  182. score: this.rateValue,
  183. scoreWs: this.rateHygiene,
  184. scoreFw: this.rateServe,
  185. scoreSs: this.rateFacility,
  186. scoreWz: this.rateLocation,
  187. createId: userInfo.id,
  188. createUsername: userInfo.user_name,
  189. createDate: time,
  190. modifyDate: time,
  191. pictureList: this.subImgList
  192. },
  193. success: (res) => {
  194. // console.log(res.data)
  195. if (res.data.code === 200) {
  196. uni.showToast({
  197. title: '评价成功',
  198. icon: 'success',
  199. mask: true
  200. })
  201. setTimeout(() => {
  202. uni.navigateTo({
  203. url: `/pages/evaluateStatus/evaluateStatus?status=1`
  204. })
  205. }, 1500)
  206. } else {
  207. uni.showToast({
  208. title: res.data.message,
  209. icon: 'none',
  210. mask: true
  211. })
  212. setTimeout(() => {
  213. uni.navigateTo({
  214. url: `/pages/evaluateStatus/evaluateStatus?status=2`
  215. })
  216. }, 1500)
  217. }
  218. }
  219. })
  220. },
  221. // 上传图片回调
  222. handleUpLoad() {
  223. uni.chooseMedia({
  224. count: 9,
  225. maxDuration: 15,
  226. success: (res) => {
  227. console.log(res)
  228. console.log(res.tempFiles)
  229. if (this.subImgList.length + res.tempFiles.length > 9) {
  230. uni.showToast({
  231. title: '最多只能上传9个图片/视频',
  232. icon: 'none'
  233. })
  234. return
  235. }
  236. uni.showLoading({
  237. title: '上传中'
  238. })
  239. // reverse()
  240. res.tempFiles.forEach((ele) => {
  241. uni.uploadFile({
  242. url: `https://chtech.ncjti.edu.cn/hotelReservation/mhotel/mhotel/uploadhimage.action`,
  243. filePath: ele.tempFilePath,
  244. name: 'myFile',
  245. success: (uploadFileRes) => {
  246. console.log(JSON.parse(uploadFileRes.data))
  247. let temRes = JSON.parse(uploadFileRes.data)
  248. if (temRes.code === 200) {
  249. this.subImgList.push(temRes.data.url)
  250. console.log(this.subImgList)
  251. uni.hideLoading()
  252. } else {
  253. uni.showToast({
  254. title: temRes.message,
  255. icon: 'none'
  256. })
  257. }
  258. },
  259. fail: () => {
  260. uni.showToast({
  261. title: '上传失败',
  262. icon: 'error'
  263. })
  264. }
  265. })
  266. })
  267. }
  268. })
  269. },
  270. // 评分改变回调
  271. onChange(e, index) {
  272. // console.log(e)
  273. if (index === 1) {
  274. if (e.value === 1) {
  275. this.msg = '非常差'
  276. } else if (e.value === 2) {
  277. this.msg = '差'
  278. } else if (e.value === 3) {
  279. this.msg = '一般'
  280. } else if (e.value === 4) {
  281. this.msg = '好'
  282. } else if (e.value === 5) {
  283. this.msg = '非常好'
  284. }
  285. } else if (index === 2) {
  286. if (e.value === 1) {
  287. this.msgLocation = '非常差'
  288. } else if (e.value === 2) {
  289. this.msgLocation = '差'
  290. } else if (e.value === 3) {
  291. this.msgLocation = '一般'
  292. } else if (e.value === 4) {
  293. this.msgLocation = '好'
  294. } else if (e.value === 5) {
  295. this.msgLocation = '非常好'
  296. }
  297. } else if (index === 3) {
  298. if (e.value === 1) {
  299. this.msgFacility = '非常差'
  300. } else if (e.value === 2) {
  301. this.msgFacility = '差'
  302. } else if (e.value === 3) {
  303. this.msgFacility = '一般'
  304. } else if (e.value === 4) {
  305. this.msgFacility = '好'
  306. } else if (e.value === 5) {
  307. this.msgFacility = '非常好'
  308. }
  309. } else if (index === 4) {
  310. if (e.value === 1) {
  311. this.msgServe = '非常差'
  312. } else if (e.value === 2) {
  313. this.msgServe = '差'
  314. } else if (e.value === 3) {
  315. this.msgServe = '一般'
  316. } else if (e.value === 4) {
  317. this.msgServe = '好'
  318. } else if (e.value === 5) {
  319. this.msgServe = '非常好'
  320. }
  321. } else if (index === 5) {
  322. if (e.value === 1) {
  323. this.msgHygiene = '非常差'
  324. } else if (e.value === 2) {
  325. this.msgHygiene = '差'
  326. } else if (e.value === 3) {
  327. this.msgHygiene = '一般'
  328. } else if (e.value === 4) {
  329. this.msgHygiene = '好'
  330. } else if (e.value === 5) {
  331. this.msgHygiene = '非常好'
  332. }
  333. }
  334. },
  335. // 评价输入框输入回调
  336. handleInput(e) {
  337. this.textareaValuelength = e.detail.cursor
  338. },
  339. // 删除图片回调
  340. handleDelete(index) {
  341. this.subImgList.splice(index, 1)
  342. }
  343. }
  344. }
  345. </script>
  346. <style lang="scss" scoped>
  347. .container {
  348. min-height: 100vh;
  349. background-color: #f2f3f5;
  350. .header {
  351. display: flex;
  352. justify-content: center;
  353. position: relative;
  354. background-color: #fff;
  355. img {
  356. position: absolute;
  357. top: 0;
  358. left: 0;
  359. width: 47rpx;
  360. height: 47rpx;
  361. }
  362. .header_text {
  363. font-size: 34rpx;
  364. }
  365. }
  366. .rate {
  367. display: flex;
  368. align-items: center;
  369. margin: 20rpx 0;
  370. height: 107rpx;
  371. background-color: #fff;
  372. .rate_key {
  373. margin: 0 18rpx;
  374. font-size: 28rpx;
  375. font-weight: bold;
  376. }
  377. .rate_value {
  378. margin-left: 100rpx;
  379. color: #808080;
  380. font-size: 24rpx;
  381. }
  382. }
  383. .operation {
  384. padding: 20rpx 20rpx 33rpx;
  385. margin-bottom: 20rpx;
  386. background-color: #fff;
  387. .operation_input {
  388. box-sizing: border-box;
  389. padding: 20rpx;
  390. width: 710rpx;
  391. height: 282rpx;
  392. border-radius: 9rpx;
  393. background-color: #f2f2f2;
  394. .textarea {
  395. width: 100%;
  396. height: 203rpx;
  397. }
  398. .operation_count {
  399. height: 39rpx;
  400. text-align: end;
  401. color: #b3b3b3;
  402. font-size: 24rpx;
  403. }
  404. }
  405. .operation_uploading {
  406. display: grid;
  407. gap: 21rpx;
  408. grid-template-columns: repeat(auto-fill, 124rpx);
  409. margin-top: 20rpx;
  410. ::v-deep .uni-file-picker__item {
  411. background-color: red;
  412. }
  413. .uploading_box {
  414. position: relative;
  415. display: flex;
  416. flex-direction: column;
  417. justify-content: center;
  418. align-items: center;
  419. width: 124rpx;
  420. height: 124rpx;
  421. border-radius: 7rpx;
  422. background-color: #f2f2f2;
  423. .img {
  424. width: 40rpx;
  425. height: 40rpx;
  426. }
  427. .msg {
  428. margin-top: 5rpx;
  429. color: #a6a6a6;
  430. font-size: 20rpx;
  431. }
  432. .img2 {
  433. width: 124rpx;
  434. height: 124rpx;
  435. border-radius: 7rpx;
  436. }
  437. .icon {
  438. position: absolute;
  439. top: 0;
  440. right: 0;
  441. display: flex;
  442. justify-content: center;
  443. align-items: center;
  444. width: 30rpx;
  445. height: 30rpx;
  446. border-radius: 7rpx;
  447. background-color: rgba(000, 000, 000, 0.5);
  448. img {
  449. width: 30rpx;
  450. height: 30rpx;
  451. }
  452. }
  453. }
  454. }
  455. }
  456. .foot {
  457. display: flex;
  458. flex-direction: column;
  459. justify-content: space-between;
  460. box-sizing: border-box;
  461. padding: 30rpx 20rpx 50rpx;
  462. height: 320rpx;
  463. background-color: #fff;
  464. .foot_box {
  465. display: flex;
  466. align-items: center;
  467. .box_key {
  468. margin-right: 18rpx;
  469. font-size: 28rpx;
  470. font-weight: bold;
  471. }
  472. .box_value {
  473. margin-left: 100rpx;
  474. color: #808080;
  475. font-size: 24rpx;
  476. }
  477. }
  478. }
  479. .foot_btn {
  480. display: flex;
  481. justify-content: center;
  482. align-items: center;
  483. margin: 65rpx auto 78rpx;
  484. width: 710rpx;
  485. height: 96rpx;
  486. color: #fff;
  487. font-size: 32rpx;
  488. border-radius: 64rpx;
  489. background-color: #096562;
  490. }
  491. }
  492. </style>