<?php
require '../conn/conn.php';
require '../conn/function.php';
require 'admin_check.php';

$action=$_GET["action"];
if($action=="save"){

  $C_pid=$_POST["C_pid"];
  $C_pkey=$_POST["C_pkey"];
  $C_wxid=$_POST["C_wxid"];
  $C_wxkey=$_POST["C_wxkey"];

  if($C_wxid==""){
    die("请填全信息");
  }else{
    mysqli_query($conn,"update sl_config set C_pid='$C_pid',C_pkey='$C_pkey',C_wxid='$C_wxid',C_wxkey='$C_wxkey'");
    die("success");
  }
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>基本设置 - 后台管理</title>
<link rel="icon" href="../media/<?php echo $C_ico?>" type="image/ico">
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/materialdesignicons.min.css" rel="stylesheet">
<link href="../css/style.min.css" rel="stylesheet">
<script type="text/javascript" src="../upload/upload.js"></script>
<style type="text/css">
.showpic{height: 60px;border: solid 1px #DDDDDD;padding: 5px;}
</style>
</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
  <?php require 'nav.php';?>
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <form class="form-horizontal" id="form">
          <div class="col-md-6">
            
            <div class="card">
              <div class="card-header"><h4>收款设置</h4></div>
              <div class="card-body">
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">7支付PID</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_pid" value="<?php echo $C_pid?>">
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">7支付PKEY</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_pkey" value="<?php echo $C_pkey?>">
                      <div style="font-size: 12px;margin-top: 10px;color: #33cabb">请到<a href="https://7-pay.cn" target="_blank"><u>7支付官网</u></a>申请收款接口 <a href="https://7ym.me/help/?id=2" class="btn btn-xs btn-success" target="_blank">帮助文档</a></div>
                    </div>
                  </div>
                  
                  
              </div>
            </div>
          </div>

          <div class="col-md-6">
            <div class="card">
              <div class="card-header"><h4>微信接口设置</h4></div>
              <div class="card-body">
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">微信APPID</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_wxid" value="<?php echo $C_wxid?>">
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-xs-12" for="example-email-input">微信APPsecret</label>
                    <div class="col-xs-12">
                      <input class="form-control" type="text" name="C_wxkey" value="<?php echo $C_wxkey?>">
                      <div style="font-size: 12px;margin-top: 10px;color: #33cabb">请到<a href="https://mp.weixin.qq.com" target="_blank"><u>微信公众平台</u></a>申请微信接口 <a href="https://7ym.me/help/?id=1" class="btn btn-xs btn-success" target="_blank">帮助文档</a></div>
                    </div>
                  </div>
                  
                  
              </div>
            </div>
            
          </div>
<div class="col-md-12">
  <button class="btn btn-primary" onclick="save()" type="button">保存</button>
</div>

        </form>
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="../js/main.min.js"></script>

<script src="../js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="../js/lightyear.js"></script>

<script type="text/javascript">
    function save(){
      lightyear.loading('show');
        $.ajax({
                url:'?action=save',
                type:'post',
                data:$("#form").serialize(),
                success:function (data) {
                lightyear.loading('hide');
                if(data=="success"){
                  lightyear.notify("保存成功", 'success', 100);
                }else{
                  lightyear.notify(data, 'danger', 100);
                }
                }
              });
      }

  var path=window.location.pathname;
  $("a").each(function(){
    if(path.indexOf($(this).attr("href"))!=-1){
      console.log($(this).attr("href"));
      $(this).parent("li").addClass("active");
      $(this).parent("li").parent("ul").parent("li").addClass("open active");
    }
  });
</script>
</body>
</html>