<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@page import="com.fadu.app.util.SystemCache"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>

<link rel="stylesheet" href="${contextPath}/static/assets/css/jquery.gritter.css" />

<!-- ajax layout which only needs content area -->
<div class="page-header">
    <h1>
        诉讼担保
        <small>
            <i class="ace-icon fa fa-angle-double-right"></i>
            开通微信通知
        </small>
    </h1>
</div><!-- /.page-header -->

<div class="row">
    <div class="col-xs-12">
        <!-- PAGE CONTENT BEGINS -->
        <div class="row">
            <div class="col-xs-12">
                <!-- #section:pages/inbox -->
                <div class="tabbable">
                    <label for="name">姓名：</label>
                    <div class="input-group">
                        <input type="text" id="name" class="form-control"/>
                    </div>
                    <br/>
                    <label for="role">角色：</label>
                    <div class="input-group">
                        <select class="select" id="role">
                            <option value="">请选择</option>
                            <option value="1">客服经理</option>
                            <option value="2">跟单人员</option>
                        </select>
                    </div>
                    <div class="modal-footer no-margin-top">
                        <div class="text-center">
                            <button onclick="addWechat()" id="mod-add-submit" type="button" class="btn btn-sm btn-primary">
                                <i class="ace-icon fa fa-floppy-o bigger-160"></i>
                                生成二维码
                            </button>
                        </div>
                    </div>
                    <img class="lazy" id="img"  style="width: 150px;height: 150px;display: none">
                </div><!-- /.modal-content -->

                </div>
                <!-- /section:pages/inbox -->
            </div><!-- /.col -->
        </div><!-- /.row -->
        <!-- PAGE CONTENT ENDS -->
    </div><!-- /.col -->
</div><!-- /.row -->

<!-- page specific plugin scripts -->
<style type="text/css">
    #show{display: none;  position: absolute; left: 35%;  width: 400;  height: 60;  padding: 8px;  border: 8px solid #E8E9F7;  background-color: white;  z-index:1002;  overflow: auto;}
</style>
<script type="text/javascript">
    var contextPath = '${contextPath}';
    var scripts = [null,"${contextPath}/static/assets/js/bootstrap-tag.js","${contextPath}/static/assets/js/jquery.hotkeys.js","${contextPath}/static/assets/js/bootstrap-wysiwyg.js","${contextPath}/static/assets/js/jquery.gritter.js",null]
    $(".page-content-area").ace_ajax("loadScripts", scripts, function() {
        jQuery(function($){
            $("#lawyerExpValueRepair").click(lawyerExpValueRepair);
            $("#lawyerCaseNumRepair").click(lawyerCaseNumRepair);
            $("#caseClassifyRepair").click(caseClassifyRepair);
            $("#lawyerCityRepair").click(lawyerCityRepair);
            $("#addProduct").click(addProduct);
            $("#sendYxSms").click(sendYxSms);
            $.post("${contextPath}/sys/product/getProductSelectHtml", {}, function(result){
                $("#products").html(result);
            });
        });
    });

    function addWechat(){
        var name = $("#name").val();
        var role = $("#role").val();
        if(!name || !role){
            alert("请完善信息");
            return;
        }
        $.ajax({
            dataType : "json",
            url : "${contextPath}/sys/ssdbOrder/openWeChat",
            type : "post",
            data : {
                'name' : name,
                'type' : role
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                $("#img").attr("src",""+ret.qrCodeUrl+"");
                $("#img").show();
            }
        });

    }

    function showdiv() {
        document.getElementById("show").style.display ="block";
        $(".btn").attr({"disabled":"disabled"});
    }
    function hidediv() {
        document.getElementById("show").style.display ='none';
        $(".btn").removeAttr("disabled");
    }

    function lawyerExpValueRepair(){
        showdiv();
        $.post("${contextPath}/sys/dataRepair/lawyerExpValue", {}, function(result){
            hidediv();
            if(result && result.isSuccess){
                alert("已经修复" + result.row + "位律师！");
            }else{
                alert("异常信息:" + result.message);
            }
        });
    }

    function lawyerCaseNumRepair(){
        showdiv();
        $.post("${contextPath}/sys/dataRepair/lawyerCaseNum", {}, function(result){
            hidediv();
            if(result && result.isSuccess){
                alert("已经修复" + result.row + "位律师！");
            }else{
                alert("异常信息:" + result.message);
            }
        });
    }

    function caseClassifyRepair(){
        showdiv();
        $.post("${contextPath}/sys/dataRepair/caseClassify", {}, function(result){
            hidediv();
            if(result && result.isSuccess){
                alert("已经分类" + result.row + "个案例！");
            }else{
                alert("异常信息:" + result.message);
            }
        });
    }

    function lawyerCityRepair(){
        showdiv();
        $.post("${contextPath}/sys/dataRepair/lawyerCityRepair", {}, function(result){
            hidediv();
            if(result && result.isSuccess){
                alert("已经完成" + result.row + "位律师的省市！");
            }else{
                alert("异常信息:" + result.message);
            }
        });
    }

    function addProduct(){
        showdiv();
        var companyId = $("#companyId").val();
        var productId = $("#productSelect").val();
        $.post("${contextPath}/sys/product/manalAddProduct", {companyId:companyId,productId:productId}, function(result){
            hidediv();
            alert(result);
        });
    }

    function setCity(obj){
        var val = obj.value;
        var sec = document.getElementById('cityId');
        sec.innerHTML = "<option value=''>全部</option>";
        if(val != ''){
            //ajax
            $.getJSON("${contextPath}/util/getCitysByProvince?provinceId="+val,function(result){
                $.each(result, function(i, v){
                    sec.innerHTML+="<option value='"+v.value+"'>"+v.name+"</option>";
                });
            });
        }
    }

    function sendYxSms(){
        showdiv();
        var param = {
            provinceId : $("#provinceId").val(),
            cityId : $("#cityId").val(),
            content : $("#smsContent").val()
        }
        $.post("${contextPath}/sys/dataRepair/sendYxSms", param, function(result){
            hidediv();
            if(result && result.isSuccess){
                alert("已经发送" + result.row + "条营销信息！");
            }else{
                alert("异常信息:" + result.message);
            }
        });
    }

</script>
