<?php session_start();include 'common.php';if($_SERVER['REQUEST_METHOD']==='POST'){$u=trim($_POST['username']);$p=trim($_POST['password']);$f='user/'.APPID1.suffix;$us=file_exists($f)?json_decode(file_get_contents($f),true):[];if(isset($us[$u])&&password_verify($p,$us[$u])){$_SESSION['user']=$u;header('Location: index.php');exit;}$e="用户名或密码错误";}?><!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8"><title>登录账号</title><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"><style>body{background:#fff;font-family:"PingFang SC","Helvetica Neue",Helvetica,Arial,"Microsoft YaHei",sans-serif;margin:0}.login-wrap{max-width:900px;margin:60px auto 0;padding:0 16px}.login-form{margin:0 auto;max-width:1200px}.login-input{width:100%;box-sizing:border-box;font-size:18px;padding:10px 12px;border:1px solid #d3d6db;border-radius:5px;margin-bottom:23px;outline:none;transition:border .2s;background:#fafbfc}.login-input:focus{border-color:#6a7ba2;background:#fff}.login-row{margin-bottom:16px;display:flex;align-items:center}.login-checkbox{width:18px;height:18px;margin-right:6px}.login-label{font-size:16px;color:#222}.login-btn{display:block;width:100%;background:#393f45;color:#fff;border:none;border-radius:6px;padding:13px 0;font-size:22px;font-weight:500;letter-spacing:8px;cursor:pointer;text-align:center;margin-top:12px;transition:background .17s}.login-btn:hover{background:#23272c}.login-error{color:#e74c3c;background:#fff4f2;border:1px solid #f3b5b2;padding:10px 13px;border-radius:6px;margin-bottom:20px;font-size:.96em;text-align:center}.login-links{margin-top:22px;text-align:center}.login-links a{color:#393f45;text-decoration:underline;font-size:16px;margin:0 7px;transition:color .18s}.login-links a:hover{color:#6a7ba2}@media (max-width:600px){.login-wrap{margin:24px 0 0}.login-btn{font-size:18px;letter-spacing:3px}.login-input{font-size:16px}}</style></head><body><div class="login-wrap"><form class="login-form" method="post" autocomplete="off"><?php if(!empty($e))echo "<div class='login-error'>$e</div>";?><input class="login-input" type="text" name="username" placeholder="手机号/用户名" required autocomplete="username" value="<?=htmlspecialchars($_POST['username']??'')?>"><input class="login-input" type="password" name="password" placeholder="密码" required autocomplete="current-password"><div class="login-row"><input class="login-checkbox" type="checkbox" id="remember" checked><label class="login-label" for="remember">保存账号密码</label></div><button class="login-btn" type="submit">登录</button></form><div class="login-links">没有账号？<a href="register.php">去注册</a></div></div><script>const u=document.querySelector('input[name="username"]'),p=document.querySelector('input[name="password"]'),r=document.getElementById('remember');if(localStorage.getItem('login_user'))u.value=localStorage.getItem('login_user');if(localStorage.getItem('login_pass'))p.value=localStorage.getItem('login_pass');r.addEventListener('change',function(){this.checked||(localStorage.removeItem('login_user'),localStorage.removeItem('login_pass'))});document.querySelector('form').addEventListener('submit',function(){r.checked?(localStorage.setItem('login_user',u.value),localStorage.setItem('login_pass',p.value)):(localStorage.removeItem('login_user'),localStorage.removeItem('login_pass'))});</script></body></html><?php include'footer.php';?>
