<template>
    <view style="height: 100%">
        <custom-nav-bar position="fixed" color="black" left-text="线上问诊" left-arrow />

        <!-- 重新定制封装，可抽离成数组的形式以方便复用，组件化，后续思考，此处逻辑可随时抽离成组件形式 -->
        <view class="form-list">
            <view class="form-item">
                <view class="label">姓名</view>
                <input class="label-input" placeholder="请输入姓名" />
            </view>

            <view class="form-item">
                <view class="label label-must">问诊类型</view>
                <view class="label-select">
                    <picker @change="bindPickerChange" :value="index" :range="array">
                        <view class="label-input">
                            {{ array[index] }}
                        </view>
                    </picker>
                    <image class="ic-xia" src="/static/packages/people/images/ic-xia.png"></image>
                </view>
            </view>

            <view class="form-item form-item-checkbox">
                <view class="label">问诊描述</view>
                <textarea class="label-textarea" placeholder="请输入" auto-height></textarea>
                <view class="label-image">
                    <van-uploader @after-read="handAfterRead" :file-list="fileList" :deletable="true" max-count="9" @delete="handDeleteImg">
                        <image class="label-image-camera" src="/static/images/icon9.png"></image>
                    </van-uploader>
                </view>
                <view class="label-image-msg">为了让家庭医生更好的了解您的情况，您可以上传您的病历或其他信息。</view>
            </view>

            <view class="form-button">
                <van-button @click="handSubmit" block color="#FE3B53">提交</van-button>
            </view>
        </view>
    </view>
</template>

<script>
export default {
    components: {
    },
    data() {
        return {
            array: ['美国', '中国', '巴西', '日本'],
            index: 0,
            fileList: []
        };
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {},
    methods: {
        bindPickerChange() {
            console.log('占位：函数 bindPickerChange 未声明');
        },

        handAfterRead() {
            console.log('占位：函数 handAfterRead 未声明');
        },

        handDeleteImg() {
            console.log('占位：函数 handDeleteImg 未声明');
        },

        handSubmit() {
            console.log('占位：函数 handSubmit 未声明');
        }
    }
};
</script>
<style lang="less">
.form-list {
    .form-item {
        padding: 42rpx 40rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: relative;

        &:nth-of-type(3)::before {
            height: 0;
        }

        &::before {
            content: '';
            position: absolute;
            left: 50%;
            bottom: 0;
            transform: translateX(-50%);
            width: 678rpx;
            height: 1px;
            background-color: #e1e1e1;
        }

        .label-msg {
            content: '';
            position: absolute;
            right: -80rpx;
            top: 2rpx;
            font-size: 24rpx;
            font-weight: 400;
            color: #999999;
            line-height: 24rpx;
        }

        .label {
            position: relative;
            font-size: 28rpx;
            font-weight: 400;
            color: #333333;
            line-height: 28rpx;
            position: relative;
        }

        .label-must::before {
            content: '*';
            position: absolute;
            right: -16rpx;
            top: 0;
            font-size: 28rpx;
            font-weight: 400;
            color: #fe3b53;
            line-height: 32rpx;
        }
    }

    .form-item-checkbox {
        align-items: flex-start;
        flex-direction: column;

        .label {
            // width: 100%;
        }
    }

    .label-image-msg {
        font-size: 24rpx;
        font-weight: 400;
        color: #999999;
        line-height: 32rpx;
    }
}

.label-input {
    flex: 1;
    text-align: right;
    font-size: 32rpx;
    font-weight: 400;
    line-height: 32rpx;
    padding-left: 30rpx;
}

.label-select {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;

    .label-is-select {
    }

    .ic-xia {
        margin-left: 27rpx;
        width: 32rpx;
        height: 32rpx;
    }
}

.label-checkbox {
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    .tag-bth {
        color: #333333;
        padding: 16rpx 32rpx;
        background: #f7faff;
        border-radius: 40rpx;
        border: 1px solid #c5dff4;
        font-size: 28rpx;
        font-weight: 400;
        line-height: 28rpx;
        margin-left: 16rpx;
        margin-top: 24rpx;

        &:first-child {
            margin-left: 0;
        }
    }

    .tag-bth-active {
        color: #0091ff;
    }
}

.label-textarea {
    width: 100%;
    margin-top: 24rpx;
    font-size: 32rpx;
    font-weight: 400;
    line-height: 32rpx;
    text-align: justify;
}

.label-image {
    margin: 32rpx 0rpx 28rpx 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;

    .label-image-camera {
        width: 160rpx;
        height: 160rpx;
    }
}

.form-treaty {
    padding: 37rpx 40rpx 30rpx;
    display: flex;

    .ic-check {
        width: 32rpx;
        height: 32rpx;
    }

    .checbox-text {
        font-size: 28rpx;
        font-weight: 400;
        color: #666666;
        line-height: 46rpx;

        .jump-to {
            display: inline;
            color: #0091ff;
        }
    }

    .van-checkbox__icon-wrap {
        align-self: flex-start;
        padding-top: 8rpx;
    }
}

.form-button {
    margin-top: 160rpx;
    padding: 25rpx 36rpx;
}
</style>
