jb.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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="row1 flex flex-space-between">
  12. <view>关联订单(选填)</view>
  13. <view style='align-items: center;' class='flex'>
  14. <view @click='selectorder'>{{dataDetails.orderNo?dataDetails.orderNo:'选择订单'}}></view>
  15. </view>
  16. </view>
  17. <u-line class="line"></u-line>
  18. <view class="row2">
  19. <view class="title">举报信息</view>
  20. <u--textarea v-model="value1" placeholder="输入要举报的内容,10-300字" count maxlength='300'></u--textarea>
  21. <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
  22. name="1" multiple :maxCount="9"></u-upload>
  23. </view>
  24. <view class="row3" @click="$u.throttle(submit(), 1000)">提交</view>
  25. <u-picker :show="isShow" ref="uPicker" :columns="orderList" keyName="orderNo" @confirm="confirmorder"
  26. :closeOnClickOverlay='true' @close='isShow=false' @cancel='isShow=false'>
  27. </u-picker>
  28. <u-toast ref="uToast"></u-toast>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. mapState
  34. } from 'vuex';
  35. import permision from "@/js_sdk/wa-permission/permission.js"
  36. import uploadImage from '@/components/ossutil/uploadFile.js';
  37. export default {
  38. data() {
  39. return {
  40. imgList: [],
  41. value1: '',
  42. fileList1: [],
  43. orderList: [],
  44. dataDetails: {},
  45. isShow: false,
  46. };
  47. },
  48. computed: {
  49. ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
  50. },
  51. onLoad(options) {
  52. this.get_camera_permission()
  53. this.dataDetails = JSON.parse(options.val)
  54. console.log(this.dataDetails)
  55. this.imgList = []
  56. },
  57. onShow() {
  58. uni.showLoading({
  59. title: '加载中'
  60. })
  61. this.$request.baseRequest('get', '/orderInfo/getAssociatedOrder', {
  62. commonId: this.dataDetails.commonId,
  63. cargoCommonId: this.userInfo.id
  64. }).then(res => {
  65. uni.hideLoading()
  66. this.orderList = [res.data]
  67. // console.log(this.orderList)
  68. })
  69. .catch(res => {
  70. uni.$u.toast(res.message);
  71. });
  72. },
  73. methods: {
  74. confirmorder(e) {
  75. console.log(e)
  76. this.dataDetails.orderId = e.value[0].id
  77. this.dataDetails.orderNo = e.value[0].orderNo
  78. this.isShow = false
  79. },
  80. selectorder() {
  81. this.isShow = true
  82. },
  83. async get_camera_permission() {
  84. var photol = await permision.requestAndroidPermission("android.permission.CAMERA")
  85. if (photol == false) {
  86. uni.showModal({
  87. title: '提示',
  88. content: '您已经关闭相机权限,去设置',
  89. success: function(res) {
  90. if (res.confirm) {
  91. permision.gotoAppPermissionSetting()
  92. // plus.runtime.openURL("app-settings:");
  93. } else if (res.cancel) {
  94. console.log('用户点击取消');
  95. }
  96. }
  97. });
  98. }
  99. },
  100. submit() {
  101. var that = this
  102. if (!this.value1) {
  103. that.$refs.uToast.show({
  104. type: 'error',
  105. message: "举报信息不能为空!",
  106. })
  107. return
  108. }
  109. if (this.value1.length < 10 || this.value1.length > 300) {
  110. that.$refs.uToast.show({
  111. type: 'error',
  112. message: "举报信息输入错误!",
  113. })
  114. return
  115. }
  116. uni.showLoading({
  117. title: '加载中'
  118. })
  119. this.$request.baseRequest('post', '/feedbackReport/api/addInfo', {
  120. initiator: uni.getStorageSync("firstAuthentication").name,
  121. initiatorNumber: uni.getStorageSync("firstAuthentication").phone,
  122. commonId: this.userInfo.id,
  123. passive: this.dataDetails.driverName,
  124. passiveNumber: this.dataDetails.driverPhone,
  125. orderId: this.dataDetails.orderId,
  126. orderNo: this.dataDetails.orderNo,
  127. passiveCommonId: this.dataDetails.commonId,
  128. content: this.value1,
  129. url: this.imgList.toString(),
  130. flag: 2,
  131. objectFlag: 1,
  132. }).then(res => {
  133. let that = this
  134. uni.hideLoading()
  135. this.$refs.uToast.show({
  136. type: 'success',
  137. message: "举报成功",
  138. complete() {
  139. uni.$u.route('/pages/order/driverDetail', {
  140. driver: JSON.stringify(that.dataDetails)
  141. });
  142. }
  143. })
  144. })
  145. .catch(res => {
  146. uni.$u.toast(res.message);
  147. });
  148. },
  149. // 删除图片
  150. deletePic(event) {
  151. this[`fileList${event.name}`].splice(event.index, 1)
  152. },
  153. // 新增图片
  154. async afterRead(event) {
  155. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  156. let lists = [].concat(event.file)
  157. let fileListLen = this[`fileList${event.name}`].length
  158. lists.map((item) => {
  159. this[`fileList${event.name}`].push({
  160. ...item,
  161. status: 'uploading',
  162. message: '上传中'
  163. })
  164. })
  165. for (let i = 0; i < lists.length; i++) {
  166. const result = await this.uploadFilePromise(lists[i].url)
  167. let item = this[`fileList${event.name}`][fileListLen]
  168. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  169. status: 'success',
  170. message: '',
  171. url: result
  172. }))
  173. fileListLen++
  174. }
  175. },
  176. uploadFilePromise(url) {
  177. uploadImage('image', url, 'appData/',
  178. result => {
  179. // 上传成功回调函数
  180. console.log('图片地址', result)
  181. this.imgList.push(result)
  182. }
  183. )
  184. },
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. .content {
  190. background: white;
  191. }
  192. .img {
  193. width: 40rpx;
  194. }
  195. .row1,
  196. .row2 {
  197. padding: 40rpx;
  198. }
  199. .title {
  200. margin-bottom: 20rpx;
  201. }
  202. .row3 {
  203. width: 80%;
  204. background: #F5BA3C;
  205. text-align: center;
  206. color: white;
  207. padding: 20rpx;
  208. margin: auto;
  209. border-radius: 10rpx;
  210. }
  211. </style>