<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link rel="stylesheet" href="/static/weixin/css/public.css">
    <link rel="stylesheet" href="/static/weixin/css/basic.css">
    <link rel="stylesheet" href="/static/weixin/css/SG_area_select.css?v=1.0.6">
    <script src="/static/weixin/js/flexible.js"></script>

    <title>信息修改</title>
</head>
<body id="contain">
<div class="contain">
    <div class="bai-head">
        <span>信息修改</span>
        <a id="back"  class="left">
            <img src="/static/weixin/images/head-left.png"/>
        </a>
        <%--<a href="javascript:;"  id="submit" class="trash amend" style="top: 0 !important;">--%>
            <%--<span style="font-size:32px;" >保存</span>--%>
        <%--</a>--%>
    </div>
        <div class="lower-level modify-information">
            <form id="defaultForm">
            <input type="hidden" name="id"/>
            <h2>基础信息</h2>
            <ul class="basic-information">
                <li>
                    <span>名称</span>
                    <input placeholder="请输入名称" name="company_name"  class="input-text">
                </li>
                <li>
                    <span>企业/个人</span>
                    <input  name="terminal_type" id="terminalType" disabled class="input-text">
                    <%--<select name="terminalType" id="ssss_enterprise" style="display: none;">--%>
                        <%--<option value="1" >企业</option>--%>
                        <%--<option value="2" >个人</option>--%>
                    <%--</select>--%>
                </li>
                <li>
                    <span>证件类型</span>
                    <p class="document_type" id="papers">

                    </p>
                    <div id="qqqqqq" style="display: none;">
                        <select name="document_type" id="ssss_idcard">
                            <option class="company terminalType" value="1">营业执照</option>
                            <option class="company terminalType" value="2" >统一社会信用代码</option>
                            <option class="company terminalType" value="3" >组织机构代码证</option>
                            <option class="person terminalType" value="0" >身份证</option>
                            <option class="person terminalType" value="1" >台胞证</option>
                            <option class="person terminalType" value="2" >护照</option>
                            <option class="person terminalType" value="3" >回乡证</option>
                            <option class="person terminalType" value="5" >其他</option>
                        </select>
                    </div>
                    <%--<input type="hidden" name="document_type" id="documentType" >--%>
                </li>
                <li>
                    <span>证件号</span>
                    <input type="text" placeholder="请输入证件号"  name="organization_code" class="input-text">
                </li>
                <li>
                    <span>所在城市</span>
                    <p id="selectBtn"></p>
                    <div class="s-city" style="display: none">
                        <input type="text" name="province" value="" id="s-province">
                        <input type="text" name="city" value="" id="s-city">
                        <input type="text" name="district" value="" id="s-area">
                    </div>
                </li>
                <li>
                    <span>具体地址</span>
                    <p id="specific"></p>
                    <input  type="hidden" name="address" id="adwer" >
                </li>
            </ul>
            <h2>联系人</h2>
            <ul class="basic-information">
                <li>
                    <span>姓名</span>
                    <input type="hidden" name="contacts_id"  value="">
                    <input  placeholder="请输入姓名" name="contacts_name"  class="input-text">
                </li>
                <li>
                    <span>手机</span>
                    <input  placeholder="请输入手机号码"  name="contacts_contacts_way"   class="input-text">
                </li>
                <li>
                    <span>电子邮箱</span>
                    <input  placeholder="请输入电子邮箱"  name="contacts_email"    class="input-text">
                </li>
            </ul>
            <h2>银行卡信息</h2>
            <ul class="basic-information distributor-level">
                <li>
                    <span>开户银行</span>
                    <input  placeholder="请输入开户银行" name="bank_name" class="input-text">
                </li>
                <li>
                    <span>银行卡号</span>
                    <input  placeholder="请输入银行卡号" name="bank_account" class="input-text">
                </li>
                <li>
                    <span>银行预留联系电话</span>
                    <input  placeholder="请输入银行预留联系电话" name="bank_phone" class="input-text">
                </li>
                <li>
                    <span>户名</span>
                    <input  placeholder="请输入户名" name="bank_account_name" class="input-text">
                </li>
                <li>
                    <span>开户行所在城市</span>
                    <p id="selectBtn-more" name="bank_province,bank_city" style="text-align: left;"></p>
                    <div class="s-city" style="display: none">
                        <input type="text" name="bank_province" value="" id="ss-province">
                        <input type="text" name="bank_city" value="" id="ss-city">
                    </div>
                </li>
            </ul>
                <div class="pro-steps assigned-steps" style="padding-top: 1rem; position: relative;">
                    <div class="steps">
                        <button id="submit" type="button" class="xia">保存</button>
                    </div>
                </div>
            </form>
    </div>
</div>
<%--<div class="pro-steps assigned-steps">--%>
    <%--<div class="steps">--%>
        <%--<button id="submit" class="xia">提交</button>--%>
        <%--<button id="back">返回</button>--%>
    <%--</div>--%>
<%--</div>--%>



<!--企业/个人选择弹窗-->
<div class="person-model">
    <ul>
        <li>
            <p>企业</p>
        </li>
        <li>
            <p>个人</p>
        </li>
    </ul>
</div>

