<template>  
 | 
    <view class="main_app">  
 | 
        <view class="list">  
 | 
            <view class="item">  
 | 
                <view class="la">位置</view>  
 | 
                <view class="line input_wrap">  
 | 
                    <input type="text" v-model="param.position" :maxlength="50" placeholder="请输入发现问题的详细位置" placeholder-class="placeholder9" />  
 | 
                </view>  
 | 
            </view>  
 | 
            <view class="item">  
 | 
                <view class="la"><text class="red">*</text>描述</view>  
 | 
                <view class="line">  
 | 
                    <textarea :maxlength="300" v-model="param.content" placeholder="请详细描述现场情况,便于工作人员及时处理" placeholder-class="placeholder9" />  
 | 
                </view>  
 | 
            </view>  
 | 
            <view class="item">  
 | 
                <view class="la">现场照片</view>  
 | 
                <view class="upload_wrap">  
 | 
                    <view class="upload_file" @click="showUpload = true">  
 | 
                        <u-icon name="plus" color="rgb(153, 153, 153)" size="28"></u-icon>  
 | 
                        <view class="mt6">图片/视频</view>  
 | 
                    </view>  
 | 
                    <view class="upload_file" v-for="(item, i) in fileList" :key="i">  
 | 
                        <u-icon class="close" size="20" name="close-circle-fill" color="red"  
 | 
                            @click="fileDel('fileList', i)"></u-icon>  
 | 
                        <image v-if="item.type == 0" :src="item.fileurlFull" mode="widthFix"></image>  
 | 
                        <video v-if="item.type == 1" :show-center-play-btn="false" :src="item.fileurlFull" :controls="false"></video>  
 | 
                    </view>  
 | 
                </view>  
 | 
            </view> 
 | 
            <view class="item"> 
 | 
                <view class="la"><text class="red">*</text>上报人</view> 
 | 
                <view class="line input_wrap"> 
 | 
                    <input v-model="param.name" type="text" :maxlength="10" placeholder="请输入" placeholder-class="placeholder9" /> 
 | 
                </view> 
 | 
            </view> 
 | 
            <view class="item"> 
 | 
                <view class="la"><text class="red">*</text>上报人电话</view> 
 | 
                <view class="line input_wrap"> 
 | 
                    <input v-model="param.phone" type="tel" :maxlength="18" placeholder="请输入" placeholder-class="placeholder9" /> 
 | 
                </view> 
 | 
            </view>  
 | 
        </view>  
 | 
        <view class="sub_btn" @click="onSubmit">提交</view>  
 | 
        <!--  -->  
 | 
        <u-popup :show="showUpload" @close="showUpload = false" closeOnClickOverlay>  
 | 
            <view class="sel_upload_wrap">  
 | 
                <view class="btn" @click="uploadImage">选择图片</view>  
 | 
                <view class="btn" @click="uploadVideo">选择视频</view>  
 | 
            </view>  
 | 
        </u-popup>  
 | 
        <!--  -->  
 | 
  
 | 
    </view>  
 | 
</template>  
 | 
  
 | 
