feedBack.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="feedBack">
  3. <div class="feedBack-box">
  4. <h4>猜你想问</h4>
  5. <div class="feedBack-item" @click="handleClick(index)" v-for="(item,index) in list" :key="index">
  6. {{item.text}}
  7. </div>
  8. </div>
  9. <div class="feedBack-box">
  10. <h4>问题反馈 <span style="margin-left:10rpx;" v-if="feedBack.type">@{{ list.find(item=>{return item.value == feedBack.type }).text }}</span></h4>
  11. <u-input class="field-input" height="500" :border-bottom="false" v-model="feedBack.context" type="textarea" placeholder="请输入反馈信息">
  12. </u-input>
  13. </div>
  14. <!-- 上传凭证 -->
  15. <div class="feedBack-box">
  16. <view class="opt-view">
  17. <view class="img-title">上传凭证(最多5张)</view>
  18. <view class="images-view">
  19. <u-upload :header=" { accessToken: storage.getAccessToken() }" :action="action" width="150" @on-uploaded="onUploaded" :max-count="5" :show-progress="false"></u-upload>
  20. </view>
  21. </view>
  22. </div>
  23. <div class="feedBack-box">
  24. <h4>手机号</h4>
  25. <u-input :border-bottom="false" v-model="feedBack.mobile" placeholder="请输入您的手机号">
  26. </u-input>
  27. </div>
  28. <div class="submit" @click="submit()">提交</div>
  29. </div>
  30. </template>
  31. <script>
  32. import storage from "@/utils/storage.js";
  33. import config from "@/config/config";
  34. import { feedBack } from "@/api/members.js";
  35. import { upload } from "@/api/common.js";
  36. export default {
  37. data() {
  38. return {
  39. storage,
  40. config,
  41. feedBack: {
  42. type: "FUNCTION", //默认反馈问题为 '功能相关'
  43. },
  44. action: upload, //图片上传地址
  45. list: [
  46. { text: "功能相关", value: "FUNCTION" },
  47. { text: "优化反馈", value: "OPTIMIZE" },
  48. { text: "其他", value: "OTHER" },
  49. ],
  50. };
  51. },
  52. methods: {
  53. // 点击反馈内容
  54. handleClick(index) {
  55. this.$set(this.feedBack, "type", this.list[index].value);
  56. },
  57. //图片上传
  58. onUploaded(lists) {
  59. let images = [];
  60. lists.forEach((item) => {
  61. images.push(item.response.result);
  62. });
  63. this.feedBack.images = images.join(",");
  64. },
  65. /**
  66. * 提交意见反馈
  67. */
  68. submit() {
  69. if (!this.feedBack.type) {
  70. uni.showToast({
  71. title: "请填写反馈类型",
  72. duration: 2000,
  73. icon: "none",
  74. });
  75. return false;
  76. }
  77. if (!this.feedBack.context) {
  78. uni.showToast({
  79. title: "请填写反馈类型",
  80. duration: 2000,
  81. icon: "none",
  82. });
  83. return false;
  84. }
  85. if (this.feedBack.mobile && !this.$u.test.mobile(this.feedBack.mobile)) {
  86. uni.showToast({
  87. title: "请填写您的正确手机号",
  88. duration: 2000,
  89. icon: "none",
  90. });
  91. return false;
  92. }
  93. /** 提交 */
  94. feedBack(this.feedBack).then((res) => {
  95. if (res.data.success) {
  96. uni.showToast({
  97. title: "提交成功!",
  98. duration: 2000,
  99. icon: "none",
  100. });
  101. setTimeout(() => {
  102. uni.navigateBack({
  103. delta: 1,
  104. });
  105. }, 500);
  106. }
  107. });
  108. },
  109. },
  110. };
  111. </script>
  112. <style lang="scss" scoped>
  113. .submit {
  114. text-align: center;
  115. background: $light-color;
  116. height: 70rpx;
  117. line-height: 70rpx;
  118. color: #fff;
  119. width: 92%;
  120. margin-bottom: 100rpx;
  121. margin: 0 auto;
  122. border-radius: 100px;
  123. }
  124. .feedBack {
  125. padding-bottom: 100rpx;
  126. }
  127. .feedBack-box {
  128. background: #fff;
  129. border-radius: 20rpx;
  130. padding: 32rpx;
  131. margin-bottom: 40rpx;
  132. }
  133. /deep/ .u-input__textarea {
  134. padding: 12px;
  135. }
  136. .feedBack-box:nth-of-type(1) {
  137. border-top-left-radius: 0;
  138. border-top-right-radius: 0;
  139. }
  140. .feedBack-item {
  141. margin: 20rpx 0;
  142. font-size: 24rpx;
  143. color: #666;
  144. }
  145. h4 {
  146. font-size: 30rpx;
  147. }
  148. .field-input {
  149. margin: 20rpx 0;
  150. padding: 20rpx 0;
  151. background: #fafafa;
  152. border-radius: 0.6em;
  153. }
  154. </style>