jb.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="content">
  3. <view class="row1 flex flex-space-between">
  4. <view>被举报人</view>
  5. <view style='align-items: center;' class='flex'>
  6. <image :src="dataDetails.avatarUrl" mode="widthFix" class="img"></image>
  7. <view>{{dataDetails.driverName}}</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. if (!this.value1) {
  65. that.$refs.uToast.show({
  66. type: 'error',
  67. message: "举报信息不能为空!",
  68. })
  69. return
  70. }
  71. if (this.value1.length<10||this.value1.length>300) {
  72. that.$refs.uToast.show({
  73. type: 'error',
  74. message: "举报信息输入错误!",
  75. })
  76. return
  77. }
  78. uni.showLoading({
  79. title: '加载中'
  80. })
  81. this.$request.baseRequest('post', '/feedbackReport/api/addInfo', {
  82. initiator:this.dataDetails.cargoOwner,
  83. initiatorNumber:this.dataDetails.cargoOwnerPhone,
  84. commonId: this.userInfo.id,
  85. passive: this.dataDetails.driverName,
  86. passiveNumber: this.dataDetails.driverPhone,
  87. passiveCommonId:this.dataDetails.commonId,
  88. content: this.value1,
  89. url: this.imgList.toString(),
  90. flag: 2,
  91. objectFlag:1,
  92. }).then(res => {
  93. let that = this
  94. uni.hideLoading()
  95. this.$refs.uToast.show({
  96. type: 'success',
  97. message: "举报成功",
  98. complete() {
  99. uni.$u.route('/pages/order/driverDetail',{
  100. driver:JSON.stringify(that.dataDetails)
  101. });
  102. }
  103. })
  104. })
  105. .catch(res => {
  106. uni.$u.toast(res.message);
  107. });
  108. },
  109. // 删除图片
  110. deletePic(event) {
  111. this[`fileList${event.name}`].splice(event.index, 1)
  112. },
  113. // 新增图片
  114. async afterRead(event) {
  115. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  116. let lists = [].concat(event.file)
  117. let fileListLen = this[`fileList${event.name}`].length
  118. lists.map((item) => {
  119. this[`fileList${event.name}`].push({
  120. ...item,
  121. status: 'uploading',
  122. message: '上传中'
  123. })
  124. })
  125. for (let i = 0; i < lists.length; i++) {
  126. const result = await this.uploadFilePromise(lists[i].url)
  127. let item = this[`fileList${event.name}`][fileListLen]
  128. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  129. status: 'success',
  130. message: '',
  131. url: result
  132. }))
  133. fileListLen++
  134. }
  135. },
  136. uploadFilePromise(url) {
  137. uploadImage('image', url, 'appData/',
  138. result => {
  139. // 上传成功回调函数
  140. console.log('图片地址', result)
  141. this.imgList.push(result)
  142. }
  143. )
  144. },
  145. }
  146. }
  147. </script>
  148. <style lang="scss">
  149. .content {
  150. background: white;
  151. }
  152. .img {
  153. width: 40rpx;
  154. }
  155. .row1,
  156. .row2 {
  157. padding: 40rpx;
  158. }
  159. .title {
  160. margin-bottom: 20rpx;
  161. }
  162. .row3 {
  163. width: 80%;
  164. background: #2772FB;
  165. text-align: center;
  166. color: white;
  167. padding: 20rpx;
  168. margin: auto;
  169. border-radius: 10rpx;
  170. }
  171. </style>