user-login.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <!-- <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>登录</title>
  7. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  14. }
  15. body {
  16. display: flex;
  17. justify-content: center;
  18. align-items: center;
  19. min-height: 100vh;
  20. background: linear-gradient(135deg, #6e8efb, #a777e3);
  21. padding: 20px;
  22. }
  23. .container {
  24. width: 100%;
  25. max-width: 400px;
  26. background: rgba(255, 255, 255, 0.9);
  27. border-radius: 16px;
  28. box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  29. overflow: hidden;
  30. }
  31. .header {
  32. background: linear-gradient(135deg, #6e8efb, #a777e3);
  33. color: white;
  34. text-align: center;
  35. padding: 30px 20px;
  36. }
  37. .header h1 {
  38. font-size: 28px;
  39. margin-bottom: 10px;
  40. }
  41. .header p {
  42. font-size: 14px;
  43. opacity: 0.9;
  44. }
  45. .form-container {
  46. padding: 30px 20px;
  47. }
  48. .input-group {
  49. margin-bottom: 20px;
  50. position: relative;
  51. }
  52. .input-group label {
  53. display: block;
  54. margin-bottom: 8px;
  55. font-weight: 500;
  56. color: #333;
  57. }
  58. .input-group input {
  59. width: 100%;
  60. padding: 14px 14px 14px 45px;
  61. border: 1px solid #ddd;
  62. border-radius: 8px;
  63. font-size: 16px;
  64. transition: all 0.3s;
  65. }
  66. .input-group input:focus {
  67. outline: none;
  68. border-color: #6e8efb;
  69. box-shadow: 0 0 0 2px rgba(110, 142, 251, 0.2);
  70. }
  71. .input-group i {
  72. position: absolute;
  73. left: 15px;
  74. top: 40px;
  75. color: #6e8efb;
  76. }
  77. .remember-forgot {
  78. display: flex;
  79. justify-content: space-between;
  80. margin-bottom: 20px;
  81. font-size: 14px;
  82. }
  83. .remember-forgot label {
  84. display: flex;
  85. align-items: center;
  86. color: #555;
  87. }
  88. .remember-forgot input {
  89. margin-right: 5px;
  90. }
  91. .remember-forgot a {
  92. color: #6e8efb;
  93. text-decoration: none;
  94. }
  95. .remember-forgot a:hover {
  96. text-decoration: underline;
  97. }
  98. .btn {
  99. width: 100%;
  100. padding: 14px;
  101. background: linear-gradient(135deg, #6e8efb, #a777e3);
  102. color: white;
  103. border: none;
  104. border-radius: 8px;
  105. font-size: 16px;
  106. font-weight: 600;
  107. cursor: pointer;
  108. transition: all 0.3s;
  109. }
  110. .btn:hover {
  111. transform: translateY(-2px);
  112. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  113. }
  114. .register-link {
  115. text-align: center;
  116. margin-top: 20px;
  117. font-size: 14px;
  118. color: #555;
  119. }
  120. .register-link a {
  121. color: #6e8efb;
  122. text-decoration: none;
  123. font-weight: 500;
  124. }
  125. .register-link a:hover {
  126. text-decoration: underline;
  127. }
  128. .message {
  129. padding: 10px;
  130. margin-top: 15px;
  131. border-radius: 5px;
  132. text-align: center;
  133. display: none;
  134. }
  135. .error {
  136. background-color: #ffebee;
  137. color: #d32f2f;
  138. border: 1px solid #ffcdd2;
  139. }
  140. .success {
  141. background-color: #e8f5e9;
  142. color: #388e3c;
  143. border: 1px solid #c8e6c9;
  144. }
  145. @media (max-width: 480px) {
  146. .container {
  147. border-radius: 12px;
  148. }
  149. .header {
  150. padding: 20px 15px;
  151. }
  152. .form-container {
  153. padding: 20px 15px;
  154. }
  155. }
  156. </style>
  157. </head>
  158. <body>
  159. <div class="container">
  160. <div class="header">
  161. <h1>欢迎回来</h1>
  162. <p>请输入您的用户名和密码进行登录</p>
  163. </div>
  164. <div class="form-container">
  165. <div class="input-group">
  166. <label for="username">用户名</label>
  167. <i class="fas fa-user"></i>
  168. <input type="text" id="username" placeholder="请输入用户名">
  169. </div>
  170. <div class="input-group">
  171. <label for="password">密码</label>
  172. <i class="fas fa-lock"></i>
  173. <input type="password" id="password" placeholder="请输入密码">
  174. </div>
  175. <div class="remember-forgot">
  176. <label>
  177. <input type="checkbox" id="remember">
  178. 记住我
  179. </label>
  180. <a href="#">忘记密码?</a>
  181. </div>
  182. <button class="btn" id="loginBtn">登录</button>
  183. <div id="message" class="message"></div>
  184. <div class="register-link">
  185. 还没有账号?<a href="#">立即注册</a>
  186. </div>
  187. </div>
  188. </div>
  189. <script>
  190. document.addEventListener('DOMContentLoaded', function () {
  191. // Mock用户数据
  192. const mockUsers = [
  193. { username: 'admin', password: 'admin123' },
  194. { username: 'user', password: 'user123' },
  195. { username: 'test', password: 'test123' },
  196. { username: 'demo', password: 'demo123' }
  197. ];
  198. const loginBtn = document.getElementById('loginBtn');
  199. const usernameInput = document.getElementById('username');
  200. const passwordInput = document.getElementById('password');
  201. const rememberCheckbox = document.getElementById('remember');
  202. const messageDiv = document.getElementById('message');
  203. // 检查是否有保存的用户名
  204. const savedUsername = localStorage.getItem('rememberedUsername');
  205. if (savedUsername) {
  206. usernameInput.value = savedUsername;
  207. rememberCheckbox.checked = true;
  208. }
  209. loginBtn.addEventListener('click', async function () {
  210. const username = usernameInput.value.trim();
  211. const password = passwordInput.value;
  212. // 简单的表单验证
  213. if (!username || !password) {
  214. showMessage('请输入用户名和密码', 'error');
  215. return;
  216. }
  217. // 验证用户凭据
  218. const user = mockUsers.find(u => u.username === username && u.password === password);
  219. let loginObj = {
  220. username: username,
  221. password: password
  222. }
  223. let res = await fetch("https://dev.fmode.cn/parse/login", {
  224. "headers": {
  225. "accept": "*/*",
  226. "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
  227. "content-type": "text/plain;charset=UTF-8",
  228. "x-parse-application-id": "dev"
  229. },
  230. "body": JSON.stringify(loginObj),
  231. "method": "POST",
  232. "mode": "cors",
  233. "credentials": "omit"
  234. });
  235. const data = await res.json();
  236. console.log(data)
  237. if (data?.objectId) {
  238. // 如果勾选了"记住我",保存用户名
  239. if (rememberCheckbox.checked) {
  240. localStorage.setItem('rememberedUsername', username);
  241. } else {
  242. localStorage.removeItem('rememberedUsername');
  243. }
  244. showMessage('登录成功!正在跳转...', 'success');
  245. // 模拟登录成功后的跳转
  246. setTimeout(() => {
  247. alert('登录成功!欢迎 ' + username);
  248. // 在实际应用中,这里会跳转到首页或其他页面
  249. // window.location.href = '/home';
  250. }, 1000);
  251. } else {
  252. showMessage('用户名或密码错误', 'error');
  253. }
  254. });
  255. function showMessage(message, type) {
  256. messageDiv.textContent = message;
  257. messageDiv.className = 'message ' + type;
  258. messageDiv.style.display = 'block';
  259. // 3秒后隐藏消息
  260. setTimeout(() => {
  261. messageDiv.style.display = 'none';
  262. }, 3000);
  263. }
  264. // 按Enter键也可以触发登录
  265. passwordInput.addEventListener('keypress', function (e) {
  266. if (e.key === 'Enter') {
  267. loginBtn.click();
  268. }
  269. });
  270. });
  271. </script>
  272. </body>
  273. </html> -->
  274. <!DOCTYPE html>
  275. <html lang="en">
  276. <head>
  277. <meta charset="UTF-8">
  278. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  279. <title>Parse.User基本用法示例</title>
  280. <script src="https://npmcdn.com/parse/dist/parse.min.js"></script>
  281. </head>
  282. <body>
  283. <script>
  284. Parse.initialize("dev");
  285. Parse.serverURL = 'https://dev.fmode.cn/parse'
  286. async function register(){
  287. let username = document.getElementById("username").value
  288. let password = document.getElementById("password").value
  289. let user = new Parse.User()
  290. user.set("username",username)
  291. user.set("password",password)
  292. try {
  293. let result = await user.signUp();
  294. console.log(result)
  295. // Hooray! Let them use the app now.
  296. } catch (error) {
  297. // Show the error message somewhere and let the user try again.
  298. alert("Error: " + error.code + " " + error.message);
  299. }
  300. }
  301. async function login(){
  302. let username = document.getElementById("username").value
  303. let password = document.getElementById("password").value
  304. const user = await Parse.User.logIn(username, password);
  305. }
  306. async function logout(){
  307. Parse.User.logOut();
  308. }
  309. // 测试ACL读写权限
  310. async function onCheck() {
  311. let query = new Parse.Query('Bill')
  312. let res = await query.get('Zgfr3OXoRm')
  313. console.log(res);
  314. if(res?.id){
  315. res.set('desc','游戏1')
  316. await res.save()
  317. console.log('读写成功');
  318. }
  319. }
  320. </script>
  321. <div>用户信息<span id="userinfo"></span></div>
  322. <script>
  323. document.getElementById("userinfo").innerHTML = Parse.User.current().id + Parse.User.current().get("username")
  324. </script>
  325. <input type="text" id="username">
  326. <input type="text" id="password">
  327. <button onclick="register()">注册</button>
  328. <button onclick="login()">登录</button>
  329. <button onclick="logout()">登出</button>
  330. <button onclick="onCheck()">修改数据</button>
  331. </body>
  332. </html>