<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" scope="request"/>
<c:set var="resourcePath" value="${ctx}/resources" scope="request"/>

<form class="layui-form" id="form3" action="">
    <input type="hidden" name="userId" value="${merchantBaseInfo.userId}"/>
    <input type="hidden" name="merchantCode" value="${merchantBaseInfo.merchantCode}"/>
    <input type="hidden" id="merchantType" name="merchantBaseInfo.merchantType"
           value="${merchantBaseInfo.merchantType}"/>
    <input type="hidden" name="certName" value="${priceIdCard.certName}"/>
    <div class="layui-form-item">
        <div class="layui-col-md12" style="clear:both">
            <div class="layui-inline">
                <div class="layui-form-label">法人姓名</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="营业执照名称"
                           class="layui-input"
                           value="${merchantBaseInfo.principalPerson }" id="principalPerson"
                           name="merchantBaseInfo.principalPerson"/>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-form-label">法人身份证号</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="法人身份证号"
                           class="layui-input"
                           value="${priceIdCard.certNo}" id="priceIdCard.certNo"
                           name="certNo"/>
                </div>
            </div>
        </div>

        <div class="layui-col-md12" style="clear:both">
            <div class="layui-inline">
                <div class="layui-form-label">身份证发放日期</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="营业执照名称"
                           class="layui-input"
                           value="${priceIdCard.certStartTime }" id="priceIdCard.certStartTime"
                           name="certStartTime"/>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-form-label">身份证截止日期</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="法人身份证号"
                           class="layui-input"
                           value="${priceIdCard.certEndTime}" id="priceIdCard.certEndTime"
                           name="certEndTime"/>
                </div>
            </div>
        </div>

        <div class="layui-col-md12" style="clear:both">
            <div class="layui-inline">
                <div class="layui-form-label">执照名称</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="营业执照名称"
                           class="layui-input"
                           value="${merchantBaseInfo.bussAuthName }" id="bussAuthName"
                           name="merchantBaseInfo.bussAuthName"/>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-form-label">工商注册号</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="工商注册号"
                           class="layui-input"
                           value="${merchantBaseInfo.bussAuthNum}" id="bussAuthNum"
                           name="merchantBaseInfo.bussAuthNum"/>
                </div>
            </div>
        </div>

        <div class="layui-col-md12" style="clear:both">
            <div class="layui-inline">
                <div class="layui-form-label">开始时间</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="营业执照下发时间"
                           class="layui-input"
                           value="${merchantBaseInfo.bussAuthStartTime }"
                           name="merchantBaseInfo.bussAuthStartTime"/>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-form-label">结束时间</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="营业执照失效时间"
                           class="layui-input"
                           value="${merchantBaseInfo.bussAuthEndTime }"
                           name="merchantBaseInfo.bussAuthEndTime"/>
                </div>
            </div>
        </div>

        <div class="layui-col-md12" style="clear:both">
            <div class="layui-inline">
                <div class="layui-form-label">注册地址</div>
                <div class="layui-input-inline" style="width: 400px">
                <textarea placeholder="注册地址"
                          class="layui-textarea"
                          name="merchantBaseInfo.bussAuthAddress">${merchantBaseInfo.bussAuthAddress}</textarea>
                </div>
            </div>
        </div>

        <div class="layui-col-md12" style="clear:both">
            <ul>
                <li class="fl pt10 pb10 layui-col-md4 layui-col-xs12 layui-col-sm4" data-v="09" data-t="store"
                    data-value="${merchantImage3}">
                    <div>营业执照照片</div>
                    <div class="dlblock upload w200 h200 mt10">
                        <input name="picUrl3" hidden/>
                        <img id="picUrl3" src="${merchantImage3}" referrer="no-referrer|origin|unsafe-url"
                             onerror="this.src='${resourcePath }/images/error.jpg'"
                             width="200" height="200"/>
                        <div class="cover"
                             style="background: rgba(0, 0, 0, 0.6);
                                 height:200px;
                                 width:200px;
                                 position:absolute;
                                 margin-top: -200px;
                                 ">
                            <div style="margin-top: 90px;">
                                <div class="u-icon icon1" onclick="magnify('picUrl3')"><i
                                        class="layui-icon layui-icon-search"></i></div>
                                <div class="u-icon icon2 upload_icon"><i class="layui-icon layui-icon-edit"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
                <li class="fl pt10 pb10 layui-col-md4 layui-col-xs12 layui-col-sm4" data-v="06" data-t="store"
                    data-value="${idCard.id}">
                    <div>法人身份证正面</div>
                    <div class="dlblock upload w200 h200 mt10">
                        <input name="picUrl1" hidden/>
                        <img id="imgLegalPositive1" src="${merchantImage1}"
                             referrer="no-referrer|origin|unsafe-url"
                             onerror="this.src='${resourcePath }/images/error.jpg'"
                             width="200" height="200">
                        <div class="cover"
                             style="background: rgba(0, 0, 0, 0.6);
                                 height:200px;
                                 width:200px;
                                 position:absolute;
                                 margin-top: -200px;
                                 ">
                            <div style="margin-top: 90px;">
                                <div class="u-icon icon1" onclick="magnify('imgLegalPositive1')"><i
                                        class="layui-icon layui-icon-search"></i></div>
                                <div class="u-icon icon2 upload_icon"><i class="layui-icon layui-icon-edit"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
                <li class="fl pt10 pb10 layui-col-md4 layui-col-xs12 layui-col-sm4" data-v="08" data-t="store"
                    data-value="${idCard.id}">
                    <div>法人身份证反面</div>
                    <div class="dlblock upload w200 h200 mt10">
                        <input name="picUrl2" hidden/>
                        <img id="imgLegalNegative2" src="${merchantImage2}"
                             onerror="this.src='${resourcePath }/images/error.jpg'"
                             width="200" height="200">
                        <div class="cover"
                             style="background: rgba(0, 0, 0, 0.6);
                                 height:200px;
                                 width:200px;
                                 position:absolute;
                                 margin-top: -200px;
                                 ">
                            <div style="margin-top: 90px;">
                                <div class="u-icon icon1" onclick="magnify('imgLegalNegative2')">
                                    <i class="layui-icon layui-icon-search"></i>
                                </div>
                                <div class="u-icon icon2 upload_icon">
                                    <i class="layui-icon layui-icon-edit"></i>
                                </div>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>


    <br/>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo3">立即提交</button>
        </div>
    </div>
</form>

<script>

    $(function () {
        form.render();

        merchLicenseLoading = 1;
        baseSet()
    });

    /*提交营业执照信息*/
    form.on('submit(formDemo3)', function (data) {
        var index = layer.load(1, {shade: [0.1, '#000']});
        $.ajax({
            url: ctx + '/promoter/updateMerchantLicense',
            method: 'post',
            data: data.field,
            dataType: 'JSON',
            success: function (res) {
                layer.close(index);
                if (res.code == 200) {
                    /*layer.alert(res.data, function () {
                        parent.location.reload();
                        layer.msg(res.message, {
                            icon: 1
                        });
                    })*/

                    layer.alert(res.message, function (index) {
                        //do something

                        layer.close(index);
                    });

                    layer.confirm(res.message, {
                        icon: 1
                    });
                } else {
                    layer.alert(res.message, function (index) {
                        //do something

                        layer.close(index);
                    });
                }
            }
        })
        return false;
    });

</script>