jb.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 permision from "@/js_sdk/wa-permission/permission.js"
  26. import uploadImage from '@/components/ossutil/uploadFile.js';
  27. export default {
  28. data() {
  29. return {
  30. imgList: [],
  31. value1: '',
  32. fileList1: [],
  33. dataDetails: {},
  34. };
  35. },
  36. computed: {
  37. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  38. },
  39. onLoad(options) {
  40. this.get_camera_permission()
  41. this.dataDetails = JSON.parse(options.val)
  42. console.log(this.dataDetails)
  43. this.imgList = []
  44. },
  45. methods: {
  46. async get_camera_permission() {
  47. var photol=await permision.requestAndroidPermission("android.permission.CAMERA")
  48. if(photol == false){
  49. uni.showModal({
  50. title: '提示',
  51. content: '您已经关闭相册权限,去设置',
  52. success: function (res) {
  53. if (res.confirm) {
  54. permision.gotoAppPermissionSetting()
  55. // plus.runtime.openURL("app-settings:");
  56. } else if (res.cancel) {
  57. console.log('用户点击取消');
  58. }
  59. }
  60. });
  61. }
  62. },
  63. submit() {
  64. uni.showLoading({
  65. title: '加载中'
  66. })
  67. this.$request.baseRequest('post', '/feedbackReport/api/addInfo', {
  68. initiator:this.firstAuthentication.driverName,
  69. initiatorNumber:this.firstAuthentication.driverPhone,
  70. commonId: this.firstAuthentication.commonId,
  71. passive: this.dataDetails.cargoOwnerName,
  72. passiveNumber: this.dataDetails.cargoOwnerPhone,
  73. passiveCommonId:this.dataDetails.commonId,
  74. content: this.value1,
  75. url: this.imgList.toString(),
  76. flag: 2,
  77. objectFlag:2
  78. }).then(res => {
  79. let that = this
  80. uni.hideLoading()
  81. this.$refs.uToast.show({
  82. type: 'success',
  83. message: "举报成功",
  84. complete() {
  85. // uni.$u.route('/pages/order/driverDetail', {
  86. // driver: JSON.stringify(that.dataDetails)
  87. // });
  88. uni.navigateBack({
  89. delta:1
  90. })
  91. }
  92. })
  93. })
  94. .catch(res => {
  95. uni.$u.toast(res.message);
  96. });
  97. },
  98. // 删除图片
  99. deletePic(event) {
  100. this[`fileList${event.name}`].splice(event.index, 1)
  101. },
  102. // 新增图片
  103. async afterRead(event) {
  104. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  105. let lists = [].concat(event.file)
  106. let fileListLen = this[`fileList${event.name}`].length
  107. lists.map((item) => {
  108. this[`fileList${event.name}`].push({
  109. ...item,
  110. status: 'uploading',
  111. message: '上传中'
  112. })
  113. })
  114. for (let i = 0; i < lists.length; i++) {
  115. const result = await this.uploadFilePromise(lists[i].url)
  116. let item = this[`fileList${event.name}`][fileListLen]
  117. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  118. status: 'success',
  119. message: '',
  120. url: result
  121. }))
  122. fileListLen++
  123. }
  124. },
  125. uploadFilePromise(url) {
  126. uploadImage('image', url, 'appData/',
  127. result => {
  128. // 上传成功回调函数
  129. console.log('图片地址', result)
  130. this.imgList.push(result)
  131. }
  132. )
  133. },
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. .content {
  139. background: white;
  140. }
  141. .img {
  142. width: 40rpx;
  143. height: 40rpx;
  144. }
  145. .row1,
  146. .row2 {
  147. padding: 40rpx;
  148. }
  149. .title {
  150. margin-bottom: 20rpx;
  151. }
  152. .row3 {
  153. width: 80%;
  154. background: #2772FB;
  155. text-align: center;
  156. color: white;
  157. padding: 20rpx;
  158. margin: auto;
  159. border-radius: 10rpx;
  160. }
  161. </style>