feedback.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <u-navbar title="意见反馈"></u-navbar>
  4. <view class="main">
  5. <textarea name="" id=""
  6. v-model="subForm.content"
  7. cols="30" rows="10" placeholder="填写反馈内容(必填)"></textarea>
  8. <u-upload :form-data="formData" :header="header" :action="action"
  9. :file-list="fileList" upload-text=""></u-upload>
  10. <input type="text"
  11. v-model="subForm.telephone"
  12. placeholder="请留下联系方式,方便我们与您取得联系" />
  13. </view>
  14. <button @click="submit">提交</button>
  15. </view>
  16. </template>
  17. <script>
  18. import * as API from '@/apis/pagejs/user.js'
  19. import * as WxJsApi from '@/apis/utils/wxJsApi'
  20. export default {
  21. data() {
  22. return {
  23. action:"",
  24. formData:{},
  25. fileList:[],
  26. header:{
  27. },
  28. subForm: {
  29. content: '',
  30. imgUrl: '',
  31. telephone: ''
  32. }
  33. }
  34. },onLoad() {
  35. this.action=process.car.BASE_URL+"uploadPicture"
  36. this.formData.subFolder="feedback"
  37. //接口应该免登陆
  38. var token=this.carhelp.getToken()
  39. this.header={
  40. 'Authorization':token
  41. }
  42. // //获取微信配置
  43. // WxJsApi.getWxConfig(['getLocation','addEventListener']).then((res)=>{
  44. // this.isReady=true;
  45. // //(res)
  46. // }).catch(error => {
  47. // //(res)
  48. // })
  49. },
  50. methods: {
  51. //表单检测
  52. checkFrom() {
  53. if (!this.subForm.content) {
  54. uni.showToast({
  55. title: "请输入内容"
  56. })
  57. return false;
  58. } else {
  59. return true;
  60. }
  61. },
  62. //提交
  63. submit() {
  64. if (this.checkFrom()) {
  65. uni.showModal({
  66. title: '提示',
  67. content: '提交成功',
  68. showCancel:false,
  69. success: res=>{
  70. if (res.confirm) {
  71. uni.navigateBack({
  72. })
  73. } else if (res.cancel) {
  74. //('用户点击取消');
  75. }
  76. }
  77. });
  78. }
  79. },
  80. //提交
  81. submit2() {
  82. let files = [];
  83. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  84. files = this.$refs.uUpload.lists.filter(val => {
  85. return val.progress == 100;
  86. })
  87. // 如果您不需要进行太多的处理,直接如下即可
  88. // files = this.$refs.uUpload.lists;
  89. //(files);
  90. var imgUrl=files.map(item=>{
  91. return item.response.data;
  92. })
  93. //(imgUrl);
  94. this.subForm.imgUrl = imgUrl.join(',');
  95. if (this.checkFrom()) {
  96. this.subForm.picUrl = this.listPic.join(',');
  97. uni.showLoading({
  98. title: "加载中",
  99. mask: true,
  100. })
  101. API.feedback(this.subForm).then(response => {
  102. uni.hideLoading()
  103. uni.showModal({
  104. title: '提示',
  105. content: '提交成功',
  106. showCancel:false,
  107. success: res=>{
  108. if (res.confirm) {
  109. uni.navigateBack({
  110. })
  111. } else if (res.cancel) {
  112. //('用户点击取消');
  113. }
  114. }
  115. });
  116. }).catch(error => {
  117. uni.showToast({
  118. title: error
  119. })
  120. })
  121. }
  122. },
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. page {
  128. background-color: #fff;
  129. }
  130. .main {
  131. padding: 32rpx;
  132. /deep/.u-add-tips {
  133. margin-top: 0;
  134. }
  135. // /deep/.u-icon__icon {
  136. // font-size: 90rpx !important;
  137. // color: #b0b0b0 !important;
  138. // }
  139. .u-upload{
  140. margin-top: 32rpx;
  141. }
  142. uni-input {
  143. margin-top: 32rpx;
  144. height: 80rpx;
  145. border-bottom: 1px solid #b5b5b5;
  146. color: #b5b5b5;
  147. font-size: 14px
  148. }
  149. }
  150. uni-button {
  151. margin:80rpx 32rpx;
  152. border-radius: 8px;
  153. background-color: rgba(31, 74, 153, 1);
  154. color: rgba(255, 255, 255, 1);
  155. font-size: 16px;
  156. height: 88rpx;
  157. }
  158. </style>