<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('待审核')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>

<body class="white-bg">
<div class="detail_status">用户状态：<span></span></div>
<p class="detail_title">基础资料</p>
<p>照片</p>
<div class="detail_inner detail_img"><img style="height: 120px;" src=""></div>
<p>真实姓名</p>
<div class="detail_inner detail_name"></div>
<p>出生日期</p>
<div class="detail_inner detail_time"></div>
<p>性别</p>
<div class="detail_inner detail_sex"></div>
<p>所在城市</p>
<div class="detail_inner detail_city"></div>
<p>你的身份</p>
<div class="detail_inner detail_id"></div>
<p>在读学校全称/毕业院校名称</p>
<div class="detail_inner detail_school"></div>
<p>所学专业</p>
<div class="detail_inner detail_acc"></div>
<!--<p>微信号</p>-->
<!--<div class="detail_inner detail_wx"></div>-->
<p class="detail_title">认证信息</p>
<p>姓名：</p>
<div class="detail_inner detail_name"></div>
<p>身份证号：</p>
<div class="detail_inner detail_idcode"></div>
<p class="detail_title">自我介绍</p>
<div class="detail_inner detail_desc"></div>
<p class="detail_title">个人技能(选填)</p>
<div class="detail_inner detail_desc1"></div>
<div class="detail_inner detail_desc2"></div>
<div class="detail_inner detail_desc3"></div>
<p>手机号：</p>
<div class="detail_inner detail_mobail"></div>
<!--<p>提交时间：</p>-->
<!--<div class="detail_inner detail_created"></div>-->
<div class="bottomBtn" id="btn-commit">
    <a href="javascript:" class="a-success layui-layer-btn0" onclick="yes(1)">通过</a>
    <a class="layui-layer-btn1 layui-layer-btn1 a-fail" onclick="closeModal(0)">驳回</a>
</div>


<div id="addClassify">
    <div class="selectClassify">
        <div class="ibox-content">
            <div class="form-group">
                <p>选择身份</p>
                <input class="idst_radio" name="idst" type="radio" value="1">总代
                <input class="idst_radio" name="idst" type="radio" value="2">普代
            </div>
            <div class="form-group">
                <select name="bindType" id="selectTwo" placeholder="请选择分组"></select>
            </div>
        </div>
    </div>
    <input type="hidden" class="editCon">
    <div class="bottomBtn">
        <a href="javascript:;" class="layui-layer-btn0" onclick="confirm(1)">确认通过</a>
    </div>
</div>


<div id="addClassify_false">
    <div class="selectClassify">
        <div class="ibox-content">
            <div class="form-group">
                <span class="require-false">*</span>
                <input class="reason_text" type="textarea" placeholder="请输入驳回原因">
            </div>
            <p class="requireFalseText"></p>
        </div>
    </div>
    <input type="hidden" class="editCon">
    <div class="bottomBtn">
        <a href="javascript:;" class="layui-layer-btn0" onclick="confirm(0)">驳回</a>
    </div>
</div>
</body>

<th:block th:include="include :: footer"/>
<script th:src="@{/js/jquery.tmpl.js}"></script>
<th:block th:include="include :: bootstrap-fileinput-js"/>

