<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <base href="#springUrl('/assets/adminlte/')"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>工作台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">

    <!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">

    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <!--validate css-->
    <link rel="stylesheet" href="plugins/jquery-validation/css/validate.css">
    <!--fileinput css-->
    <link rel="stylesheet" href="plugins/bootstrap-fileinput/bootstrap-fileinput.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        .previewImg {
            max-width: 100%;
            max-height: 100%;
            border: 0px;
            display: none;
            z-index: 999;
        }
    </style>
</head>
<!-- END HEAD -->
<body class="hold-transition skin-blue sidebar-mini">

<div class="wrapper">
    <div class="content-wrapper" style="margin-left:0;">

        <section class="content-header">
            <h1>
                微信多客服管理
                <small>微信多客服</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>首页</a></li>
                <li><a class="active">微信多客服</a></li>
            </ol>
        </section>


        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <!-- general form elements disabled -->
                    <div class="box box-primary">
                        <form role="form" id="myForm">
                            <input name="id" value="$!{data.id}" hidden="true"/>
                            <div class="box-body">
                                <div class="form-group form-md-line-input" id="imageUrlDiv">
                                    <label>头像</label>
                                    <input name="domain" id="domain" style="display: none;">
                                    <div class="input-group" id="actStartPicGroup">
                                        <input type="text" style="display: none"
                                               class="form-control" name="kfAvatar"
                                               id="kfAvatar"
                                               maxlength="500" placeholder="头像"
                                               value="$!{data.kfAvatar}"
                                        >

                                        <!--<span class="input-group-btn">-->
                                        <!--<button type="button" id="smallImgSelect"-->
                                        <!--class="btn btn-info btn-flat">选择</button>-->
                                        <!--</span>-->
                                    </div>
                                    <div id="ImgSelect"
                                         style="text-align: center;line-height: 200px;width: 200px;height: 200px;border: 1px #ccc solid;position: relative;">
                                        <i class="fa fa-plus" style="font-size:50px;color:#ccc"></i>
                                        <img src="" style="" class="previewImg" id="previewImg"/>
                                    </div>
                                </div>
                                <div class="form-group form-md-line-input">
                                    <label>客服账号</label> <input type="text"
                                                               class="form-control"
                                                               name="kfAccount" id="kfAccount"
                                                               maxlength="50"
                                                               placeholder="客服账号"
                                                               required="required"
                                                               value="$!{data.kfAccount}">
                                </div>
                                <div class="form-group form-md-line-input">
                                    <label>客服昵称</label> <input type="text"
                                                               class="form-control"
                                                               name="nickName" id="nickName"
                                                               maxlength="50"
                                                               placeholder="客服昵称"
                                                               required="required"
                                                               value="$!{data.nickName}">
                                </div>
                                <!--<div class="form-group form-md-line-input">-->
                                    <!--<label>客服密码</label> <input type="password"-->
                                                               <!--class="form-control"-->
                                                               <!--name="password" id="password"-->
                                                               <!--maxlength="50"-->
                                                               <!--placeholder="客服密码"-->
                                                               <!--required="required"-->
                                                               <!--value="$!{data.password}">-->
                                <!--</div>-->
                            </div>

                            <div class="box-footer">
                                #if($shiro.hasPermission("mp:multiCustservice:edit"))
                                <input class="btn btn-primary" id="save" value="保存" type="submit">
                                #end
                                <a href="#springUrl('/a/multiCustservice/list')" class="btn btn-default">取消</a>
                            </div>
                        </form>
                        <!-- /.box-body -->
                    </div><!-- /.box -->


                </div><!-- /.col -->
            </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->


    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->

<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
<script src="plugins/security/sha256.js" type="text/javascript"></script>
<script src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<script src="js/jquery.form.min.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/lang/zh-cn/zh-cn.js"></script>
<script src="common/js/cfapp.js"></script>
<script src="plugins/jquery-validation/js/localization/messages_zh.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<script>
    $().ready(function () {
        Cfapp.init();




        /**
         * 小图选择
         */
        $("#ImgSelect").click(function () {
            obj = $(this);
            Cfapp.sm({
                title: "分类封面图选择",
                success: function (data) {
                    obj.find("i").remove();
                    $("#imageUrl").val(data[0]);
                    $("#previewImg").attr("src", data[0]).show();
                }
            })
        })


        var protocol = window.location.protocol;
        var host = window.location.host;
        $("#domain").val(protocol + '//' + host);
        var dataId=$("#id").val();
        if(dataId!=null && dataId!=""){
            var actStartPicImg = $("#imageUrl").val();
            if (actStartPicImg && actStartPicImg != null) {
                if (actStartPicImg.substring(0, 7) == "http://") {
                    $("#previewImg").attr("src", actStartPicImg).show();
                } else {
                    $("#previewImg").attr("src", protocol + '//' + host + actStartPicImg).show();
                }
                $("#previewImg").siblings("i").remove();
            }
        }

        recdTypeAdd.init();
    });


    var recdTypeAdd = function () {
        var initForm = function () {
            var initFormCtrl = function () {
                bindEvent();
            };
            var bindEvent = function () {
                $("#myForm").validate({
                    rules: {},
                    messages: {},
                    submitHandler: function (form) {
                        $("#save").attr("disabled", true);
                        var options = {
                            url : "#springUrl('/a/custservice/findOnlineCustServiceList')",
                            type : "POST",
                            dataType: "json",
                            contentType : "application/x-www-form-urlencoded; charset=utf-8",
                            success : function(data) {
                                data=JSON.parse(data);
                                $("#save").attr("disabled", false);
                                if(data.errorNo == 0){
                                    Cfapp.alert({
                                        message: "上传成功",
                                        btnoktext: "确定",
                                        success: function () {
                                            location.href="#springUrl('/a/card/cardLogoform')";
                                        }
                                    });
                                }else if(data.errorNo == 2){
                                    Cfapp.alert({
                                        message: "文件过大(最大为1M)",
                                        btntext: "确定",
                                        success: function () {
                                        }
                                    });
                                }else if(data.errorNo == 3){
                                    Cfapp.alert({
                                        message: "仅支持jpg、png文件",
                                        btntext: "确定",
                                        success: function () {
                                        }
                                    });
                                }
                            }
                        };

                        $("#recform").ajaxSubmit(options);
                    }
                })
            }
            initFormCtrl();
        }
        return {

            //main function to initiate the module
            init: function () {
                initForm();
            }

        };
    }();
</script>
</body>
<!-- END BODY -->
</html>