123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <view class="content">
- <view class="row1 flex flex-space-between">
- <view>被举报人</view>
- <view class='flex'>
- <image :src="dataDetails.driverPortrait" mode="widthFix" class="img"></image>
- <view>{{dataDetails.cargoOwnerName}}</view>
- </view>
- </view>
- <u-line class="line"></u-line>
- <view class="row2">
- <view class="title">举报信息</view>
- <u--textarea v-model="value1" placeholder="输入要举报的内容,10-300字" count maxlength='300'></u--textarea>
- <u-upload class="uview-upload" :fileList="fileList1" @afterRead="afterRead($event)" @delete="deletePic"
- name="1" multiple :maxCount="9"></u-upload>
- </view>
- <view class="row3" @click="submit">提交</view>
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex';
- import uploadImage from '@/components/ossutil/uploadFile.js';
- export default {
- data() {
- return {
- imgList: [],
- value1: '',
- fileList1: [],
- dataDetails: {},
- };
- },
- computed: {
- ...mapState(['hasLogin', 'userInfo', 'firstAuthentication'])
- },
- onLoad(options) {
- this.dataDetails = JSON.parse(options.val)
- console.log(this.dataDetails)
- this.imgList = []
- },
- methods: {
- submit() {
- uni.showLoading({
- title: '加载中'
- })
- this.$request.baseRequest('post', '/feedbackReport/api/addInfo', {
- commonId: this.userInfo.id,
- name: this.dataDetails.cargoOwnerName,
- content: this.value1,
- url: this.imgList.toString(),
- flag: 2,
- }).then(res => {
- let that = this
- uni.hideLoading()
- this.$refs.uToast.show({
- type: 'success',
- message: "举报成功",
- complete() {
- uni.$u.route('/pages/order/driverDetail', {
- driver: JSON.stringify(that.dataDetails)
- });
- }
- })
- })
- .catch(res => {
- uni.$u.toast(res.message);
- });
- },
- // 删除图片
- deletePic(event) {
- this[`fileList${event.name}`].splice(event.index, 1)
- },
- // 新增图片
- async afterRead(event) {
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- let lists = [].concat(event.file)
- let fileListLen = this[`fileList${event.name}`].length
- lists.map((item) => {
- this[`fileList${event.name}`].push({
- ...item,
- status: 'uploading',
- message: '上传中'
- })
- })
- for (let i = 0; i < lists.length; i++) {
- const result = await this.uploadFilePromise(lists[i].url)
- let item = this[`fileList${event.name}`][fileListLen]
- this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
- status: 'success',
- message: '',
- url: result
- }))
- fileListLen++
- }
- },
- uploadFilePromise(url) {
- uploadImage('image', url, 'appData/',
- result => {
- // 上传成功回调函数
- console.log('图片地址', result)
- this.imgList.push(result)
- }
- )
- },
- }
- }
- </script>
- <style lang="scss">
- .content {
- background: white;
- }
- .img {
- width: 40rpx;
- }
- .row1,
- .row2 {
- padding: 40rpx;
- }
- .title {
- margin-bottom: 20rpx;
- }
- .row3 {
- width: 80%;
- background: #2772FB;
- text-align: center;
- color: white;
- padding: 20rpx;
- margin: auto;
- border-radius: 10rpx;
- }
- </style>
|