 //获取用户信息
 function usermessage() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({

         url: 'http://127.0.0.1:81/consumer/user/fineById/' + userId + '/', //请求url
         undefined,
         type: "get",
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         success: function(data) {
             if (data.code == 200) {

                 document.getElementById("denglu").innerHTML = '<div style="display:flex;"><a href="./index.html"><img src=http://cdn.shuguangwl.com/2022/04/01/9d62eaa7c11f2.png style="width:20px;height:20px;">' + data.data.username + '</a><a href="./logout.html"><img src=http://cdn.shuguangwl.com/2022/04/10/60fc777f1b526.png style="width:20px;height:20px;">退出登录</a><div>';
                

             } else {
                
                 window.location.href = "./login.html";
                  alert("您未登录，没有访问权限");
             }
         }
     })
 }
 // 导航栏顶部
 // 首页
function load_ci() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");

     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:88/consumer/do/fine/poem/type/1/1/8',
         type: 'GET',
         // data: 'data',
          success: function(data) {
             for (i = 0; i < data.data.rows.length; i++) {
                 var one = data.data.rows[i].poemInformation;
                 var input = one.replace(/\。/g, '。<br/>');
                 one = input.replace(/\，/g, '，<br/>');
                 input = one.replace(/\？ /g, '？<br/>');
                 one = input.replace(/\,/g, '，<br/>');
                 input = one.replace(/\ /g, '<br/>')
                 one = input.replace(/\!/g, '!<br/>');
                 var result = one.replace(/\./g, '。<br/>');
                 var poemInformation = result;
                 b = ' <div class=" col-md-6 col-sm-12 single-trainer"><a href="./poetry.html?ownText=' + data.data.rows[i].poemId + '"><div class="meta-text text-sm-center"><h4 id="title">' + data.data.rows[i].poemName + '</h4>'
                 b += '<p id="aritle">' + data.data.rows[i].poemUser + '</p>'
                 b += '<div class="mb-4">'
                 b += '<p id="poemer">' + poemInformation + '</p></div></div>'
                 b += '</a>'
                 b += '</div>';
                 $(".poems").append(b);

             }

         }
     });
 }

 function load_shi() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");

     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:88/consumer/do/fine/dynasty/type/2/1/8',
         type: 'GET',
         // data: 'data',
        success: function(data) {

             for (i = 0; i <data.data.rows.length; i++) {
                 var one = data.data.rows[i].dynastyInformation;
                 var input = one.replace(/\。/g, '。<br/>');
                 one = input.replace(/\，/g, '，<br/>');
                 input = one.replace(/\？ /g, '？<br/>');
                 one = input.replace(/\,/g, '，<br/>');
                 input = one.replace(/\ /g, '<br/>')
                 one = input.replace(/\!/g, '!<br/>');
                 input = one.replace(/？/g, '？<br/>')
                 var result = input.replace(/\./g, '。<br/>');
                 var dynastyInformation = result;
                 b = ' <div class="col-lg-3 col-md-6 col-sm-12 single-trainer"><a href="./ancient%20poetry.html?ownText=' + data.data.rows[i].dynastyId + '"><div class="meta-text text-sm-center"><h4 id="title">' + data.data.rows[i].dynastyName + '</h4>'
                 b += '<p id="aritle">' + data.data.rows[i].dynastyUser + '</p>'
                 b += '<div class="mb-4">'
                 b += '<p id="poemer">' + dynastyInformation + '</p></div></div>'
                 b += '</a></div>';
                 $(".dynastys").append(b);

             }

         }
     });
 }
 // 管理
 var userId = sessionStorage.getItem('userId');
 var userToken = sessionStorage.getItem("yq_token");
 //我发布的词
 function guanlici() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");

     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/do/fine/poem/userId/' + userId + '/',
         type: 'GET',
         // data: 'data',
         success: function(data) {

             for (i = 0; i < data.data.length; i++) {
                 {
//                      
                     b = '<li><h4>' + data.data[i].poemName +
                         '</h4><p>' + data.data[i].time + '</p><div><a href="./xiugai.html#' + data.data[i].poemId + '"><img src="../assets/images/修改.png">修改</a><a href="./leixing.html#' + data.data[i].poemId + '"><img src="../assets/images/添加.png">添加类型</a><a href="./delete.html#'+data.data[i].poemId+'"><img src="../assets/images/shanchuleixing.png">删除类型</a><a href="./shanchu.html#' + data.data[i].poemId + '"><img src="../assets/images/删除.png">删除</a><div>';
                         
                     b += '</li>';
                     $(".poems").append(b);
                    // document.getElementById("shiciname").value=data.data[i].poemId;
                        
                     
                 }
                 
                 
             }

         }
     });
 }
 
 //我发布的词
 function guanlishi() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/do/fine/dynasty/userId/' + userId + '/',
         type: 'GET',
         // data: 'data',
         success: function(data) {

             for (j = 0; j < data.data.length; j++) {
                 {
                    
                     b = '<li><h4>' + data.data[j].dynastyName + '</h4><p>' + data.data[j].time + '</p><a href=xiugai.html?' + data.data[j].dynastyId + '><div><img src="../assets/images/修改.png">修改</a><a href="./leixing.html?' + data.data[j].dynastyId + '"><img src="../assets/images/添加.png">添加类型</a><a href="./delete.html?'+data.data[j].dynastyId+'"><img src="../assets/images/shanchuleixing.png">删除类型</a><a href=./shanchu.html?' + data.data[j].dynastyId + '><img src="../assets/images/删除.png">删除</a></div>';
                     b += '</li>';
                     $(".dynastys").append(b);
                    //   document.getElementById("shiciname").value=data.data[j].dynastyId;
                      
                 }
             }
           

         }
     });
 }
 
 // 判断用户登录状态
 function denglu() {

 }
 // 关注
 function guanzhulist() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");

     $.ajax({
         url: 'http://127.0.0.1:83/consumer/user/followersList/' + userId + '/',
         undefined,
         type: "get",
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         success: function(data) {

             for (j = 0; j < data.data.length; j++) {
                 {
                     b = '<li><a href="../product.html?ownText='+ data.data[j].username +'"><img src="../assets/images/guanzhu.svg">您关注了‘' + data.data[j].username +
                         '’</a></li>';
                     $(".guanzhu").append(b);
                 }
             }

         }
     });
 }

 // 修改密码

 function xiugaimessage() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");
     var username = $.trim($("#username").val());
     var email = $.trim($("#email").val());
     var password = $.trim($("#password").val());
     var passwords = $.trim($("#passwords").val());
     var data1 = {
         'username': username,
         'password': password,
         'email': email,
         'userId': userId
     };
     $.ajax({
         //请求地址
         contentType: 'application/json;charset=UTF-8',
         url: 'http://127.0.0.1:81/consumer/user/modification',
         undefined,
         type: 'GET',
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         data: data1,
         dataType: JSON,
         success: function(data1) {
             if (data.code == 200) {
                 alert("修改成功,请牢记用户信息");
             } else {
                 alert("修改失败,请稍后再试！");
             }

         },
         error: function(data1) {
             alert: ("链接失败");
         }

     });

 };


 //我发布的词
 function myci() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/do/fine/poem/userId/' + userId + '/',
         type: 'GET',
         // data: 'data',
         success: function(data) {

             for (j = 0; j < data.data.length; j++) {
                 {
                     b = '<li><h4>' + data.data[j].poemName +
                         '</h4><p>' + data.data[j].time + '</p><a href="../poetry.html?ownText=' + data.data[j].poemId + '"><img src="../assets/images/查看.png">查看详细</a>';
                     b += '</li>';
                     $(".poems").append(b);
                 }
             }

         }
     });
 }
 //我发布的词
 function myshi() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/do/fine/dynasty/userId/' + userId + '/',
         type: 'GET',
         // data: 'data',
         success: function(data) {

             for (j = 0; j < data.data.length; j++) {
                 {
                     b = '<li><h4>' + data.data[j].dynastyName + '</h4><p>' + data.data[j].time + '</p><a href="../ancient poetry.html?ownText=' + data.data[j].dynastyId + '"><img src="../assets/images/查看.png">查看详细</a>';
                     b += '</li>';
                     $(".dynastys").append(b);
                 }
             }

         }
     });
 }



 // 收藏的诗
 function myshoucangshi() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:84/consumer/see/collection/dynasty/' + userId + '/',
         type: 'GET',
         data: 'data',
         success: function(data) {
             for (j = 0; j < data.data.length; j++) {
                 {
                     b = '<a href="../ancient%20poetry.html?ownText='+data.data[j].dynastyId+'"><li><img src="../assets/images/shoucang.svg"><span>您收藏了' +
                         data.data[j].dynastyName + '</span>';
                     b += '<p style="margin-bottom:30px;">' + data.data[j].dynastyUser + '</p>';
                     b += '<div class="mb-6"><p>' + data.data[j].time + '</p></div></li></a>';
                     $(".dynasty").append(b);
                 }
             }
         }
     });
 }
 // 收藏的词
 function myshoucangci() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:84/consumer/see/collection/poem/' + userId + '/',
         type: 'GET',
         data: 'data',
         success: function(data) {
             for (j = 0; j < data.data.length; j++) {
                 {
                     b = '<a href="../poetry.html?ownText=' + data.data[j].poemId + '"><li><img src="../assets/images/shoucang.svg"><span>您收藏了' +
                         data.data[j].poemName + '</span>';
                     b += '<p style="margin-bottom:30px;">' + data.data[j].poemUser + '</p>';
                     b += '<div class="mb-6"><p>' + data.data[j].time + '</p></div></div></div></a>';
                     $(".poem").append(b);
                 }
             }
         }
     });
 }

 //发布古词


 function text() {
     var userId = window.sessionStorage.getItem('userId');
     var token = window.sessionStorage.getItem("yq_token");
     var poemName = $.trim($("#poemName").val());
     var poemUser = userId;
     var poemInformation = tinyMCE.activeEditor.getContent();
     var dynastyName = $.trim($("#poemName").val());
     var dynastyUser = userId;
     var dynastyInformation = tinyMCE.activeEditor.getContent();
     var explain = $.trim($("#explain").val());
     var types = $.trim($("#types").val());
    

     var data1 = {
         "poemName": poemName,
         "poemUser": poemUser,
         "poemInformation": poemInformation,
         "explain": explain,
       
     };

     var data2 = {
         "dynastyName": dynastyName,
         "dynastyUser": dynastyUser,
         "dynastyInformation": dynastyInformation,
         "explain": explain,
      
     };
     var type = $.trim($("#type").val());
     if (type == "1") {
         var path = "poem";
         var DATA = data1;
     } else {
         var path = "dynasty";
         var DATA = data2;
     };
     var token = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": token //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/creation/' + path + "/",
         // 请求方式
         type: 'get',
         //成功回调
         data: DATA,
         success: function(data) {
             if (data.code == 200) {
                 alert("发布成功")
                 window.location.href = "./index.html";
             } else {
                 alert("发布失败"),
                     window.location.href = "./index.html";
             }

         },
         error: function(data) {
             alert("链接失败，请稍后再试");

         }
     });
 }
