feedback.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="complain">
  3. <view class="content">
  4. <view class="title">
  5. 投诉类型
  6. </view>
  7. <view class="select" v-for="(item,index) in list" :key="index" @click="selectType(item,index)">
  8. {{item.info}}
  9. <image src="../../static/other/select.png" mode="" v-if="currentIndex === index"></image>
  10. <image src="../../static/other/no_select.png" mode="" v-else></image>
  11. </view>
  12. </view>
  13. <view class="content">
  14. <view class="title">
  15. 问题描述
  16. </view>
  17. <view class="select">
  18. <textarea v-model="form.description" placeholder="您的反馈将帮助我们改善服务品质,期待您的反馈"></textarea>
  19. </view>
  20. </view>
  21. <view class="content">
  22. <view class="title">
  23. 投诉商户
  24. </view>
  25. <view class="select">
  26. <input type="text" v-model="form.name" placeholder="请输入您要投诉的商户姓名" />
  27. <u-select v-model="show" :list="citylist" @confirm="confirm"></u-select>
  28. </view>
  29. <view class="city" @click="selectCity" v-if="form.deptName == ''">
  30. 所在城市
  31. </view>
  32. <view class="city" v-else>
  33. {{form.deptName}}
  34. </view>
  35. </view>
  36. <view class="content">
  37. <view class="title">
  38. 手机号码
  39. </view>
  40. <view class="select">
  41. <input v-model="form.phone" placeholder="请输入您的手机号码,以便我们及时联系您"></input>
  42. </view>
  43. </view>
  44. <view class="content">
  45. <view class="title">
  46. 添加图片
  47. </view>
  48. <view class="select">
  49. <u-upload :action="uploadUrl" :max-count="2" :file-list="LifeList" @on-success="handleUploadSuccess"
  50. @on-remove="handleUploadRemove" :header="header"></u-upload>
  51. </view>
  52. </view>
  53. <view class="btn_box">
  54. <view class="btn" @click="submit">
  55. 提交
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. complain,
  63. getCityList,complaintEnum
  64. } from '../../api/index'
  65. export default {
  66. data() {
  67. return {
  68. list: [],
  69. citylist: [],
  70. city: '',
  71. currentIndex: '',
  72. describe: '',
  73. jsName: '',
  74. LifeList: [],
  75. photograph: [],
  76. show: false,
  77. // uploadUrl: 'https://test.baoxianzhanggui.com/nightFragrance/common/upload',
  78. uploadUrl:'https://city.baoxianzhanggui.com/nightFragrance/common/upload',
  79. urlImg: [],
  80. form: {
  81. description: '',
  82. complaintType: '',
  83. name: '',
  84. photograph: '',
  85. deptName: '',
  86. phone:'',
  87. deptId: null
  88. },
  89. token: ''
  90. }
  91. },
  92. methods: {
  93. selectType(item, index) {
  94. this.currentIndex = index
  95. this.form.complaintType = item.desc
  96. },
  97. handleUploadSuccess(response) {
  98. this.photograph.push(response.fileName)
  99. },
  100. handleUploadRemove(index) {
  101. this.urlImg.splice(index, 1);
  102. this.form.photograph.splice(index, 1)
  103. },
  104. selectCity() {
  105. this.show = true
  106. },
  107. confirm(e) {
  108. this.form.deptName = e[0].label
  109. this.form.deptId = e[0].value
  110. },
  111. submit() {
  112. console.log(this.form)
  113. this.form.photograph = this.photograph.toString()
  114. if (this.form.complaintType == '') {
  115. uni.showToast({
  116. title: '请选择投诉类型',
  117. icon: 'none'
  118. })
  119. return
  120. } else {
  121. complain(this.form).then(res => {
  122. console.log(res)
  123. if (res.data.code == 200){
  124. uni.showToast({
  125. title: '提交成功',
  126. icon: 'none'
  127. })
  128. uni.navigateBack()
  129. }else{
  130. uni.showToast({
  131. title: res.data.msg,
  132. icon: 'none'
  133. })
  134. }
  135. })
  136. }
  137. },
  138. complaintEnum(){
  139. complaintEnum().then(res => {
  140. this.list = res.data.data
  141. })
  142. },
  143. getCity() {
  144. getCityList().then(res => {
  145. this.citylist = res.data.data.map(({
  146. deptId,
  147. deptName
  148. }) => ({
  149. value: deptId,
  150. label: deptName
  151. }))
  152. });
  153. }
  154. },
  155. onShow() {
  156. // this.token =
  157. // 'eyJhbGciOiJIUzUxMiJ9.eyJ0ZjoiOiJiN2UyOTU5NC0wNjE0LTQ2MWUtOThmYy1hMGJlYWNjYjExZWUifQ.SYH2TuRT-DVjzbW2moz6pgkItmsOsUEbh8jENZlCM9RV0AUEMFq9P7HEtuVa1LXWts1k3ss1VD1rpMrnr_9EFA'
  158. // uni.setStorageSync('access-token',
  159. // 'eyJhbGciOiJIUzUxMiJ9.eyJ0ZjoiOiJiN2UyOTU5NC0wNjE0LTQ2MWUtOThmYy1hMGJlYWNjYjExZWUifQ.SYH2TuRT-DVjzbW2moz6pgkItmsOsUEbh8jENZlCM9RV0AUEMFq9P7HEtuVa1LXWts1k3ss1VD1rpMrnr_9EFA'
  160. // )
  161. this.getCity()
  162. this.complaintEnum()
  163. },
  164. computed: {
  165. header() {
  166. return {
  167. Authorization: `tf: ${this.token}`, // 携带Token的请求头
  168. };
  169. },
  170. },
  171. mounted() {
  172. // 在页面加载时获取Token,可以从本地缓存中获取
  173. this.token = uni.getStorageSync('access-token'); // 假设token保存在本地缓存中
  174. },
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .complain {
  179. width: 100%;
  180. height: 100%;
  181. background: linear-gradient(to right, #fcfdff, #b1fffc);
  182. padding-top: 20px;
  183. overflow-y: auto;
  184. padding-bottom: 100px;
  185. .content {
  186. width: 95%;
  187. margin: 10px auto;
  188. background-color: #fff;
  189. border-radius: 10px;
  190. padding: 20rpx;
  191. box-sizing: border-box;
  192. box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  193. .title {
  194. width: 100%;
  195. background-color: #f7f7f7;
  196. margin: 0 auto;
  197. padding: 10rpx 0px;
  198. text-align: center;
  199. border-radius: 10px;
  200. }
  201. .select {
  202. width: 100%;
  203. display: flex;
  204. justify-content: space-between;
  205. margin: 20px 0px;
  206. image {
  207. width: 40rpx;
  208. height: 40rpx;
  209. }
  210. textarea {
  211. width: 100%;
  212. height: 100px;
  213. background-color: #f7f7f7;
  214. padding: 10px;
  215. border-radius: 10px;
  216. }
  217. input {
  218. width: 100%;
  219. background-color: #f7f7f7;
  220. padding: 10px;
  221. border-radius: 10px;
  222. font-size: 24rpx;
  223. }
  224. }
  225. .city {
  226. width: 100%;
  227. font-size: 24rpx;
  228. box-sizing: border-box;
  229. background-color: #f7f7f7;
  230. margin: 0 auto;
  231. padding: 10px;
  232. // text-align: left;
  233. border-radius: 10px;
  234. }
  235. }
  236. .btn_box {
  237. width: 100%;
  238. height: 60px;
  239. background-color: #fff;
  240. position: fixed;
  241. bottom: 0px;
  242. .btn {
  243. width: 40%;
  244. height: 40px;
  245. text-align: center;
  246. background: linear-gradient(to right, #35c99d, #27aea7);
  247. margin: 20rpx auto;
  248. line-height: 40px;
  249. border-radius: 10px;
  250. color: #fcfdff;
  251. }
  252. }
  253. }
  254. </style>