<%@page language="java" contentType="text/html; charset=utf-8"
        pageEncoding="utf-8" %>
<script type="text/javascript" src="<%=webpath%>/js/DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
    function submitMyInfo() {
        var path = $("#mypaths").val();
        var newPassword = $("#newPassword").val();
        var confirmPassword = $("#confirmPassword").val();
        if (newPassword != confirmPassword) {
            alert("密码和确认密码不匹配");
            return;
        }
        $.ajax({
            cache: true,
            type: "POST",
            url: path + "/enterprise/put_Myenterprise.do",
            data: $('#enterpriseform').serialize(),// 你的formid
            async: false,
            error: function (request) {
                alert("Connection error");
            },
            success: function (data) {
                var data = eval("(" + data + ")");
                if (data.flag == 1) {
                    $("#my_info_dialog").hide();
                } else {
                    alert(data.msg);
                }
            }
        });

    }

    function getMapUrl() {
        var mapUrl = $("#map_frame").attr("src");
        setTimeout(function () {
            $("#map_frame").attr("src", mapUrl);
        }, 1);
    }


    function showMyInfoDialog() {
        $("#enterpriseform").form("clear");
        var params = {};
        var result = ajaxgetresultpost($("#mypaths").val()
                + '/enterprise/get_my_info.do', params);
        if (result.flag == 0) {
            alert(result.msg);
        } else {
//			alert(result.data);
            getMapUrl();
            loadData(result.data);
            $("#my_info_dialog").show();

        }
    }

    function loadData(obj) {
        var key, value, tagName, type, arr;
        for (x in obj) {
            key = x;
            value = obj[x];
            $("#my_info_dialog").find($("[name='" + key + "'],[name='" + key + "[]']")).each(function () {
                tagName = $(this)[0].tagName;
                type = $(this).attr('type');
                if (tagName == 'INPUT') {
                    if (type == 'radio') {
                        $(this).attr('checked', $(this).val() == value);
                    } else if (type == 'checkbox') {
                        arr = value.split(',');
                        for (var i = 0; i < arr.length; i++) {
                            //alert($(this).val()+'&&'+arr[i]+i);
                            if ($(this).val() == arr[i]) {
                                //alert(1);
                                $(this).prop('checked', true);
                                break;
                            }
                        }
                    } else {
                        $(this).val(value);
                    }
                } else if (tagName == 'SELECT' || tagName == 'TEXTAREA') {
                    $(this).val(value);
                }

            });
        }
    }
    $(document).on('click', '.cancel1', function () {
        $(".order_undo1").hide();
    });
    $(document).on('click', '.cancel', function () {
        $(".order_undo").hide();
    });
    function loginEmailBlur(strEmail) {
        var loginEmail = $.trim($("input[name='brands']").val());
        if (loginEmail == null || loginEmail == "") {
            alert("您的邮箱账号忘记输入了");
        }
        else {
            if (strEmail.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
                return true;
            }
            else {
                alert("请输入正确的邮箱格式");
            }
        }
    }

    window.onload = function () {
        var firstPage = $("#firstPage").val();
        var isShow = $("#isShow").val();
        if (firstPage == '1' && isShow == '1') {
            var params = {};
            var result = ajaxgetresultpost($("#mypaths").val()
                    + '/enterprise/get_my_info.do', params);
            //alert(result.data);
            if (result.flag == 0) {
                alert(result.msg);
            } else {
//			alert(result.data);
                getMapUrl();
                loadData(result.data);
                var brands = $("#brands").val();
                if (brands == null || brands == '') {
                    $("#my_info_dialog").show();
                    setTimeout(function () {
                        alert("对账邮箱信息不能为空");
                    }, 1);
                }
            }
        }
    };