<!--企业证件类型弹窗-->
<div class="papers-model" id="ertff">
    <ul>
        <li class="company terminalType">
            <p onclick="tyu(this)">营业执照</p>
        </li>
        <li class="company terminalType">
            <p onclick="tyu(this)">统一社会信用代码</p>
        </li>
        <li class="company terminalType">
            <p onclick="tyu(this)">组织机构代码证</p>
        </li>
        <li class="person terminalType">
            <p onclick="tyu(this)">身份证</p>
        </li>
        <li class="person terminalType">
            <p onclick="tyu(this)">台胞证</p>
        </li>
        <li class="person terminalType">
            <p onclick="tyu(this)">护照</p>
        </li>
        <li class="person terminalType">
            <p onclick="tyu(this)">其他</p>
        </li>
        <li class="person terminalType">
            <p onclick="tyu(this)">回乡证</p>
        </li>
    </ul>
</div>

<!--具体地址填写弹窗-->
<div class="specific-address">
    <textarea></textarea>
    <div class="select-sdf">
        <button class="cancel">取消</button>
        <button class="bao">保存</button>
    </div>
</div>

<!--黑色蒙版-->
<div class="block-mask"></div>

<script src="/static/weixin/js/jquery-1.8.3.min.js"></script>
<script src="/static/weixin/js/iscroll.js"></script>
<script src="/static/weixin/js/SG_area_select-two.js"></script>
<script src="/static/weixin/js/SG_area_select-three.js"></script>
<script src="/static/weixin/js/basicTwo.js"></script>
<script src="/static/weixin/common/layer_mobile/layer.js"></script>
<link rel="stylesheet" href="/static/weixin/common/layer_mobile/need/right.css">
<script src="/static/weixin/common/jquery.formHelper.js"></script>
<script src="/static/weixin/js/g.js"></script>
<script>

    $(document).ready(function () {
        //省市县选择
        $('#selectBtn').on('click', function () {
            $.areaSelect();
        });

        //省市县选择
        $('#selectBtn-more').on('click', function () {
            $.areaSelectMore();
        });

        //定位input、textarea
        function po_Last(obj) {
            obj.focus();//解决ff不获取焦点无法定位问题
            if (window.getSelection) {//ie11 10 9 ff safari
                var max_Len=obj.value.length;//text字符数
                obj.setSelectionRange(max_Len, max_Len);
            }
            else if (document.selection) {//ie10 9 8 7 6 5
                var range = obj.createTextRange();//创建range
                range.collapse(false);//光标移至最后
                range.select();//避免产生空格
            }
        }

        $('.modify-information input').click(function () {
            po_Last(this);
        })

        //返回按钮点击事件
        $("#back").click(function(){
            layer.open({
                content: '修改的内容未保存，确定要返回吗？'
                ,btn: ['确认返回', '取消返回'] ,yes: function(index){
                     window.top.location.href="/weixin/account/index";
                }
            });
        });

        //初始化显示  字典列表， 数据列表，现场翻译
        function setP(row){
            //个人和企业选项的样式控制
            if(row.terminal_type=="2") {//个人
                $(".terminalType").hide(); $(".person").show();
            }else{
                $(".terminalType").hide(); $(".company").show();
            }

            //初始化表单
            $("#defaultForm").setForm(row);

            //初始化证件类型
            var document_type = "";
            if( row.terminal_type=="2")  document_type = g_getDict("iDType", row.document_type);
            if( row.terminal_type=="1")  document_type = g_getDict("documentType", row.document_type);
            $(".document_type").html(document_type);

            //初始化企业/个人
            $("#terminalType").val(g_getDict("terminalType", row.terminal_type));
            $("#specific").html(row.address);

            try {
                $("#selectBtn").html(""+g_getRegion(row.province).province+" "+g_getRegion(row.city).citytype+" "+g_getRegion(row.district).city);
                $("#selectBtn-more").html(""+g_getRegion(row.bank_province).province+" "+g_getRegion(row.bank_city).citytype);
            } catch (e) {
            }

        }
        g_ajax("/weixin/account/getAccount",{},function(json){  setP(json); },false);

        //提交
        $("#submit").click(function(){
            var p  = $("#defaultForm").serializeJson();
            //必填校验

            //参数校验
            if(!g_reg.ckPhone(p["contacts_contacts_way"])) {layer.open({content:"手机号码不正确",btn: '我知道了'}); return;}
            if(!g_reg.ckEmail(p["contacts_email"])) {layer.open({content:"邮箱格式不正确",btn: '我知道了'}); return;}
            if(!g_reg.ckNum(p["bank_account"])) {layer.open({content:"银行卡号格式不正确，只能数字",btn: '我知道了'}); return;}
            if(!g_reg.ckPhone(p["bank_phone"])) {layer.open({content:"银行预留联系电话格式不正确，为11位手机",btn: '我知道了'}); return;}

            //TODO 替换表情字符
            g_ajax("/weixin/account/upd",p,function(json){
                if (json.success == true) {
                    window.location.href="/weixin/account/index";
                } else {
                    layer.open({content:json.msg,btn: '我知道了'})
                }
            },true);
        });



    });
</script>


</body>
</html>