//  修改诗词
function xiugai() {
     var id = document.location.href; //获取页面完整链接
    if (id.search('#') == -1) {
             var ID = id.split("?"); //截取?后的参数
    } else {
         var ID = id.split("#"); //截取?后的参数

    }
     var userId = window.sessionStorage.getItem('userId');
     var token = window.sessionStorage.getItem("yq_token");
     var poemName = $.trim($("#poemName").val());
     var poemUser = userId;
     var poemInformation = tinyMCE.activeEditor.getContent();
     var dynastyName = $.trim($("#poemName").val());
     var dynastyUser = userId;
     var dynastyInformation = tinyMCE.activeEditor.getContent();
     var explain = $.trim($("#explain").val());
     var types = $.trim($("#types").val());
    

     var data1 = {
          "poemId": ID[1],
         "poemName": poemName,
         "poemUser": poemUser,
         "poemInformation": poemInformation,
         "explain": explain
     };

     var data2 = {
         "dynastyName": dynastyName,
         "dynastyId": ID[1],
         "dynastyUser": dynastyUser,
         "dynastyInformation": dynastyInformation,
         "explain": explain
     };
         
     var type = $.trim($("#type").val());
     if (type == "1") {
         var path = "poem";
         var DATA = data1;
     } else {
         var path = "dynasty";
         var DATA = data2;
     };
     var token = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": token //此处放置请求到的用户token
         },
          //contentType: 'application/json;charset=UTF-8',
         url: 'http://127.0.0.1:82/consumer/update/' + path + "/",
         // 请求方式
        type: "GET",
         //成功回调
         data: DATA,
        //  dataType:'json',
         success: function(data) {
             if (data.code == 200) {
                 alert("发布成功")
                 window.location.href = "./guanli.html";
             } else {
                 alert("发布失败")
                     window.location.href = "./guanli.html";
             }

         },
         error: function(data) {
             alert("链接失败，请稍后再试11");

         }
     });
 }
 //  消息中心-词

 function xiaoxici() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");

     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/do/fine/poem/userId/' + userId + '/',
         type: 'GET',
         // data: 'data',
         success: function(data) {

             for (i = 0; i < data.data.length; i++) {
                 {
                     b = '<li><a href="../poetry.html?ownText='+data.data[i].poemId+'"><img src="../assets/images/xiaoxi.svg" alt=""><span>您发布的的诗词《' + data.data[i].poemName + '》共计' + data.data[i].giveLike + '个赞，' + data.data[i].collection + '个收藏<span><p>' + data.data[i].time + '</p>'
                     b += '</a></li>';
                     $(".poems").append(b);
                 }
             }

         }
     });
 }
 //  消息中心-诗
 function xiaoxishi() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/do/fine/dynasty/userId/' + userId + '/',

         type: 'GET',
         // data: 'data',
         success: function(data) {


             for (j = 0; j < data.data.length; j++) {
                 {
                    
                     b = '<li><a href="../ancient%20poetry.html?ownText='+data.data[j].dynastyId+'"><img src="../assets/images/xiaoxi.svg" alt=""><span>您发布的的诗《' + data.data[j].dynastyName + '》共计' + data.data[j].giveLike + '个赞，' + data.data[j].collection + '个收藏</span><p>' + data.data[j].time + '</p>'
                     b += '</a></li>';
                     $(".dynastys").append(b);
                 }
             }

         }
     });
 }
 //  用户中心
 function cinumber() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:84/consumer/see/collection/poem/' + userId + '/',
         type: 'GET',
         data: 'data',
         success: function(data) {
             if(data.code==200){
             document.getElementById("ci-number").innerHTML = data.data.length;
             }
         }
     });
 }

 function shinumber() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:84/consumer/see/collection/dynasty/' + userId + '/',
         type: 'GET',
         data: 'data',
         success: function(data) {
             if(data.code==200){
             document.getElementById("shi-number").innerHTML = data.data.length;
             }
         }
     });
 }
 var userId = sessionStorage.getItem('userId');
 var userToken = sessionStorage.getItem("yq_token");
 //我发布的词
 function fabu_ci() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");

     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/do/fine/poem/userId/' + userId + '/',
         type: 'GET',
         // data: 'data',
         success: function(data) {
             if(data.code==200){
             document.getElementById("fabu_ci").innerHTML = data.data.length;


}
         }
     });
 }

 function fabu_shi() {
     var userId = sessionStorage.getItem('userId');
     var userToken = sessionStorage.getItem("yq_token");

     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:82/consumer/do/fine/dynasty/userId/' + userId + '/',
         type: 'GET',
         // data: 'data',
         success: function(data) {
             if(data.code==200){
             document.getElementById("fabu_shi").innerHTML = data.data.length;

        }

         }
     });
 }
 //获取用户信息
 function user_message() {
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({

         url: 'http://127.0.0.1:81/consumer/user/fineById/' + userId + '/', //请求url
         undefined,
         type: "get",
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         success: function(data) {
             if (data.code == 200) {

                 document.getElementById("user-index-id").innerHTML = '用户ID：' + userId;
                 document.getElementById("user-index-username").innerHTML = '用户昵称：' + data.data.username;
                 document.getElementById("user-index-email").innerHTML = '用户邮箱：' + data.data.email;

             } 
         }
     })
 }
 
 //分类
   function fenleici() {
        var id = document.location.href; //获取页面完整链接
        var ID = id.split("#"); //截取?后的参数
        var userId = sessionStorage.getItem('userId');
        var userToken = sessionStorage.getItem("yq_token");
        // var saveurl = 'http://127.0.0.1:82/consumer/add/'+poem+'/'
        $.ajax({
            undefined,
            headers: {
                undefined,
                "token": userToken //此处放置请求到的用户token
            },
            url: 'http://127.0.0.1:82/consumer/do/fine/poem/poemId/' + ID[1] + '/',
            // 请求方式
            type: 'GET',
            //成功回调
            success: function(data) {
                document.getElementById("shciname").value = data.data.poemName;
                  document.getElementById("shciId").value = data.data.poemId;
                poemleixing()
            },
            // error: function(data) {
            //     alert: ("网络错误,请稍后再试");

            // }
        });
    };
    function poemleixing() {
     var id = document.location.href; //获取页面完整链接
     var ID = id.split("#"); //截取?后的参数
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:88/consumer/see/poem/type/',
         data: {
             'poemId': ID[1]
         },
         dataType: "json",
         type: "get",

         success: function(data) {
             if (data.code = 200) {
                  var num3="";
                   var num2;
                 for (k = 0; k <= data.data.length-1; k++) {
                     var res=data.data.valueOf();
                     var num1 = data.data[k];
                          switch (num1) {
                            case 1:
                                 var num = "春";
                                 num2 = num;
                                break;
                            case 2:
                                 var num = "夏"
                                 num2 = num;
                                break;
                            case 3:
                                 var num = "秋"
                                  num2 =  num;
                                 break;
                            case 4:
                                 var num = "冬"
                                  num2 = num;
                                break;
                            case undefined:
                                break;
                              }
                               num3+=num2+"，"
                           }
                     document.getElementById("shicileixing").value = num3;
                    
            
            }
        }
    })
}


    function fenleishi() {
        var id = document.location.href; //获取页面完整链接
        var ID = id.split("?"); //截取?后的参数
        var userId = sessionStorage.getItem('userId');
        var userToken = sessionStorage.getItem("yq_token");
        //  var saveurl = 'http://127.0.0.1:82/consumer/do/fine/dynasty/dynastyId/' + ID[1] + '/'
        $.ajax({
            undefined,
            headers: {
                undefined,
                "token": userToken //此处放置请求到的用户token
            },
            url: 'http://127.0.0.1:82/consumer/do/fine/dynasty/dynastyId/' + ID[1] + '/',
            // 请求方式
            type: 'GET',
            //成功回调
            success: function(data) {
                document.getElementById("shciname").value = data.data.dynastyName;
                 document.getElementById("shciId").value = data.data.dynastyId;
               dynastyleixing()
            },
        });
    };
    
    function dynastyleixing() {
     var id = document.location.href; //获取页面完整链接
     var ID = id.split("?"); //截取?后的参数
     var userId = window.sessionStorage.getItem('userId');
     var userToken = window.sessionStorage.getItem("yq_token");
     $.ajax({
         undefined,
         headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
         url: 'http://127.0.0.1:88/consumer/see/dynasty/type/',
         data: {
             'dynastyId': ID[1]
         },
         dataType: "json",
         type: "get",
         success: function(data) {
              if (data.code = 200) {
                  var num3="";
                   var num2;
                 for (k = 0; k <= data.data.length-1; k++) {
                     var res=data.data.valueOf();
                     var num1 = data.data[k];
                          switch (num1) {
                            case 1:
                                 var num = "春";
                                 num2 = num;
                                break;
                            case 2:
                                 var num = "夏"
                                 num2 = num;
                                break;
                            case 3:
                                 var num = "秋"
                                  num2 =  num;
                                 break;
                            case 4:
                                 var num = "冬"
                                  num2 = num;
                                break;
                            case undefined:
                                break;
                              }
                               num3+=num2+"，"
                           }
                     document.getElementById("shicileixing").value = num3;
            }
        }
    })
}



    function deleteleixing() {
        var userId = window.sessionStorage.getItem('userId');
        var userToken = window.sessionStorage.getItem("yq_token");
        // var type = document.getElementById("type").value;
        var id = document.location.href; //获取页面完整链接
         
    if (id.search('#') == -1) {
        fenleishi()
         var dynastyId = document.getElementById("shciId").value;
       var deleteurl = 'http://127.0.0.1:88/consumer/delete/DynastyType/'+dynastyId+'/'
      
    //   var data2={
    //             'seasonsId': dynastyId
    //         }
    //   var DATA=data2
       
    } else {
        fenleici()
         var seasonsId = document.getElementById("shciId").value;
        var deleteurl = 'http://127.0.0.1:88/consumer/delete/PoemType/'+seasonsId+'/'
        //  var data1={
        //         'seasonsId': poemId
        //           }
        //  var DATA =data1
    }
        $.ajax({
             undefined,
             headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
            url: deleteurl,
            dataType: "json",
            type: "get",
            success: function(data) {
                if (data.code = 200) {
                    alert("删除类型成功");
                    window.location.href = "../user/guanli.html"
                } else {
                    alert("删除类型失败");
                    window.location.href = "../user/guanli.html"
                }
            },
            error: function(data) {
                alert("网络错误，请稍后重试");
                // window.location.href = "../user/guanli.html"
            }
        });
    }
    
    
     function save() {
        var userId = window.sessionStorage.getItem('userId');
        var userToken = window.sessionStorage.getItem("yq_token");
        var type = document.getElementById("type").value;
        var id = document.location.href; //获取页面完整链接
         
    if (id.search('#') == -1) {
       var saveurl = 'http://127.0.0.1:88/consumer/add/dynasty/type'
       var dynastyId = document.getElementById("shciId").value;
       var data2={
                'type': type,
                'dynastyId': dynastyId
            }
       var DATA=data2
       
    } else {
        var saveurl = 'http://127.0.0.1:88/consumer/add/poem/type'
       
        var poemId = document.getElementById("shciId").value;
         var data1={
                'type': type,
                'poemId': poemId
                   }
         var DATA =data1
    }
        $.ajax({
             undefined,
             headers: {
             undefined,
             "token": userToken //此处放置请求到的用户token
         },
            url: saveurl,
            dataType: "json",
            type: "get",
            data:DATA,
            success: function(data) {
                if (data.code = 200) {
                    alert("修改成功");
                    window.location.href = "../user/guanli.html"
                } else {
                    alert("修改失败");
                    window.location.href = "../user/guanli.html"
                }
            },
            error: function(data) {
                alert("网络错误，请稍后重试");
                window.location.href = "../user/guanli.html"
            }
        });
    }

    function cancel() {
        window.location.href = "../user/guanli.html"
    }