submit.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <div class="wrapper">
  3. <div class="feedBack-box">
  4. <h4>问题类型</h4>
  5. <view class="charge-amount">
  6. <view
  7. class="radio-button"
  8. v-for="(item, index) in list"
  9. :key="index"
  10. :class="{ selected: feedBack.type == item.value }"
  11. @click="handleClick(index)"
  12. >{{ item.text }}</view>
  13. </view>
  14. </div>
  15. <div class="feedBack-box">
  16. <h4>问题描述</h4>
  17. <u-input
  18. class="field-input"
  19. height="200"
  20. :border-bottom="false"
  21. v-model="feedBack.txt"
  22. type="textarea"
  23. placeholder="请说明您遇到的问题"
  24. :maxlength="200"
  25. :custom-style="{backgroundColor:'#80808020',borderRadius: '10rpx'}"
  26. ></u-input>
  27. <!-- #ifdef MP-WEIXIN -->
  28. <div class="word-limit">{{ getTextLen() }}/200</div>
  29. <!-- #endif -->
  30. </div>
  31. <div class="feedBack-box" v-if="connectorType.includes(feedBack.type)">
  32. <h4>充电枪编号</h4>
  33. <!-- #ifdef MP-WEIXIN -->
  34. <u-input
  35. class="field-input"
  36. :border-bottom="false"
  37. v-model="feedBack.connectorId"
  38. placeholder="请输入充电枪编号"
  39. :custom-style="{backgroundColor:'#80808020',borderRadius: '10rpx'}"
  40. ></u-input>
  41. <!-- #endif -->
  42. <!-- #ifndef MP-WEIXIN -->
  43. <u-input
  44. class="field-input"
  45. :border-bottom="false"
  46. v-model="feedBack.connectorId"
  47. placeholder="请输入充电枪编号"
  48. :custom-style="{backgroundColor:'#EFEFEFFF',borderRadius: '10rpx'}"
  49. :clearable="false"
  50. ></u-input>
  51. <!-- #endif -->
  52. </div>
  53. <!-- 上传凭证 -->
  54. <div class="feedBack-box">
  55. <view class="opt-view">
  56. <view class="img-title">上传凭证(最多2张)</view>
  57. <view class="images-view">
  58. <u-upload
  59. :header="{ accessToken: storage.getAccessToken() }"
  60. :action="action"
  61. width="150"
  62. @on-remove="onRemove"
  63. @on-success="onSuccess"
  64. @on-uploaded="onUploaded"
  65. :before-upload="beforeUpload"
  66. :max-count="2"
  67. :show-progress="false"
  68. ></u-upload>
  69. </view>
  70. </view>
  71. </div>
  72. <u-button type="success" :ripple="true" shape="circle" @click="save" :loading="loading">提交</u-button>
  73. </div>
  74. </template>
  75. <script>
  76. import storage from "@/utils/storage.js";
  77. import config from "@/config/config";
  78. import { feedback, getFeedbackInfo } from "@/api/members.js";
  79. import { upload } from "@/api/common.js";
  80. export default {
  81. data() {
  82. return {
  83. storage,
  84. config,
  85. selectedIndex: 0,
  86. feedBack: {
  87. type: 1,
  88. },
  89. action: upload, //图片上传地址
  90. list: [
  91. { text: "无法启动", value: 1 },
  92. { text: "枪头损坏", value: 2 },
  93. { text: "充电慢", value: 3 },
  94. { text: "车位被占用", value: 4 },
  95. { text: "其他", value: 99 },
  96. ],
  97. connectorType: [2, 3, 7, 8, 9, 11, 12, 13],
  98. img: [],
  99. loading:false,
  100. };
  101. },
  102. watch: {
  103. feedBack: {
  104. handler(val) {
  105. this.parkingPriceDetail = val.parkFeeList;
  106. },
  107. deep: true,
  108. immediate: true,
  109. },
  110. },
  111. methods: {
  112. getTextLen() {
  113. let strLength = 0
  114. if (this.feedBack && this.feedBack.txt) strLength = this.feedBack.txt.length;
  115. if (strLength > 200) strLength = 200;
  116. return strLength;
  117. },
  118. // 点击反馈内容
  119. handleClick(index) {
  120. this.$set(this.feedBack, "type", this.list[index].value);
  121. if (!this.connectorType.includes(this.list[index].value)) {
  122. this.feedBack.connectorId = "";
  123. }
  124. },
  125. //图片上传成功
  126. onSuccess(data, index, lists, name) {
  127. this.img.push(data.data.name);
  128. },
  129. //删除图片
  130. onRemove(index, lists, name) {
  131. this.img.splice(index, 1);
  132. },
  133. onUploaded(lists) {
  134. this.loading = false
  135. },
  136. beforeUpload(index, list) {
  137. this.loading = true
  138. return true;
  139. },
  140. /**
  141. * 提交意见反馈
  142. */
  143. save() {
  144. if (!this.feedBack.type) {
  145. uni.showToast({
  146. title: "请填写反馈类型",
  147. duration: 2000,
  148. icon: "none",
  149. });
  150. return false;
  151. }
  152. if (!this.feedBack.txt) {
  153. uni.showToast({
  154. title: "请填写反馈信息",
  155. duration: 2000,
  156. icon: "none",
  157. });
  158. return false;
  159. }
  160. if (this.feedBack.mobile && !this.$u.test.mobile(this.feedBack.mobile)) {
  161. uni.showToast({
  162. title: "请填写您的正确手机号",
  163. duration: 2000,
  164. icon: "none",
  165. });
  166. return false;
  167. }
  168. /** 提交 */
  169. this.feedBack.imgArrayJson = JSON.stringify(this.img)
  170. feedback(this.feedBack).then((res) => {
  171. if (res.data.code == 200) {
  172. uni.showToast({
  173. title: "提交成功!",
  174. duration: 2000,
  175. icon: "success",
  176. });
  177. setTimeout(() => {
  178. uni.navigateBack({
  179. delta: 1,
  180. });
  181. }, 1000);
  182. }
  183. });
  184. },
  185. },
  186. };
  187. </script>
  188. <style lang="scss" scoped>
  189. .wrapper {
  190. padding: 30rpx;
  191. }
  192. .feedBack-box {
  193. position: relative;
  194. padding: 30rpx 0;
  195. }
  196. .word-limit {
  197. position: absolute;
  198. color: #95989e;
  199. // background-color: ;
  200. right: 48rpx;
  201. bottom: 30rpx;
  202. }
  203. /deep/ .u-input__textarea {
  204. padding: 20rpx;
  205. }
  206. /deep/ .u-input__input {
  207. padding: 0 10rpx;
  208. }
  209. .feedBack-item {
  210. margin: 20rpx 0;
  211. font-size: 24rpx;
  212. color: #666;
  213. }
  214. h4 {
  215. font-size: 30rpx;
  216. margin-bottom: 20rpx;
  217. }
  218. .field-input {
  219. margin: 10rpx 0;
  220. border-radius: 10rpx;
  221. }
  222. .charge-amount {
  223. display: flex;
  224. justify-content: flex-start;
  225. flex-wrap: wrap;
  226. }
  227. .radio-button {
  228. border-radius: 20rpx;
  229. background: #7c7c7c15;
  230. text-align: center;
  231. line-height: 62rpx;
  232. height: 62rpx;
  233. width: 210rpx;
  234. margin: 10rpx;
  235. font-size: 25rpx;
  236. border: 1px solid transparent;
  237. &.selected {
  238. background: rgba(0, 201, 164, 0.1);
  239. border: 1px solid #0974C5;
  240. color: #0974C5;
  241. }
  242. .amount {
  243. font-size: 32rpx;
  244. font-weight: 700;
  245. margin-bottom: 24rpx;
  246. }
  247. .sub {
  248. font-size: 24rpx;
  249. }
  250. }
  251. </style>