complaint.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <view class="container">
  3. <!-- 标题区域 -->
  4. <view class="title">
  5. <view class="title_key">标题</view>
  6. <view class="title_value">
  7. <input maxlength="10" type="text" placeholder="请输入标题,不要超过10个字哦~" placeholder-style="color:#B3B3B3;fontSize:28rpx;" v-model="inputValue" />
  8. </view>
  9. </view>
  10. <!-- 评价上传图片视频区域 -->
  11. <view class="operation">
  12. <!-- 输入框区域 -->
  13. <view class="operation_input">
  14. <textarea
  15. maxlength="1000"
  16. class="textarea"
  17. placeholder-style="color:#B3B3B3;font-size:24rpx"
  18. placeholder="写出你的相关问题"
  19. v-model="textareaValue"
  20. @input="handleInput"
  21. />
  22. <view class="operation_count">({{ textareaValuelength }}/1000)</view>
  23. </view>
  24. <!-- 上传区域 -->
  25. <view class="operation_uploading">
  26. <view class="uploading_box" @click="handleUpLoad">
  27. <img class="img" src="../../static/index/photo.png" />
  28. <view class="msg">照片/视频</view>
  29. </view>
  30. <view class="uploading_box" v-for="(ele, index) in subImgList" :key="index">
  31. <img class="img2" mode="aspectFill" :src="ele" />
  32. <view class="icon" @click="handleDelete(index)">
  33. <img src="../../static/index/close2.png" />
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 提交按钮区域 -->
  39. <view class="btn" @click="handleSub">提交</view>
  40. </view>
  41. </template>
  42. <script>
  43. var dayjs = require('dayjs')
  44. export default {
  45. data() {
  46. return {
  47. // 标题输入框绑定数据
  48. inputValue: '',
  49. // 评价绑定数据
  50. textareaValue: '',
  51. // 评价文字长度
  52. textareaValuelength: 0,
  53. // 上传的图片数据
  54. subImgList: [],
  55. // 订单id
  56. bookingId: '',
  57. // 民宿id
  58. hotelId: '',
  59. // 房间id
  60. houseId: ''
  61. }
  62. },
  63. onLoad(options) {
  64. this.bookingId = options.bookingId
  65. this.hotelId = options.hotelId
  66. this.houseId = options.houseId
  67. },
  68. methods: {
  69. // 评价输入框输入回调
  70. handleInput(e) {
  71. this.textareaValuelength = e.detail.cursor
  72. },
  73. // 上传图片回调
  74. handleUpLoad() {
  75. uni.chooseMedia({
  76. count: 9,
  77. maxDuration: 15,
  78. success: (res) => {
  79. console.log(res)
  80. console.log(res.tempFiles)
  81. if (this.subImgList.length + res.tempFiles.length > 9) {
  82. uni.showToast({
  83. title: '最多只能上传9个图片/视频',
  84. icon: 'none'
  85. })
  86. return
  87. }
  88. uni.showLoading({
  89. title: '上传中'
  90. })
  91. // reverse()
  92. res.tempFiles.forEach((ele) => {
  93. uni.uploadFile({
  94. url: `https://chtech.ncjti.edu.cn/hotelReservation/mhotel/mhotel/uploadhimage.action`,
  95. filePath: ele.tempFilePath,
  96. name: 'myFile',
  97. success: (uploadFileRes) => {
  98. console.log(JSON.parse(uploadFileRes.data))
  99. let temRes = JSON.parse(uploadFileRes.data)
  100. if (temRes.code === 200) {
  101. this.subImgList.push(temRes.data.url)
  102. console.log(this.subImgList)
  103. uni.hideLoading()
  104. } else {
  105. uni.showToast({
  106. title: temRes.message,
  107. icon: 'none'
  108. })
  109. }
  110. },
  111. fail: () => {
  112. uni.showToast({
  113. title: '上传失败',
  114. icon: 'error'
  115. })
  116. }
  117. })
  118. })
  119. }
  120. })
  121. },
  122. // 提交按钮回调
  123. async handleSub() {
  124. if (!this.inputValue) {
  125. uni.showToast({
  126. title: '请输入标题',
  127. icon: 'none',
  128. mask: true
  129. })
  130. return
  131. }
  132. if (!this.textareaValue) {
  133. uni.showToast({
  134. title: '请输入投诉内容',
  135. icon: 'none',
  136. mask: true
  137. })
  138. return
  139. }
  140. let time = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')
  141. const res = await this.$myRequest({
  142. url: '/mhotel/complaintorderComplaint.action',
  143. method: 'post',
  144. data: {
  145. bookingId: this.bookingId,
  146. hotelId: this.hotelId,
  147. houseId: this.houseId,
  148. title: this.inputValue,
  149. content: this.textareaValue,
  150. createId: uni.getStorageSync('userInfo').id,
  151. createDate: time,
  152. modifyDate: time,
  153. pictureList: this.subImgList
  154. }
  155. })
  156. // console.log(res)
  157. if (res.code === 200) {
  158. uni.navigateTo({
  159. url: `/pages/complaintStatus/complaintStatus?status=1`
  160. })
  161. } else {
  162. uni.navigateTo({
  163. url: `/pages/complaintStatus/complaintStatus?status=2`
  164. })
  165. }
  166. },
  167. // 删除图片回调
  168. handleDelete(index) {
  169. this.subImgList.splice(index, 1)
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. .container {
  176. display: flex;
  177. flex-direction: column;
  178. min-height: 100vh;
  179. background-color: #f2f3f5;
  180. .title {
  181. display: flex;
  182. align-items: center;
  183. margin: 20rpx 0;
  184. padding: 0 20rpx;
  185. height: 144rpx;
  186. background-color: #fff;
  187. .title_key {
  188. font-size: 28rpx;
  189. font-weight: bold;
  190. }
  191. .title_value {
  192. display: flex;
  193. align-items: center;
  194. box-sizing: border-box;
  195. padding: 0 26rpx;
  196. margin-left: 30rpx;
  197. width: 625rpx;
  198. height: 80rpx;
  199. border-radius: 11rpx;
  200. background-color: #f2f2f2;
  201. input {
  202. width: 100%;
  203. }
  204. }
  205. }
  206. .operation {
  207. padding: 20rpx 20rpx 33rpx;
  208. margin-bottom: 20rpx;
  209. background-color: #fff;
  210. .operation_input {
  211. box-sizing: border-box;
  212. padding: 20rpx;
  213. width: 710rpx;
  214. height: 282rpx;
  215. border-radius: 9rpx;
  216. background-color: #f2f2f2;
  217. .textarea {
  218. width: 100%;
  219. height: 203rpx;
  220. }
  221. .operation_count {
  222. height: 39rpx;
  223. text-align: end;
  224. color: #b3b3b3;
  225. font-size: 24rpx;
  226. }
  227. }
  228. .operation_uploading {
  229. display: grid;
  230. gap: 21rpx;
  231. grid-template-columns: repeat(auto-fill, 124rpx);
  232. margin-top: 20rpx;
  233. ::v-deep .uni-file-picker__item {
  234. background-color: red;
  235. }
  236. .uploading_box {
  237. position: relative;
  238. display: flex;
  239. flex-direction: column;
  240. justify-content: center;
  241. align-items: center;
  242. width: 124rpx;
  243. height: 124rpx;
  244. border-radius: 7rpx;
  245. background-color: #f2f2f2;
  246. .img {
  247. width: 40rpx;
  248. height: 40rpx;
  249. }
  250. .msg {
  251. margin-top: 5rpx;
  252. color: #a6a6a6;
  253. font-size: 20rpx;
  254. }
  255. .img2 {
  256. width: 124rpx;
  257. height: 124rpx;
  258. border-radius: 7rpx;
  259. }
  260. .icon {
  261. position: absolute;
  262. top: 0;
  263. right: 0;
  264. display: flex;
  265. justify-content: center;
  266. align-items: center;
  267. width: 30rpx;
  268. height: 30rpx;
  269. border-radius: 7rpx;
  270. background-color: rgba(000, 000, 000, 0.5);
  271. img {
  272. width: 30rpx;
  273. height: 30rpx;
  274. }
  275. }
  276. }
  277. }
  278. }
  279. .btn {
  280. display: flex;
  281. justify-content: center;
  282. align-items: center;
  283. margin: 368rpx auto 78rpx;
  284. width: 710rpx;
  285. height: 96rpx;
  286. color: #fff;
  287. font-size: 32rpx;
  288. border-radius: 64rpx;
  289. background-color: #096562;
  290. }
  291. }
  292. </style>