<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <title>作家管理系统-小说精品屋</title>
        <link rel="stylesheet" href="/css/base.css?v=1"/>
        <link rel="stylesheet" href="/css/user.css"/>
        <style type="text/css">
            .opacity{-khtml-opacity:0.0;-moz-opacity:0.0;filter:alpha(opacity=0);filter:"alpha(opacity=0)";opacity:0.0; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);/*兼容ie8及以下*/}
        </style>
    </head>
</head>
<body class="">

<div class="header">
    <div class="mainNav" id="mainNav">
        <div class="box_center cf"
             style="text-align: center;height: 44px;line-height: 48px;color: #fff;font-size: 16px;">

            小说精品屋作家管理

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

<div class="main box_center cf">
    <div class="userBox cf">
        <div class="my_l">

            <ul class="log_list">
                <li><a class="link_1 on" href="/author/index.html">小说管理</a></li>
                <li><a class="link_1 " href="/author/author_income_detail.html">稿费收入</a></li>
                <!--<li><a class="link_1 " href="/user/userinfo.html">批量小说爬取</a></li>
<li><a class="link_4 " href="/user/favorites.html">单本小说爬取</a></li>-->
            </ul>

        </div>
        <div class="my_r">
            <div class="my_bookshelf">

                <div class="userBox cf">
                    <form method="post" action="./register.html" id="form2">
                        <div class="aspNetHidden">
                            <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
                                   value="/wEPDwUKLTIzNjMxNDQxNw9kFgJmD2QWAmYPFgIeBFRleHQFqAE8YSBocmVmPSIvc2VhcmNoLmFzcHg/c2VhcmNoS2V5PeWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqyIgdGFyZ2V0PSJfYmxhbmsiPuWWu+Wuiembr++8jOeLhOazve+8jOeBteW8gu+8jOWJjeS4luS7iueUn++8jOWGpeeOi+msvOWkqzwvYT5kZOquoASBvnvPbc/TYIQiLhSPJ8GKnYQrmk7jGhb5AC5Q">
                        </div>

                        <div class="aspNetHidden">

                            <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="23AA6834">
                            <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
                                   value="/wEdAAVece19BIZ9HiByRfHz3pfnqKSXUE1UN51mNFrIuw38c3Y2+Mc6SrnAqio3oCKbxYZZ1lS+gZUZKpbsAea8j7ASAv40DHFcQ/NE7tJUnABeyQ3d9sFDIcFCYNqlVtprfLoh4JFy0U+R/CcMuyAiWTz7">
                        </div>
                        <div class="user_l">
                            <div></div>
                            <h3>小说基本信息填写</h3>
                            <ul class="log_list">
                                <li><span id="LabErr"></span></li>
                                <b>作品方向：</b>
                                <li><select class="s_input" id="workDirection" name="workDirection">
                                    <option value="0">男频</option>
                                    <option value="1">女频</option>
                                </select>
                                </li>
                                <b>分类：</b>
                                <li><select class="s_input" id="catId" name="catId">
                                    <option value="1">玄幻奇幻</option>
                                    <option value="2">武侠仙侠</option>
                                    <option value="3">都市言情</option>
                                    <option value="4">历史军事</option>
                                    <option value="5">科幻灵异</option>
                                    <option value="6">网游竞技</option>
                                    <option value="7">女生频道</option>
                                </select></li>
                                <input type="hidden" id="catName" name="catName" value="玄幻奇幻"/>
                                <b>小说名：</b>
                                <li><input type="text" id="bookName" name="bookName" class="s_input" ></li>
                                <b>小说封面：</b>
                                <li style="position: relative">
                                    <input class="opacity" onchange="picChange()"
                                           type="file" id="file0" name="file"
                                           title="点击更换图片"
                                           style="z-index: 100;cursor: pointer;left: 0px; top: 0px; width: 100px; height: 130px; opacity: 0; position: absolute;  "
                                    />
                                    <img style="width:100px;height: 130px" id="picImage" src="/images/default.gif" alt="">
                                    <input type="hidden" id="picUrl" name="picUrl" class="s_input" value="/images/default.gif"></li>
                                <b>小说介绍：</b>

                                <li><textarea name="bookDesc" rows="5" cols="53" id="bookDesc"
                                              class="textarea"></textarea></li>

                                <li><input type="button" onclick="addBook()" name="btnRegister" value="提交"
                                           id="btnRegister" class="btn_red"></li>
                            </ul>
                        </div>
                    </form>
                </div>
                <!--<div id="divData" class="updateTable">
                    <table cellpadding="0" cellspacing="0">
                        <thead>
                        <tr>

                            <th class="name">
                                爬虫源（已开启的爬虫源）
                            </th>
                            <th class="chapter">
                                成功爬取数量（websocket实现）
                            </th>
                            <th class="time">
                            目标爬取数量
                            </th>
                            <th class="goread">
                                状态（正在运行，已停止）（一次只能运行一个爬虫源）
                            </th>
                            <th class="goread">
                                操作（启动，停止）
                            </th>
                        </tr>
                        </thead>
                        <tbody id="bookShelfList">



                        </tbody>
                    </table>
                    <div class="pageBox cf" id="shellPage">
                    </div>
                </div>-->
            </div>
        </div>
    </div>
</div>


</body>
<script src="/javascript/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="/javascript/ajaxfileupload.js" type="text/javascript"></script>

<script src="/layui/layui.all.js" type="text/javascript"></script>
<script src="/javascript/header.js" type="text/javascript"></script>
<script src="/javascript/user.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">

    function picChange() {
        var file = $("#file0").val(); //文件名称
        if (file != "") {

            $.ajaxFileUpload({
                url : "/file/upload", //用于文件上传的服务器端请求地址
                secureuri : false, //是否需要安全协议，一般设置为false
                fileElementId : "file0", //文件上传域的ID
                dataType : "json", //返回值类型 一般设置为json
                type : "post",
                success : function(data) { //服务器成功响应处理函数
                    if (data.code == 200) {
                        $("#picImage").attr("src", data.data);
                        $("#picUrl").val(data.data);
                    }else {
                        layer.alert('图片上传失败');
                    }

                }

            });
        } else {
            alert("请选择上传文件！");
        }



    }

    var lock = false;
    function addBook() {
        if(lock){
            return;
        }
        lock = true;



        var bookName = $("#bookName").val();
        if(!bookName){
            $("#LabErr").html("小说名不能为空！");
            lock = false;
            return;
        }
        if(bookName.length > 20){
            $("#LabErr").html("小说名太长！");
            lock = false;
            return;
        }

        var picUrl = $("#picUrl").val();
        if(!picUrl){
            $("#LabErr").html("封面图片不能为空！");
            lock = false;
            return;
        }

        var bookDesc = $("#bookDesc").val();
        if(!bookDesc){
            $("#LabErr").html("简介不能为空！");
            lock = false;
            return;
        }


        $.ajax({
            type: "POST",
            url: "/author/addBook",
            data: {'workDirection': $("#workDirection").val(),
            'catId':$("#catId").val(),'catName':$("#catId").find("option[value="+$("#catId").val()+"]").html(),
            'bookName':bookName,'picUrl':picUrl,'bookDesc':bookDesc},
            dataType: "json",
            success: function (data) {
                if (data.code == 200) {

                    window.location.href = '/author/index.html';


                } else {
                    lock = false;
                    $("#LabErr").html(data.msg);
                }

            },
            error: function () {
                lock = false;
                layer.alert('网络异常');
            }
        })

    }

</script>
</html>