<script>  
 | 
    import {  
 | 
        uploadUrl,  
 | 
        ywProblemCreate,  
 | 
    } from '@/api'  
 | 
    import dayjs from 'dayjs';  
 | 
    export default {  
 | 
        data() {  
 | 
            return {  
 | 
                param: {},  
 | 
                showUpload: false,  
 | 
                fileList: [],  
 | 
  
 | 
            };  
 | 
        },  
 | 
        onLoad() {  
 | 
        },  
 | 
        methods: {  
 | 
            onSubmit() {  
 | 
                const {  
 | 
                    param,  
 | 
                    fileList  
 | 
                } = this 
 | 
                if (!param.content) return this.showToast('请输入现场情况描述') 
 | 
                if (!param.name) return this.showToast('请输入上报人姓名') 
 | 
                if (!param.phone) return this.showToast('请输入上报人电话')  
 | 
                ywProblemCreate({  
 | 
                    ...param,  
 | 
                    fileList  
 | 
                }).then(res => {  
 | 
                    this.showToast('提交成功')  
 | 
                    this.param = {} 
 | 
                    uni.navigateTo({ 
 | 
                        url: '/pages/workOrder/result' 
 | 
                    })  
 | 
                })  
 | 
            },  
 | 
            fileDel(str, i) {  
 | 
                this[str].splice(i, 1);  
 | 
            },  
 | 
            uploadImage() {  
 | 
                this.showUpload = false;  
 | 
                let token = uni.getStorageSync('token') || '';  
 | 
                uni.chooseImage({  
 | 
                    count: 6,  
 | 
                    success: chooseImageRes => {  
 | 
                        uni.showLoading({  
 | 
                            title: '上传中',  
 | 
                            mask: true  
 | 
                        });  
 | 
                        const tempFilePaths = chooseImageRes.tempFilePaths;  
 | 
                        let imgs = tempFilePaths.map((value, index) => {  
 | 
                            return {  
 | 
                                name: 'file',  
 | 
                                uri: value  
 | 
                            };  
 | 
                        });  
 | 
                        uni.uploadFile({  
 | 
                            url: `${uploadUrl}`,  
 | 
                            files: imgs,  
 | 
                            name: 'file',  
 | 
                            formData: {  
 | 
                                folder: 'YW_WORKORDER_FILE'  
 | 
                            },  
 | 
                            header: {  
 | 
                                Dm_user_token: token  
 | 
                            },  
 | 
                            success: uploadFileRes => {  
 | 
                                let res = JSON.parse(uploadFileRes.data);  
 | 
                                if (res.data && res.data.length > 0) {  
 | 
                                    res.data.forEach(i => {  
 | 
                                        i.type = 0;  
 | 
                                        i.fileurl = i.imgaddr;  
 | 
                                        i.fileurlFull = i.url; 
 | 
                                        if(this.fileList.length < 9){ 
 | 
                                            this.fileList.push(i); 
 | 
                                        }  
 | 
                                    });  
 | 
                                }  
 | 
                            },  
 | 
                            fail(err) {  
 | 
                                console.log('err', err);  
 | 
                            },  
 | 
                            complete() {  
 | 
                                uni.hideLoading();  
 | 
                                // if (i === chooseImageRes.tempFilePaths.length - 1) {  
 | 
                                //   uni.hideLoading()  
 | 
                                // }  
 | 
                            }  
 | 
                        });  
 | 
                    }  
 | 
                });  
 | 
            },  
 | 
            uploadVideo() {  
 | 
                this.showUpload = false;  
 | 
                let token = uni.getStorageSync('token') || '';  
 | 
                uni.chooseVideo({  
 | 
                    success: chooseImageRes => {  
 | 
                        uni.showLoading({  
 | 
                            title: '上传中',  
 | 
                            mask: true  
 | 
                        });  
 | 
                        uni.uploadFile({  
 | 
                            url: `${uploadUrl}`,  
 | 
                            filePath: chooseImageRes.tempFilePath,  
 | 
                            header: {  
 | 
                                Dm_user_token: token  
 | 
                            },  
 | 
                            name: 'file',  
 | 
                            formData: {  
 | 
                                folder: 'YW_WORKORDER_FILE'  
 | 
                            },  
 | 
                            success: uploadFileRes => {  
 | 
                                let res = JSON.parse(uploadFileRes.data);  
 | 
                                if (res.data && res.data.length > 0) {  
 | 
                                    res.data.forEach(i => {  
 | 
                                        i.type = 1;  
 | 
                                        i.fileurl = i.imgaddr;  
 | 
                                        i.fileurlFull = i.url;  
 | 
                                        if(this.fileList.length < 9){ 
 | 
                                            this.fileList.push(i); 
 | 
                                        }  
 | 
                                    });  
 | 
                                }  
 | 
                            },  
 | 
                            complete() {  
 | 
                                uni.hideLoading();  
 | 
                            }  
 | 
                        });  
 | 
                    }  
 | 
                });  
 | 
            }  
 | 
        }  
 | 
    }  
 | 
</script>  
 | 
  
 | 
