<template>
    <view>
        <view class="images">
            <!-- <Upload :maxCount="1" @fileList="onUpload($event, 'cImgList')" /> -->
            <Upload  :accept="title == '宣传视频'?'file':'image'" :maxSize="title == '宣传视频'?51200:10240"  :maxCount="maxCount" :customImg="true" :width="'70'" :height="'70'"
                :src="'/static/points/picture2.png'" @fileList="onUpload" :fileList="fileList" />
            <view class="tagText" v-if="title == '生活照'">简单介绍自己的生活照，可以说说自己的基本信息，工作场景，等等;
                或者上传自己清晰露脸半身照/全身照/工作照。最多上传{{ maxCount }}张</view>
            <view class="tagText" v-if="title == '宣传视频'">请上传 大小不超过 50MB 格式为 mp4/mov/mkv/wmv 的文件</view>
            <view class="tagText" v-if="title == '健康证' || title =='从业资格证' || title =='无犯罪证明'">请上传小于10MB的{{ title }}图片，最多上传{{ maxCount }}张
            </view>


            <view class="footer-bar">
                <u-button shape="circle" :customStyle="{
                    color: '#fff',
                    background: 'var(--theme-color-gradient)'
                }" @click="onSubmit">确认修改</u-button>
            </view>
        </view>
    </view>
</template>

<script>

import Upload from '@/components/upload/index.vue';

export default {
    components: { Upload },
    data() {
        return {
            fileList: [],
            fieldName: '',
            maxCount: 9,
            title: '',
        }
    },

    onLoad(query) {
        console.log(query)
        if (query.fieldName) this.fieldName = query.fieldName
        if (query.fieldVal) this.fileList = JSON.parse(query.fieldVal)
        if (query.maxlength) this.maxlength = Number(query.maxlength)
        if (query.title) this.title = query.title
        // console.log(this.fileList, 'query')
        // console.log(this.fileList, 'query')
        // console.log(this.maxlength, 'query')
        // console.log(this.title, 'query')
    },
    onReady() {
        // 页面渲染完成后再设置标题
        uni.setNavigationBarTitle({
            title: this.title
        })
    },
    onShow() {
    },
    methods: {

        // upload事件
        onUpload(e) {
            this.fileList = e
        },
        goBack() {
            uni.navigateBack()
        },
        onSubmit() {
            // 获取页面栈
            const pages = getCurrentPages()
            // 上一页实例
            const prevPage = pages[pages.length - 2]
            // 直接修改上一页data里的字段
            prevPage.$data.baseInfo[this.fieldName] = this.fileList
            uni.navigateBack()
        }

    }
}
</script>

<style scoped lang="scss">
.u-cell-group {
    padding: 30rpx;
}
</style>
