feedback.vue 3.3 KB

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