<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.0</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" href="./static/css/font.css">
        <link rel="stylesheet" href="./static/css/xadmin.css">
        <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
    </head>
    <body onload="InitParams({{.Version}}, {{.IsCoverNext}}, {{.Adpull1}}, {{.Adpull2}}, {{.Url}})">
    <div class="x-body layui-anim layui-anim-up">
        <blockquote class="layui-elem-quote">
          版本:<input id="version" type="text" name="iVersion" />
          <br>
          <br>
          <input class="layui-btn" type="button" onclick="submitAtom()" value=查看>
          <br>
          <br>
          <br>
          <br>
          是否打开B包热更:
          <input id="b_hotfix"  type="text" name="bHotfix">
          <br>
          adpull_1:
          <input id="adpull_1"  type="text" name="Adpull_1">
          <br>
          adpull_2:
          <input id="adpull_2"  type="text" name="Adpull_2">
          <br>
          B包更新地址:
          <input id="url"  type="text" name="Url">
          <br>
          <br>
          
          <input class="layui-btn" type="button" onclick="submitUpdate()" value=更新>
        </blockquote>
    </div>
    </body>
    <script type="text/javascript">
      function InitParams(Version, IsCoverNext, Adpull1, Adpull2, Url) {
        if (Version.length > 0) {
            document.getElementById("version").value = Version;
        }
        if (IsCoverNext.length > 0) {
            document.getElementById("b_hotfix").value = IsCoverNext;
        }
        if (Adpull1.length > 0) {
            document.getElementById("adpull_1").value = Adpull1;
        }
        if (Adpull2.length > 0) {
            document.getElementById("adpull_2").value = Adpull2;
        }
        if (Url.length > 0) {
            document.getElementById("url").value = Url;
        }
      }

      function submitAtom () {
        var version = document.getElementById("version").value
        // var text = "action=get" + "&version=" + encodeURI(version)
        var text = "ver=" + encodeURI(version)
        
        $.ajax({
          type:"get",
          url:"/version?" + text,
          success:function (data) {
            // alert(data.status);
            if (data.status){
              window.location.href="/version?"+text;
              if (data.info){
                layer.msg(data.info,{icon:1,time:1000});
              }
            }else{
              if (data.info){
                alert(data.info);
              }else{
                window.location.href="/version?"+text;
              }
            }
          }
        });
      }
      
      function submitUpdate () {
        var version = document.getElementById("version").value;
        var b_hotfix = document.getElementById("b_hotfix").value;
        var adpull_1 = document.getElementById("adpull_1").value;
        var adpull_2 = document.getElementById("adpull_2").value;
        var url = document.getElementById("url").value;
        var text = "ver=" + encodeURI(version) + "&b_hotfix=" + encodeURI(b_hotfix) + "&adpull_1=" + encodeURI(adpull_1) + "&adpull_2=" + encodeURI(adpull_2) + "&url=" + encodeURI(url);
        
        $.ajax({
          type:"post",
          url:"/version?" + text,
          success:function (data) {
            // alert(data.status);
            if (data.status){
              window.location.href="/version?"+text;
              if (data.info){
                layer.msg(data.info,{icon:1,time:1000});
              }
            }else{
              if (data.info){
                alert(data.info);
              }else{
                window.location.href="/version?"+text;
              }
            }
          }
        });
      }
    </script>
</html>