<%@ 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="form2" action="">
    <input type="hidden" name="userId" value="${merchantBaseInfo.userId}"/>
    <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.merchantName }" id="updateMerchantName"
                           name="merchantBaseInfo.merchantName"/>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-form-label">商户类型</div>
                <div class="layui-input-inline">
                    <c:if test="${ merchantBaseInfo.merchantType=='1'}">
                        <input type="text" readonly="readonly"
                               class="layui-input"
                               value="小微" id="upateRegistName1"/>
                    </c:if>
                    <c:if test="${ merchantBaseInfo.merchantType=='2'}">
                        <input type="text" readonly="readonly"
                               class="layui-input"
                               value="个体" id="upateRegistName2"/>
                    </c:if>
                    <c:if test="${ merchantBaseInfo.merchantType=='3'}">
                        <input type="text" readonly="readonly"
                               class="layui-input"
                               value="企业" id="upateRegistName3"/>
                    </c:if>
                </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.alias }"
                           name="merchantBaseInfo.alias"/>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-form-label">商户联系人</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="联系人姓名"
                           class="layui-input" id="updateContactName"
                           value="${merchantBaseInfo.contactName }"
                           name="merchantBaseInfo.contactName"/>
                </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.email }"
                           name="merchantBaseInfo.email"/>
                </div>
            </div>

            <div class="layui-inline">
                <div class="layui-form-label">联系人电话</div>
                <div class="layui-input-inline">
                    <input type="text" placeholder="联系人电话(作为登录名)"
                           class="layui-input" id="updateContactMobile"
                           value="${merchantBaseInfo.contactMobile }"
                           name="merchantBaseInfo.contactMobile"/>
                </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" id="updateServicealiAccount"
                           value="${merchantBaseInfo.aliAccount }"
                           name="merchantBaseInfo.aliAccount"/>
                </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: 250px;">
                    <select name="merchantBaseInfo.mcc" id="mccCode" lay-search>
                        <option value=""></option>
                        <c:forEach items="${mccList}" var="mcc">
                            <option value="${mcc.fMccCode}" ${checkMcc.fMccCode == mcc.fMccCode ? 'selected' : ''}>${mcc.fMccTxt}[${mcc.fMccCode}]</option>
                        </c:forEach>
                    </select>
                </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">
                    <select id="province" name="merchantBaseInfo.province" class="province-selector"
                            data-dom="city"
                            data-value=" " lay-filter="provinceType">
                        <option value="">请选择省</option>
                        <c:forEach items="${areaCitiesList}" var="acl">>
                            <option value="${acl.areaCode}"
                                    <c:if test="${merchantBaseInfo.province eq acl.areaName }">selected</c:if>>${acl.areaName}
                            </option>
                        </c:forEach>
                    </select>
                </div>

                <div class="layui-input-inline">
                    <select id="city" name="merchantBaseInfo.city" class="city-selector"
                            data-dom="county" data-value=""
                            lay-filter="cityType">
                        <option value="${merchantBaseInfo.city}">${merchantBaseInfo.city}</option>
                    </select>
                </div>

                <div class="layui-input-inline">
                    <select id="county" name="merchantBaseInfo.district" class="county-selector"
                            data-value=""
                            lay-filter="countyType">
                        <option value="${merchantBaseInfo.district}">${merchantBaseInfo.district}</option>
                    </select>
                </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: 300px;">
                    <input type="text" placeholder="详细地址:不含省市区县字样"
                           class="layui-input"
                           id="updateAddress" name="merchantBaseInfo.address"
                           value="${merchantBaseInfo.address }"/>
                </div>
            </div>
        </div>

        <input type="hidden" name="merchantCode" value="${merchantBaseInfo.merchantCode}"/>

        <div class="layui-col-md12" style="clear:both">
            <ul>
                <li class="fl pt10 pb10 layui-col-xs12 layui-col-md4 layui-col-sm4" data-v="06" data-t="store">
                    <div>门头照</div>
                    <div class="dlblock upload w200 h200 mt10">
                        <input name="picUrl6" value="${merchantImage6}" hidden/>
                        <img id="picUrl6" src="${merchantImage6}"
                             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('picUrl6')">
                                    <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-xs12 layui-col-md4 layui-col-sm4" data-v="08" data-t="store">
                    <div>收银台照</div>
                    <div class="dlblock upload w200 h200 mt10">
                        <input name="picUrl8" value="${merchantImage8}" hidden/>
                        <img id="picUrl8" src="${merchantImage8}"
                             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('picUrl8')">
                                    <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-xs12 layui-col-md4 layui-col-sm4" data-v="09" data-t="store">
                    <div>门店内场景照</div>
                    <div class="dlblock upload w200 h200 mt10">
                        <input name="picUrl9" value="${merchantImage9}" hidden/>
                        <c:if test="${not empty merchantImage8 }">
                            <img id="picUrl9" src="${merchantImage9}"
                                 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('picUrl9')">
                                        <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>
                        </c:if>
                    </div>
                </li>

                <li class="fl pt10 pb10 layui-col-xs12 layui-col-md4 layui-col-sm4" data-v="101" data-t="store">
                    <div>商户协议</div>
                    <div class="dlblock upload w200 h200 mt10">
                        <input name="picUrl101" value="${merchantImage101}" hidden/>
                        <img id="picUrl101" src="${merchantImage101}"
                             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('picUrl101')">
                                    <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-xs12 layui-col-md4 layui-col-sm4" data-v="102" data-t="store">
                    <div>商户附属协议</div>
                    <div class="dlblock upload w200 h200 mt10">
                        <input name="picUrl102" value="${merchantImage102}" hidden/>
                        <img id="picUrl102" src="${merchantImage102}"
                             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('picUrl102')">
                                    <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>
        <br/>

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

<script>

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

        merchBaseInfoLoading = 1;
        baseSet()
    });

    form.on('select(provinceType)', funcDistrict);

    form.on('select(cityType)', funcDistrict);

    form.on('submit(formDemo2)', function (data) {
        var index = layer.load(1, {shade: [0.1, '#000']});
        $.ajax({
            url: '${ctx}/promoter/updateMerchantInformation',
            method: 'post',
            data: data.field,
            dataType: 'JSON',
            success: function (res) {
                layer.close(index);
                if (res.code == 200) {
                    layer.msg(res.message, {
                        icon: 1
                    });
                } else {
                    layer.msg(res.message, {
                        icon: 5
                    });
                }
            }
        })
        return false;
    })

</script>