<template>
    <view class="applyJoin">
        <view>
            <view> 基本信息</view>
            <uni-list>
                <uni-list-item title="姓名" :rightText="baseInfo.name" />
                <uni-list-item title="性别" :rightText="baseInfo.name" />
                <uni-list-item title="手机号" :rightText="baseInfo.name" />
                <uni-list-item title="昵称" :rightText="baseInfo.name" />
                <uni-list-item title="入驻城市" :rightText="baseInfo.name" />
                <uni-list-item showArrow title="简介" clickable @click="introduceYourselfEdit(baseInfo.introduceYourself)"
                    :rightText="baseInfo.introduceYourself ? baseInfo.introduceYourself : '简单的介绍您自己~'" />
            </uni-list>
        </view>
        <view>
            <view> 入驻资料</view>
            <uni-list>

                <uni-list-item title="形象照" showArrow clickable @click="portraitPhotoFun">
                    <template v-slot:footer>
                        <image class="slot-image" :src="baseInfo.portraitPhoto?baseInfo.portraitPhoto:'/static/logo.png'" mode="widthFix"></image>
                    </template>
                </uni-list-item>
                <uni-list-item showArrow title="生活照" :rightText="baseInfo.cImgList.length > 0 ? '已上传' : '去上传'" clickable
                    @click="pictureUpLoad('cImgList', '生活照', 9)" />
                <uni-list-item showArrow title="宣传视频" :rightText="baseInfo.promotionalVideo.length > 0 ? '已上传' : '去上传'"
                    clickable @click="pictureUpLoad('promotionalVideo', '宣传视频')" />

                <uni-list-item showArrow title="身份证" :rightText="baseInfo.idCard.length > 2 ? '已上传' : '去上传'" clickable
                    @click="idCardEditFun('idCard')" />

                <uni-list-item showArrow title="健康证" :rightText="baseInfo.healthCertificate.length > 0 ? '已上传' : '去上传'"
                    clickable @click="pictureUpLoad('healthCertificate', '健康证', 3)" />
                <uni-list-item showArrow title="从业资格证" :rightText="baseInfo.certification.length > 0 ? '已上传' : '去上传'"
                    clickable @click="pictureUpLoad('certification', '从业资格证', 3)" />
                <uni-list-item showArrow title="无犯罪证明" :rightText="baseInfo.noCrime.length > 0 ? '已上传' : '去上传'"
                    clickable @click="pictureUpLoad('noCrime', '无犯罪证明', 9)" />

                <uni-list-item showArrow title="承诺文件" :rightText="baseInfo.commitDocment[0].length > 0 && baseInfo.commitDocment[1].length > 0 && baseInfo.commitDocment[2].length > 0
                ? '已上传' : '去上传'" clickable @click="commitDocmentEditFun('commitDocment')" />

            </uni-list>
        </view>




        <!-- 提交按钮 pages/join/introduceYourselfEdit-->
        <view class="submit-box">
            <u-button type="primary" disabled block @click="submitForm">提交</u-button>
        </view>

    </view>
</template>

<script>
export default {

    data() {
        return {
            // 任务数据
            tasks: [
                { taskName: '222' }
            ],
            baseInfo: {
                portraitPhoto:'',
                name: '萧然然',
                gender: '女',
                phone: '18366668888',
                nickName: '苒苒',
                city: '朝阳区',
                intro: '',
                avatar: '',
                lifeImg: [],
                idCard: '',
                introduceYourself: '',
                cImgList: [],
                healthCertificate: [],
                certification: [],
                noCrime: [],
                promotionalVideo: [],
                idCard: [],
                commitDocment: [[],[],[]],
            }

        }
    },
    onLoad() {
    },
    onShow() {
    },
    methods: {
        commitDocmentEditFun(value) {
            let str = uni.$u.queryParams({
                fieldName: value,
                fieldVal: JSON.stringify(this.baseInfo[value])
            })
            uni.navigateTo({ url: `/pages/join/commitDocumentEdit${str}` })
        },
        idCardEditFun(value) {
            let str = uni.$u.queryParams({
                fieldName: value,
                fieldVal: JSON.stringify(this.baseInfo[value])
            })
            uni.navigateTo({ url: `/pages/join/idCardEdit${str}` })
        },
        pictureUpLoad(value, title, maxlength) {
            let str = uni.$u.queryParams({
                fieldName: value,
                fieldVal: JSON.stringify(this.baseInfo[value]),
                title: title,
                maxlength: maxlength
            })
            console.log(str)
            uni.navigateTo({ url: `/pages/join/lifePhotosEdit${str}` })

        },
        //简介
        introduceYourselfEdit() {
            uni.navigateTo({ url: '/pages/join/introduceYourselfEdit?introduceYourself=' + this.baseInfo.introduceYourself })
        },
        portraitPhotoFun() {
            // const perResult = requestAndroidPermission('android.permission.CAMERA', {
            //     title: '相册/相机权限申请说明',
            //     content: '为了修改个人头像和订单评价发布信息图片视频等, 我们需要申请您设备的相机和存储权限',
            // }, true);
            console.log('8888888')
            uni.chooseImage({
                count: 1,
                sizeType: ['original', 'compressed'],
                sourceType: ['album'],
                success: (res) => {
                    if (res) {
                        this.baseInfo.portraitPhoto=res.tempFilePaths[0]
                    }
                }
            });
        },

        // 提交表单
        submitForm() {
            // 接口请求提交入驻资料
            console.log('提交入驻', this.form)
        }
    },
    mounted() {


    }
}
</script>

<style lang="scss" scoped>
.applyJoin {
    background-color: #f5f5f5;
    min-height: 100vh;
    padding: 20rpx 0;

    .slot-box {
        /* #ifndef APP-NVUE */
        display: flex;
        /* #endif */
        flex-direction: row;
        align-items: center;
    }

    .slot-image {
        /* #ifndef APP-NVUE */
        display: block;
        /* #endif */
        margin-right: 10px;
        width: 30px;
        height: 30px;
    }

    .slot-text {
        flex: 1;
        font-size: 14px;
        color: #4cd964;
        margin-right: 10px;
    }

    .submit-box {
        padding: 30rpx;
    }
}
</style>