fk.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <view class="content">
  3. <view class="row1 flex flex-space-between">
  4. <view>被反馈人</view>
  5. <view class='flex'>
  6. <image :src="dataDetails.driverPortrait" mode="widthFix" style="width: 40rpx;height: 40rpx;"> </image>
  7. <view>{{dataDetails.cargoOwnerName}}</view>
  8. </view>
  9. </view>
  10. <u-line class="line"></u-line>
  11. <view class="row2">
  12. <view class="title">反馈信息</view>
  13. <u--textarea v-model="value1" placeholder="输入要反馈的内容,10-300字" count maxlength='300'></u--textarea>
  14. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  15. name="1" multiple :maxCount="9"></u-upload>
  16. </view>
  17. <view class="row3" @click="submit">提交</view>
  18. <u-toast ref="uToast"></u-toast>
  19. </view>
  20. </template>
  21. <script>
  22. import {
  23. mapState
  24. } from 'vuex';
  25. import uploadImage from '@/components/ossutil/uploadFile.js';
  26. export default {
  27. data() {
  28. return {
  29. imgList: [],
  30. value1: '',
  31. fileList1: [],
  32. dataDetails: {},
  33. };
  34. },
  35. onLoad(options) {
  36. this.dataDetails = JSON.parse(options.val)
  37. console.log(this.dataDetails)
  38. this.imgList = []
  39. },
  40. computed: {
  41. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  42. },
  43. methods: {
  44. submit() {
  45. uni.showLoading({
  46. title: '加载中'
  47. })
  48. this.$request.baseRequest('post', '/feedbackReport/api/addInfo', {
  49. commonId: this.userInfo.id,
  50. name: this.dataDetails.cargoOwnerName,
  51. content: this.value1,
  52. url: this.imgList.toString(),
  53. flag: 1,
  54. }).then(res => {
  55. let that = this
  56. uni.hideLoading()
  57. this.$refs.uToast.show({
  58. type: 'success',
  59. message: "反馈成功",
  60. complete() {
  61. // uni.$u.route('/pages/goodSource/cargoOwnerSee', {
  62. // driver: JSON.stringify(that.dataDetails)
  63. // });
  64. uni.navigateBack({
  65. delta: 1
  66. });
  67. }
  68. })
  69. })
  70. .catch(res => {
  71. uni.$u.toast(res.message);
  72. });
  73. },
  74. // 删除图片
  75. deletePic(event) {
  76. this[`fileList${event.name}`].splice(event.index, 1)
  77. },
  78. // 新增图片
  79. async afterRead(event) {
  80. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  81. let lists = [].concat(event.file)
  82. let fileListLen = this[`fileList${event.name}`].length
  83. lists.map((item) => {
  84. this[`fileList${event.name}`].push({
  85. ...item,
  86. status: 'uploading',
  87. message: '上传中'
  88. })
  89. })
  90. for (let i = 0; i < lists.length; i++) {
  91. const result = await this.uploadFilePromise(lists[i].url)
  92. let item = this[`fileList${event.name}`][fileListLen]
  93. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  94. status: 'success',
  95. message: '',
  96. url: result
  97. }))
  98. fileListLen++
  99. }
  100. },
  101. uploadFilePromise(url) {
  102. uploadImage('image', url, 'appData/',
  103. result => {
  104. // 上传成功回调函数
  105. console.log('图片地址', result)
  106. this.imgList.push(result)
  107. }
  108. )
  109. },
  110. }
  111. }
  112. </script>
  113. <style lang="scss">
  114. .content {
  115. background: white;
  116. }
  117. .img {
  118. width: 40rpx;
  119. }
  120. .row1,
  121. .row2 {
  122. padding: 40rpx;
  123. }
  124. .title {
  125. margin-bottom: 20rpx;
  126. }
  127. .row3 {
  128. width: 80%;
  129. background: #2772FB;
  130. text-align: center;
  131. color: white;
  132. padding: 20rpx;
  133. margin: auto;
  134. border-radius: 10rpx;
  135. }
  136. </style>