fk.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. 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/order/driverDetail', {
  62. driver: JSON.stringify(that.dataDetails)
  63. });
  64. }
  65. })
  66. })
  67. .catch(res => {
  68. uni.$u.toast(res.message);
  69. });
  70. },
  71. // 删除图片
  72. deletePic(event) {
  73. this[`fileList${event.name}`].splice(event.index, 1)
  74. },
  75. // 新增图片
  76. async afterRead(event) {
  77. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  78. let lists = [].concat(event.file)
  79. let fileListLen = this[`fileList${event.name}`].length
  80. lists.map((item) => {
  81. this[`fileList${event.name}`].push({
  82. ...item,
  83. status: 'uploading',
  84. message: '上传中'
  85. })
  86. })
  87. for (let i = 0; i < lists.length; i++) {
  88. const result = await this.uploadFilePromise(lists[i].url)
  89. let item = this[`fileList${event.name}`][fileListLen]
  90. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  91. status: 'success',
  92. message: '',
  93. url: result
  94. }))
  95. fileListLen++
  96. }
  97. },
  98. uploadFilePromise(url) {
  99. uploadImage('image', url, 'appData/',
  100. result => {
  101. // 上传成功回调函数
  102. console.log('图片地址', result)
  103. this.imgList.push(result)
  104. }
  105. )
  106. },
  107. }
  108. }
  109. </script>
  110. <style lang="scss">
  111. .content {
  112. background: white;
  113. }
  114. .img {
  115. width: 40rpx;
  116. }
  117. .row1,
  118. .row2 {
  119. padding: 40rpx;
  120. }
  121. .title {
  122. margin-bottom: 20rpx;
  123. }
  124. .row3 {
  125. width: 80%;
  126. background: #2772FB;
  127. text-align: center;
  128. color: white;
  129. padding: 20rpx;
  130. margin: auto;
  131. border-radius: 10rpx;
  132. }
  133. </style>