<script type="text/javascript">
    var smilePrefix = ctx + "smile/user";
    var orifix = ctx + "smile/organization";
    // var penddingId = window.localStorage.getItem('penddingId');

    let _uid = getUrlParms('id');

    var detailObj = {}
    $.ajax({
        type: 'post',
        url: smilePrefix + "/getUserById",
        data: {
            uid: _uid
        },
        success: function (e) {
            var detailData = e.data;
            detailObj = detailData;
            if (detailData.type == 0) {
                $('.detail_status span').text('未认证');
            }
            $('.detail_img img').attr('src', detailData.img);
            $('.detail_name').text(detailData.name);
            $('.detail_time').text(detailData.birthday);
            if (detailData.sex == 1) {
                $('.detail_sex').text('男');
            } else {
                $('.detail_sex').text('女');
            }
            $('.detail_city').text(detailData.province + detailData.city + detailData.area);
            if (detailData.identity == 1) {
                $('.detail_id').text('在校学生');
            } else {
                $('.detail_id').text('已毕业');
            }
            $('.detail_school').text(detailData.schoolName);
            $('.detail_acc').text(detailData.schoolMajor);
            $('.detail_wx').text(detailData.wechat);
            $('.detail_name').text(detailData.name);
            $('.detail_idcode').text(detailData.idCard);
            $('.detail_desc').text(detailData.introduce);
            $('.detail_desc1').text(detailData.specialty1);
            $('.detail_desc2').text(detailData.specialty2);
            $('.detail_desc3').text(detailData.specialty3);
            $('.detail_mobail').text(detailData.phone);
            $('.detail_created').text(detailData.createdDate);
            if (detailData.type != 0) {
                document.getElementById("btn-commit").style.visibility = "hidden";
            }
            console.log('e', e)
        }
    })

    function getUrlParms(name){
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)
            return unescape(r[2]);
        return null;
    }

    function closeModal() {
        layer.open({
            type: 1,
            shade: 0.3,
            title: '驳回', //不显示标题
            content: $('#addClassify_false') //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
        });
    }

    function confirm(num) {
        if (num == 1) {
            var postData = {
                id: Number(detailObj.id),
                orgId: Number(detailObj.orgId),
                type: Number(detailObj.type),
                uid: detailObj.uid,
            }
        } else { // 驳回
            // 驳回原因必填
            if (!$('.reason_text').val()) {
                $('.requireFalseText').text('驳回原因为必填项！')
                return
            }
            var postData = {
                id: Number(detailObj.id),
                orgId: '',
                type: 4,
                uid: detailObj.uid,
                reason: $('.reason_text').val()
            }
        }

        $('.requireFalseText').text('')
        $.ajax({
            type: 'post',
            url: smilePrefix + "/check/updateById",
            headers: {"Content-Type": "application/json;charset=UTF-8"},
            data: JSON.stringify(postData),
            success: function (e) {
                $(".layui-layer-close1").click();
                alert(e.msg)
                location.reload();
            }
        })

    }

    function yes() {
        layer.open({
            type: 1,
            shade: 0.3,
            title: '通过', //不显示标题
            content: $('#addClassify'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
            success: function () {
                $("input[name=idst]").change(function (e) {
                    detailObj.type = e.target.value;
                    var postData = {
                        pageNum: 40,
                        pageSize: 1
                    }
                    $.ajax({
                        type: 'post',
                        url: orifix + '/list',
                        data: JSON.stringify(postData),
                        success: function (res) {
                            $('#selectTwo').html('');

                            $('#selectTwo').append('<option value="0">请选择</option>');
                            for (var i in res.rows) {
                                $('#selectTwo').append('<option value="' + res.rows[i].id + '">' + res.rows[i].name + '</option>');
                            }
                            $('#selectTwo').change(function () {
                                detailObj.orgId = $('#selectTwo option:selected').val();
                            })
                        }
                    })
                });
            },
            cancel: function (res) {
                // layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', {time: 5000, icon:6});
            }
        });
    }
</script>

<style>
    .white-bg {
        padding: 50px;
    }

    .white-bg .detail_inner {
        margin-bottom: 20px;
    }

    .white-bg .detail_title {
        margin-top: 50px;
        font-weight: bold;
        font-size: 16px;
    }

    .bottomBtn {
        text-align: left;
        padding: 10px 15px 12px;
    }

    #addClassify, #addClassify_false {
        display: none;
        width: 540px;
        padding-top: 20px;
    }

    #addClassify .selectClassify {
        display: flex;
        align-items: center;
        padding: 0 20px;
    }

    #addClassify .selectClassify label {
        display: flex;
        margin-right: 20px;
        align-items: center;
    }

    #addClassify .selectClassify label input {
        margin: 0;
        margin-right: 2px;
    }

    #detailPro .detail_inner {
        margin-bottom: 20px;
    }

    #detailPro .detail_title {
        margin-top: 50px;
        font-weight: bold;
        font-size: 16px;
    }
    .require-false {
        font-size: 20px;
        color: red;
        margin-right: 10px;
        position: relative;
        top: 6px;
    }
    .requireFalseText {
        color: red;
    }
</style>

</html>