complaint.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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;" />
  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. export default {
  44. data() {
  45. return {
  46. // 评价绑定数据
  47. textareaValue: '',
  48. // 评价文字长度
  49. textareaValuelength: 0,
  50. // 上传的图片数据
  51. subImgList: []
  52. }
  53. },
  54. methods: {
  55. // 评价输入框输入回调
  56. handleInput(e) {
  57. this.textareaValuelength = e.detail.cursor
  58. },
  59. handleUpLoad() {
  60. uni.chooseMedia({
  61. count: 9,
  62. maxDuration: 15,
  63. success: (res) => {
  64. console.log(res)
  65. console.log(res.tempFiles)
  66. if (this.subImgList.length + res.tempFiles.length > 9) {
  67. uni.showToast({
  68. title: '最多只能上传9个图片/视频',
  69. icon: 'none'
  70. })
  71. return
  72. }
  73. uni.showLoading({
  74. title: '上传中'
  75. })
  76. // reverse()
  77. res.tempFiles.forEach((ele) => {
  78. uni.uploadFile({
  79. url: `https://chtech.ncjti.edu.cn/hotelReservation/mhotel/mhotel/uploadhimage.action`,
  80. filePath: ele.tempFilePath,
  81. name: 'myFile',
  82. success: (uploadFileRes) => {
  83. console.log(JSON.parse(uploadFileRes.data))
  84. let temRes = JSON.parse(uploadFileRes.data)
  85. if (temRes.code === 200) {
  86. this.subImgList.push(temRes.data.url)
  87. console.log(this.subImgList)
  88. uni.hideLoading()
  89. } else {
  90. uni.showToast({
  91. title: temRes.message,
  92. icon: 'none'
  93. })
  94. }
  95. },
  96. fail: () => {
  97. uni.showToast({
  98. title: '上传失败',
  99. icon: 'error'
  100. })
  101. }
  102. })
  103. })
  104. }
  105. })
  106. },
  107. handleSub() {
  108. uni.navigateTo({
  109. url: `/pages/complaintStatus/complaintStatus?status=1`
  110. })
  111. },
  112. // 删除图片回调
  113. handleDelete(index) {
  114. this.subImgList.splice(index, 1)
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .container {
  121. display: flex;
  122. flex-direction: column;
  123. min-height: 100vh;
  124. background-color: #f2f3f5;
  125. .title {
  126. display: flex;
  127. align-items: center;
  128. margin: 20rpx 0;
  129. padding: 0 20rpx;
  130. height: 144rpx;
  131. background-color: #fff;
  132. .title_key {
  133. font-size: 28rpx;
  134. font-weight: bold;
  135. }
  136. .title_value {
  137. display: flex;
  138. align-items: center;
  139. box-sizing: border-box;
  140. padding: 0 26rpx;
  141. margin-left: 30rpx;
  142. width: 625rpx;
  143. height: 80rpx;
  144. border-radius: 11rpx;
  145. background-color: #f2f2f2;
  146. input {
  147. width: 100%;
  148. }
  149. }
  150. }
  151. .operation {
  152. padding: 20rpx 20rpx 33rpx;
  153. margin-bottom: 20rpx;
  154. background-color: #fff;
  155. .operation_input {
  156. box-sizing: border-box;
  157. padding: 20rpx;
  158. width: 710rpx;
  159. height: 282rpx;
  160. border-radius: 9rpx;
  161. background-color: #f2f2f2;
  162. .textarea {
  163. width: 100%;
  164. height: 203rpx;
  165. }
  166. .operation_count {
  167. height: 39rpx;
  168. text-align: end;
  169. color: #b3b3b3;
  170. font-size: 24rpx;
  171. }
  172. }
  173. .operation_uploading {
  174. display: grid;
  175. gap: 21rpx;
  176. grid-template-columns: repeat(auto-fill, 124rpx);
  177. margin-top: 20rpx;
  178. ::v-deep .uni-file-picker__item {
  179. background-color: red;
  180. }
  181. .uploading_box {
  182. position: relative;
  183. display: flex;
  184. flex-direction: column;
  185. justify-content: center;
  186. align-items: center;
  187. width: 124rpx;
  188. height: 124rpx;
  189. border-radius: 7rpx;
  190. background-color: #f2f2f2;
  191. .img {
  192. width: 40rpx;
  193. height: 40rpx;
  194. }
  195. .msg {
  196. margin-top: 5rpx;
  197. color: #a6a6a6;
  198. font-size: 20rpx;
  199. }
  200. .img2 {
  201. width: 124rpx;
  202. height: 124rpx;
  203. border-radius: 7rpx;
  204. }
  205. .icon {
  206. position: absolute;
  207. top: 0;
  208. right: 0;
  209. display: flex;
  210. justify-content: center;
  211. align-items: center;
  212. width: 30rpx;
  213. height: 30rpx;
  214. border-radius: 7rpx;
  215. background-color: rgba(000, 000, 000, 0.5);
  216. img {
  217. width: 30rpx;
  218. height: 30rpx;
  219. }
  220. }
  221. }
  222. }
  223. }
  224. .btn {
  225. display: flex;
  226. justify-content: center;
  227. align-items: center;
  228. margin: 368rpx auto 78rpx;
  229. width: 710rpx;
  230. height: 96rpx;
  231. color: #fff;
  232. font-size: 32rpx;
  233. border-radius: 64rpx;
  234. background-color: #096562;
  235. }
  236. }
  237. </style>