evaluate.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  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. async 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. const res = await this.$myRequest({
  174. url: '/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. })
  194. // console.log(res)
  195. if (res.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.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. handleUpLoad() {
  221. uni.chooseMedia({
  222. count: 9,
  223. maxDuration: 15,
  224. success: (res) => {
  225. console.log(res)
  226. console.log(res.tempFiles)
  227. if (this.subImgList.length + res.tempFiles.length > 9) {
  228. uni.showToast({
  229. title: '最多只能上传9个图片/视频',
  230. icon: 'none'
  231. })
  232. return
  233. }
  234. uni.showLoading({
  235. title: '上传中'
  236. })
  237. // reverse()
  238. res.tempFiles.forEach((ele) => {
  239. uni.uploadFile({
  240. url: `https://chtech.ncjti.edu.cn/hotelReservation/mhotel/mhotel/uploadhimage.action`,
  241. filePath: ele.tempFilePath,
  242. name: 'myFile',
  243. success: (uploadFileRes) => {
  244. console.log(JSON.parse(uploadFileRes.data))
  245. let temRes = JSON.parse(uploadFileRes.data)
  246. if (temRes.code === 200) {
  247. this.subImgList.push(temRes.data.url)
  248. console.log(this.subImgList)
  249. uni.hideLoading()
  250. } else {
  251. uni.showToast({
  252. title: temRes.message,
  253. icon: 'none'
  254. })
  255. }
  256. },
  257. fail: () => {
  258. uni.showToast({
  259. title: '上传失败',
  260. icon: 'error'
  261. })
  262. }
  263. })
  264. })
  265. }
  266. })
  267. },
  268. // 评分改变回调
  269. onChange(e, index) {
  270. // console.log(e)
  271. if (index === 1) {
  272. if (e.value === 1) {
  273. this.msg = '非常差'
  274. } else if (e.value === 2) {
  275. this.msg = '差'
  276. } else if (e.value === 3) {
  277. this.msg = '一般'
  278. } else if (e.value === 4) {
  279. this.msg = '好'
  280. } else if (e.value === 5) {
  281. this.msg = '非常好'
  282. }
  283. } else if (index === 2) {
  284. if (e.value === 1) {
  285. this.msgLocation = '非常差'
  286. } else if (e.value === 2) {
  287. this.msgLocation = '差'
  288. } else if (e.value === 3) {
  289. this.msgLocation = '一般'
  290. } else if (e.value === 4) {
  291. this.msgLocation = '好'
  292. } else if (e.value === 5) {
  293. this.msgLocation = '非常好'
  294. }
  295. } else if (index === 3) {
  296. if (e.value === 1) {
  297. this.msgFacility = '非常差'
  298. } else if (e.value === 2) {
  299. this.msgFacility = '差'
  300. } else if (e.value === 3) {
  301. this.msgFacility = '一般'
  302. } else if (e.value === 4) {
  303. this.msgFacility = '好'
  304. } else if (e.value === 5) {
  305. this.msgFacility = '非常好'
  306. }
  307. } else if (index === 4) {
  308. if (e.value === 1) {
  309. this.msgServe = '非常差'
  310. } else if (e.value === 2) {
  311. this.msgServe = '差'
  312. } else if (e.value === 3) {
  313. this.msgServe = '一般'
  314. } else if (e.value === 4) {
  315. this.msgServe = '好'
  316. } else if (e.value === 5) {
  317. this.msgServe = '非常好'
  318. }
  319. } else if (index === 5) {
  320. if (e.value === 1) {
  321. this.msgHygiene = '非常差'
  322. } else if (e.value === 2) {
  323. this.msgHygiene = '差'
  324. } else if (e.value === 3) {
  325. this.msgHygiene = '一般'
  326. } else if (e.value === 4) {
  327. this.msgHygiene = '好'
  328. } else if (e.value === 5) {
  329. this.msgHygiene = '非常好'
  330. }
  331. }
  332. },
  333. // 评价输入框输入回调
  334. handleInput(e) {
  335. this.textareaValuelength = e.detail.cursor
  336. },
  337. // 删除图片回调
  338. handleDelete(index) {
  339. this.subImgList.splice(index, 1)
  340. }
  341. }
  342. }
  343. </script>
  344. <style lang="scss" scoped>
  345. .container {
  346. min-height: 100vh;
  347. background-color: #f2f3f5;
  348. .header {
  349. display: flex;
  350. justify-content: center;
  351. position: relative;
  352. background-color: #fff;
  353. img {
  354. position: absolute;
  355. top: 0;
  356. left: 0;
  357. width: 47rpx;
  358. height: 47rpx;
  359. }
  360. .header_text {
  361. font-size: 34rpx;
  362. }
  363. }
  364. .rate {
  365. display: flex;
  366. align-items: center;
  367. margin: 20rpx 0;
  368. height: 107rpx;
  369. background-color: #fff;
  370. .rate_key {
  371. margin: 0 18rpx;
  372. font-size: 28rpx;
  373. font-weight: bold;
  374. }
  375. .rate_value {
  376. margin-left: 100rpx;
  377. color: #808080;
  378. font-size: 24rpx;
  379. }
  380. }
  381. .operation {
  382. padding: 20rpx 20rpx 33rpx;
  383. margin-bottom: 20rpx;
  384. background-color: #fff;
  385. .operation_input {
  386. box-sizing: border-box;
  387. padding: 20rpx;
  388. width: 710rpx;
  389. height: 282rpx;
  390. border-radius: 9rpx;
  391. background-color: #f2f2f2;
  392. .textarea {
  393. width: 100%;
  394. height: 203rpx;
  395. }
  396. .operation_count {
  397. height: 39rpx;
  398. text-align: end;
  399. color: #b3b3b3;
  400. font-size: 24rpx;
  401. }
  402. }
  403. .operation_uploading {
  404. display: grid;
  405. gap: 21rpx;
  406. grid-template-columns: repeat(auto-fill, 124rpx);
  407. margin-top: 20rpx;
  408. ::v-deep .uni-file-picker__item {
  409. background-color: red;
  410. }
  411. .uploading_box {
  412. position: relative;
  413. display: flex;
  414. flex-direction: column;
  415. justify-content: center;
  416. align-items: center;
  417. width: 124rpx;
  418. height: 124rpx;
  419. border-radius: 7rpx;
  420. background-color: #f2f2f2;
  421. .img {
  422. width: 40rpx;
  423. height: 40rpx;
  424. }
  425. .msg {
  426. margin-top: 5rpx;
  427. color: #a6a6a6;
  428. font-size: 20rpx;
  429. }
  430. .img2 {
  431. width: 124rpx;
  432. height: 124rpx;
  433. border-radius: 7rpx;
  434. }
  435. .icon {
  436. position: absolute;
  437. top: 0;
  438. right: 0;
  439. display: flex;
  440. justify-content: center;
  441. align-items: center;
  442. width: 30rpx;
  443. height: 30rpx;
  444. border-radius: 7rpx;
  445. background-color: rgba(000, 000, 000, 0.5);
  446. img {
  447. width: 30rpx;
  448. height: 30rpx;
  449. }
  450. }
  451. }
  452. }
  453. }
  454. .foot {
  455. display: flex;
  456. flex-direction: column;
  457. justify-content: space-between;
  458. box-sizing: border-box;
  459. padding: 30rpx 20rpx 50rpx;
  460. height: 320rpx;
  461. background-color: #fff;
  462. .foot_box {
  463. display: flex;
  464. align-items: center;
  465. .box_key {
  466. margin-right: 18rpx;
  467. font-size: 28rpx;
  468. font-weight: bold;
  469. }
  470. .box_value {
  471. margin-left: 100rpx;
  472. color: #808080;
  473. font-size: 24rpx;
  474. }
  475. }
  476. }
  477. .foot_btn {
  478. display: flex;
  479. justify-content: center;
  480. align-items: center;
  481. margin: 65rpx auto 78rpx;
  482. width: 710rpx;
  483. height: 96rpx;
  484. color: #fff;
  485. font-size: 32rpx;
  486. border-radius: 64rpx;
  487. background-color: #096562;
  488. }
  489. }
  490. </style>