jb.vue 3.5 KB

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