<style lang="scss" scoped>  
 | 
    .list {  
 | 
  
 | 
        .item {  
 | 
            .la {  
 | 
                margin-top: 30rpx;  
 | 
            }  
 | 
  
 | 
            .line {  
 | 
  
 | 
                textarea {  
 | 
                    box-sizing: border-box;  
 | 
                    width: 690rpx;  
 | 
                    height: 200rpx;  
 | 
                    background-color: #f7f7f7;  
 | 
                    font-size: 28rpx;  
 | 
                    color: #333333;  
 | 
                    padding: 24rpx;  
 | 
                    border-radius: 8rpx;  
 | 
                    margin-bottom: 30rpx;  
 | 
                    margin-top: 20rpx;  
 | 
                }  
 | 
            }  
 | 
  
 | 
            .sel_wrap {  
 | 
                height: 90rpx;  
 | 
                display: flex;  
 | 
                justify-content: space-between;  
 | 
                align-items: center;  
 | 
                border-bottom: 1rpx solid #E5E5E5;  
 | 
            } 
 | 
            .input_wrap{ 
 | 
                width: 100%; 
 | 
                height: 90rpx; 
 | 
                display: flex; 
 | 
                align-items: center; 
 | 
                border-bottom: 1rpx solid #e5e5e5; 
 | 
                input{ 
 | 
                    width: 100%; 
 | 
                } 
 | 
            }  
 | 
  
 | 
            .upload_wrap {  
 | 
                display: flex;  
 | 
                flex-wrap: wrap;  
 | 
                margin-bottom: 30rpx;  
 | 
            }  
 | 
  
 | 
            .upload_file {  
 | 
                margin-top: 24rpx;  
 | 
                width: 156rpx;  
 | 
                height: 156rpx;  
 | 
                margin-right: 20rpx;  
 | 
                border: 2rpx solid #e5e5e5;  
 | 
                background: #f7f7f7;  
 | 
                color: #666666;  
 | 
                font-size: 22rpx;  
 | 
                display: flex;  
 | 
                flex-direction: column;  
 | 
                align-items: center;  
 | 
                justify-content: center;  
 | 
                position: relative;  
 | 
  
 | 
                &:nth-of-type(4n) {  
 | 
                    margin-right: 0;  
 | 
                }  
 | 
  
 | 
                .close {  
 | 
                    position: absolute;  
 | 
                    right: -20rpx;  
 | 
                    top: -20rpx;  
 | 
                    z-index: 9999; 
 | 
                    background-color: #fff; 
 | 
                    border-radius: 50%; 
 | 
                    overflow: hidden;  
 | 
                }  
 | 
  
 | 
                image {  
 | 
                    width: 100%;  
 | 
                    height: 100%;  
 | 
                }  
 | 
  
 | 
                video {  
 | 
                    width: 100%;  
 | 
                    height: 100%;  
 | 
                }  
 | 
            }  
 | 
  
 | 
        }  
 | 
    }  
 | 
  
 | 
    .sub_btn {  
 | 
        // position: fixed;  
 | 
        // bottom: 68rpx;  
 | 
        // left: 40rpx;  
 | 
        width: 670rpx;  
 | 
        height: 88rpx; 
 | 
        margin-top: 80rpx;  
 | 
        background: $primaryColor;  
 | 
        box-shadow: 0rpx 8rpx 20rpx 0rpx rgba(0, 104, 255, 0.3);  
 | 
        border-radius: 44rpx;  
 | 
        display: flex;  
 | 
        align-items: center;  
 | 
        justify-content: center;  
 | 
        font-weight: 500;  
 | 
        font-size: 32rpx;  
 | 
        color: #FFFFFF;  
 | 
    }  
 | 
  
 | 
    .sel_upload_wrap {  
 | 
        width: 100%;  
 | 
        border-top: 1px solid #666666;  
 | 
        box-shadow: 0 1 1 #333333;  
 | 
  
 | 
        .btn {  
 | 
            height: 90rpx;  
 | 
            line-height: 90rpx;  
 | 
            text-align: center;  
 | 
        }  
 | 
    }  
 | 
</style> 
 |