fk.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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" class="img"></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. debugger
  37. this.dataDetails = JSON.parse(options.val)
  38. console.log(this.dataDetails)
  39. this.imgList = []
  40. },
  41. computed: {
  42. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  43. },
  44. methods: {
  45. submit() {
  46. uni.showLoading({
  47. title: '加载中'
  48. })
  49. this.$request.baseRequest('post', '/feedbackReport/api/addInfo', {
  50. commonId: this.userInfo.id,
  51. name: this.dataDetails.cargoOwnerName,
  52. content: this.value1,
  53. url: this.imgList.toString(),
  54. flag: 1,
  55. }).then(res => {
  56. let that = this
  57. uni.hideLoading()
  58. this.$refs.uToast.show({
  59. type: 'success',
  60. message: "反馈成功",
  61. complete() {
  62. uni.$u.route('/pages/order/driverDetail', {
  63. driver: JSON.stringify(that.dataDetails)
  64. });
  65. }
  66. })
  67. })
  68. .catch(res => {
  69. uni.$u.toast(res.message);
  70. });
  71. },
  72. // 删除图片
  73. deletePic(event) {
  74. this[`fileList${event.name}`].splice(event.index, 1)
  75. },
  76. // 新增图片
  77. async afterRead(event) {
  78. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  79. let lists = [].concat(event.file)
  80. let fileListLen = this[`fileList${event.name}`].length
  81. lists.map((item) => {
  82. this[`fileList${event.name}`].push({
  83. ...item,
  84. status: 'uploading',
  85. message: '上传中'
  86. })
  87. })
  88. for (let i = 0; i < lists.length; i++) {
  89. const result = await this.uploadFilePromise(lists[i].url)
  90. let item = this[`fileList${event.name}`][fileListLen]
  91. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  92. status: 'success',
  93. message: '',
  94. url: result
  95. }))
  96. fileListLen++
  97. }
  98. },
  99. uploadFilePromise(url) {
  100. uploadImage('image', url, 'appData/',
  101. result => {
  102. // 上传成功回调函数
  103. console.log('图片地址', result)
  104. this.imgList.push(result)
  105. }
  106. )
  107. },
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. .content {
  113. background: white;
  114. }
  115. .img {
  116. width: 40rpx;
  117. }
  118. .row1,
  119. .row2 {
  120. padding: 40rpx;
  121. }
  122. .title {
  123. margin-bottom: 20rpx;
  124. }
  125. .row3 {
  126. width: 80%;
  127. background: #2772FB;
  128. text-align: center;
  129. color: white;
  130. padding: 20rpx;
  131. margin: auto;
  132. border-radius: 10rpx;
  133. }
  134. </style>