</script>
<input id="isShow" type="hidden" value="<%=null !=  dto.getEnterpriseJlrId() &&0<dto.getEnterpriseJlrId()?1:0%>">
<input id="firstPage" type="hidden" value="${firstPage==null||firstPage==''?0:firstPage}">
<div class="order_undo1" id="my_info_dialog" style="display: none;">
    <form action="" id="enterpriseform">
        <div class="dialog_default" style="width:800px">
            <div class="dialog_title">编辑</div>
            <div class="dialog_con2">

                <div class="dialog_left2">
                    <table style="width:100%;">
                        <tbody>
                        <tr>
                            <td><span style="margin-right: 30px;">经销商名称</span><input name="name" type="text"
                                                                                     value="" readonly="readonly"
                                                                                     style="border:0;background:none;"/>
                            </td>
                            <td><span style="margin-right: 30px;">经销商代码</span><input name="abbr_code" type="text"
                                                                                     value="" readonly="readonly"
                                                                                     style="border:0;background:none;"/>
                            </td>
                            <!-- <td><span>简称</span><input name="registry" type="text"
                                                      value=""/></td> -->
                        </tr>

                        <tr>
                            <td style="line-height:32px;">
                                <span style="margin-right: 36px;">服务资质</span>
                                <input type="checkbox" id="roadRepair" name="service_qualification" value="路修"
                                       style="margin-right:5px;" disabled/> 路修
                                <input type="checkbox" id="trailer" name="service_qualification" value="拖车"
                                       style="margin-left:20px;margin-right:5px;" disabled/> 拖车
                            </td>

                            <td><span style="margin-right: 30px;">地址</span> <input name="address" id="address"
                                                                                   type="text" value=""
                                                                                   readonly="readonly"
                                                                                   style="border:0;background:none;"/>
                                <!-- <input type="button" class="addressBtn" value="选择地址" onclick="showmap();"/> -->
                            </td>

                        </tr>
                        <tr>
                            <td colspan="3"></td>
                        </tr>


                        <tr>
                            <td colspan="3">
                                <span>24小时联系人1</span>
                                <div class="contactWrap"><input class="contactInput" name="contact" placeholder="姓名"
                                                                type="text" value="" id="contact"/></div>
                                <div class="contactWrap"><input class="contactInput" name="phone1" placeholder="电话"
                                                                type="text" value="" id="phone1"/></div>
                                <div class="contactWrap"><input class="contactInput" name="job1" placeholder="职务"
                                                                type="text" value="" id="job1"/></div>
                            </td>

                        </tr>
                        <tr>
                            <td colspan="3">
                                <span>24小时联系人2</span>
                                <div class="contactWrap"><input class="contactInput" name="contact2" placeholder="姓名"
                                                                type="text" value=""/></div>
                                <div class="contactWrap"><input class="contactInput" name="phone2"
                                                                placeholder="电话" type="text"
                                                                value="" style=""/></div>
                                <div class="contactWrap">
                                    <input class="contactInput" name="job2" placeholder="职务" type="text" value=""/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="3">
                                <span>对账联系人</span>
                                <div class="contactWrap"><input class="contactInput" name="contact3" placeholder="姓名"
                                                                type="text" value=""/></div>
                                <div class="contactWrap"><input class="contactInput" name="phone3" placeholder="电话"
                                                                type="text"
                                                                value="" style=""/></div>
                                <div class="contactWrap">
                                    <input class="contactInput" name="job3" placeholder="职务" type="text" value=""/>
                                </div>
                            </td>

                        </tr>
                        <tr>
                            <td colspan="3"></td>
                        </tr>

                        <tr>

                            <!-- <td><span>联系人</span><input name="contact" type="text"
                                value="" /></td> -->
                            <td colspan="2"><span>对账邮箱</span><input id="brands" name="brands" type="email"
                                                                    value="" onblur="loginEmailBlur(this.value)"/>
                                <font style="color:red;margin-left:5px;font-size:12px;">该邮箱自动绑定服务费用结算通知，如有变动请及时更新！</font>
                            </td>
                        </tr>

                        <tr>
                            <td>
                                <span>更改密码</span>
                                <input id="newPassword" name="newPassword" type="password" placeholder="密码"
                                       value=""/></td>
                            <td>
                                <span>确认密码</span>

                                <input id="confirmPassword" name="confirmPassword" type="password" placeholder="确认密码"
                                       value=""/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>VIN码</span>
                                <input id="vin" name="vin_code" type="text" placeholder="VIN码"
                                       value=""/></td>
                            <td>
                                <span>车型</span>

                                <input id="carType" name="car_type" type="text" placeholder="车型"
                                       value=""/>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>首次销售日期</span>
                                <input type="text" id="firstSellDate" placeholder="首次销售日期"
                                       class="Wdate" readonly="readonly"
                                       name="first_sale_date"
                                       onfocus="WdatePicker({errDealMode:2,readOnly:true,startDate:'%y-%M-%d %H:%m:%s',dateFmt:'yyyy/MM/dd'})"
                                       style="cursor:pointer;"/>
                            </td>
                        </tr>

                        <tr>
                            <td colspan="3">
                                <input type="hidden" name="lat"/>
                                <input type="hidden" name="lon"/>
                            </td>
                        </tr>


                        </tbody>
                    </table>
                    <div class="confirm_cancel clearfix">

                        <a href="javascript:void(0);" class="btn2"
                           style="margin-right:20px;float: left;margin-left:80px;" onclick="submitMyInfo();">确&nbsp;&nbsp;认</a>
                        <a href="javascript:void(0);" class="btn1 cancel1" style="float: left;">取&nbsp;&nbsp;消</a>
                    </div>

                </div>


                <%--  <div class="dialog_right">
                     <iframe src="<%=path%>/base/amap.do" frameborder="0" scrolling="no"
                             id="map_frame" style="width: 715px;height: 550px"></iframe>
                 </div> --%>


            </div>
        </div>
    </form>

</div>
<div>
    <input type="hidden" id="mypaths" value="<%=path%>">
    <!-- <div class="footer"></div> -->
    <div></div>
</div>
</body>
</html>