login.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <!DOCTYPE html>
  2. <html lang="en">
  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="css/index.css">
  8. <link rel="stylesheet" href="css/login.css">
  9. <script src="js/axios.min.js"></script>
  10. <script src="js/vue.js"></script>
  11. </head>
  12. <body>
  13. <section id="app">
  14. <header>
  15. <div class="left_nav">
  16. <img @click="show=!show" class="phone" width="30" src="img/menu.png" alt="">
  17. <img class="logo" src="img/logo.png" alt="logo">
  18. </div>
  19. <div class="nav">
  20. <a class="act" href="/index.html">主页</a>
  21. <a href="https://match.yuanrenxue.cn/" target="_blank">爬虫逆向比赛</a>
  22. <a href="https://match.yuanrenxue.cn/" target="_blank">采集进阶课程</a>
  23. <a href="https://tool.yuanrenxue.cn/" target="_blank">采集分析工具</a>
  24. <a href="https://appmatch.yuanrenxue.cn/" target="_blank">APP题目</a>
  25. <a href="https://www.yuanrenxue.cn/" target="_blank">关于猿人学</a>
  26. </div>
  27. <div class="login">
  28. <div class="pc">
  29. <!-- <img width="30px" src="img/logo.jpg" alt="logo"> -->
  30. <div v-if="userInfo" class="menu">
  31. {{userInfo.name}}
  32. <ul>
  33. <li><a href="/record.html">我的刷题记录</a></li>
  34. <li @click="logout"><a>退出登录</a></li>
  35. </ul>
  36. </div>
  37. <a v-else href="/login.html">请先登录</a>
  38. </div>
  39. <div class="phone">
  40. <span v-if="userInfo">{{userInfo.name}}</span>
  41. <a v-else href="/login.html">请先登录</a>
  42. </div>
  43. </div>
  44. </header>
  45. <transition name="slide">
  46. <div class="slide" v-if="show">
  47. <a class="act" href="/index.html">主页</a>
  48. <a href="https://match.yuanrenxue.cn/" target="_blank">爬虫逆向比赛</a>
  49. <a href="https://match.yuanrenxue.cn/" target="_blank">采集进阶课程</a>
  50. <a href="https://tool.yuanrenxue.cn/" target="_blank">采集分析工具</a>
  51. <a href="https://appmatch.yuanrenxue.cn/" target="_blank">APP题目</a>
  52. <a href="https://www.yuanrenxue.cn/" target="_blank">关于猿人学</a>
  53. <a v-if="userInfo" href="/record.html">我的刷题记录</a>
  54. <a v-if="userInfo" @click="logout">退出登录</a>
  55. </div>
  56. </transition>
  57. <div class="content" style="justify-content: center;width: 930px;margin-bottom: 50px;">
  58. <p class="navtation"><a href="/index.html">首页</a> - {{showLogin?'登录页':'注册页'}}</p>
  59. <div class="top_bg" style="height: 60vh;">
  60. <div class="signup">
  61. <form v-if="!showLogin" class="form reg" >
  62. <label>昵称</label>
  63. <input type="text" v-model="form.nickname" placeholder="昵称将会展示出来">
  64. <label>注册账号</label>
  65. <input type="text" v-model="form.name" placeholder="登录时的账号">
  66. <label>登录密码</label>
  67. <input type="password" v-model="form.password">
  68. <label>确认密码</label>
  69. <input type="password" v-model="form.repassword">
  70. <label>注册邀请码</label>
  71. <input type="text" v-model="form.invitationCode" placeholder="右侧扫码加我微信,免费领取">
  72. <button type="button" @click="submitForm">立即注册</button>
  73. <p align="center"><a style="cursor: pointer;color: #00f;" @click="showLogin=1">去登录</a></p>
  74. </form>
  75. <form v-else class="form reg" style="padding: 30px;">
  76. <label>账号</label>
  77. <input type="text" v-model="loginForm.name" placeholder="账号">
  78. <label>密码</label>
  79. <input type="password" placeholder="密码" v-model="loginForm.password">
  80. <button type="button" @click="login">立即登录</button>
  81. <p align="center"><a style="cursor: pointer;color: #00f;" @click="showLogin=0">去注册</a></p>
  82. </form>
  83. </div>
  84. <div class="addvx">
  85. 扫码加我微信 <br>
  86. <b>免费领取注册邀请码</b><br>
  87. <img width="50%" src="img/wx.jpg" alt=""><br>
  88. 备注“面试邀请码” <br>
  89. 拉你入猿人学 - 面试交流群
  90. </div>
  91. </div>
  92. </div>
  93. <footer>
  94. <ul>
  95. <li>
  96. <b>爬虫比赛</b> <br>
  97. <a href="https://appmatch.yuanrenxue.cn/" target="_blank">APP题目</a>
  98. <a href="https://match.yuanrenxue.cn/" target="_blank">爬虫逆向比赛</a>
  99. <a href="https://tool.yuanrenxue.cn/" target="_blank">采集分析工具</a>
  100. </li>
  101. <li>
  102. <b>爬虫课程</b> <br>
  103. <a href="https://shop45147253.m.youzan.com/wscgoods/detail/2okabph85ypv1?banner_id=f.86209928~goods.2~1~rVebiaQ5&alg_id=0&slg=0&components_style_layout=0&reft=1744878857227&spm=f.86209928&sf=wx_sm" target="_blank">爬虫逆向进阶课</a>
  104. <a href="https://shop45147253.m.youzan.com/wscgoods/detail/2xli2kj7ku3a5zk?banner_id=f.86209928~goods.2~2~lWrtebiJ&alg_id=0&slg=0&components_style_layout=0&reft=1744878880491&spm=f.86209928&sf=wx_sm" target="_blank">反爬&风控对抗课</a>
  105. <a href="https://shop45147253.m.youzan.com/wscgoods/detail/361rmliyhfwr184?banner_id=f.86209928~goods.2~3~25r4gDL2&alg_id=0&slg=0&components_style_layout=0&reft=1744878921640&spm=f.86209928&sf=wx_sm" target="_blank">0基础+爬虫逆向课</a>
  106. </li>
  107. <li>
  108. <b>关于猿人学</b> <br>
  109. <a href="https://www.yuanrenxue.cn/tricks" target="_blank">Python技术杂谈</a>
  110. <a href="https://www.yuanrenxue.cn/earn-money" target="_blank">Python爬虫挣钱</a>
  111. </li>
  112. <li class="contact" style="display: flex;line-height: 30px;">
  113. <img style="margin-right: 10px;" width="100" height="100" src="img/wx.jpg" alt="">
  114. 扫一扫加我微信 <br>
  115. 备注面试题 <br>
  116. 拉你进面试交流群
  117. </li>
  118. </ul>
  119. <p>成都老猿智能科技有限公司Copyright @ 2025 猿人学面试 蜀ICP备2022000052号-2</p>
  120. </footer>
  121. </section>
  122. <script src="js/public.js"></script>
  123. <script>
  124. const { createApp } = Vue;
  125. createApp({
  126. data() {
  127. return {
  128. showLogin: false,
  129. form: {
  130. name: "",
  131. nickname: "",
  132. password: "",
  133. repassword: "",
  134. invitationCode: ""
  135. },
  136. loginForm: {
  137. name: "",
  138. password: ""
  139. },
  140. userInfo: {}, // 添加 userInfo 变量
  141. show: 0 // 添加 show 变量
  142. }
  143. },
  144. created() {
  145. const userInfo = JSON.parse(localStorage.getItem('userInfo')); // 获取本地存储的用户信息
  146. this.userInfo = userInfo;
  147. },
  148. methods: {
  149. submitForm() {
  150. if (!this.form.name || !this.form.nickname || !this.form.password || !this.form.repassword || !this.form.invitationCode) {
  151. alert('所有字段都不能为空');
  152. return;
  153. }
  154. if (this.form.password !== this.form.repassword) {
  155. alert('两次输入的密码不一致');
  156. return;
  157. }
  158. axios.post(url + '/api/account/regist', this.form)
  159. .then(res => {
  160. localStorage.setItem('token',res.data.data.token);
  161. this.getUser();
  162. window.location.href = '/index.html';
  163. })
  164. .catch(err => {
  165. alert('提交失败,请重试');
  166. console.error(err);
  167. });
  168. },
  169. login() {
  170. if (!this.loginForm.name || !this.loginForm.password) {
  171. alert('所有字段都不能为空');
  172. return;
  173. }
  174. axios.post(url + '/api/account/login', this.loginForm)
  175. .then(res => {
  176. if(res.data.code==0){
  177. // alert('登录成功');
  178. localStorage.setItem('token',res.data.data.token);
  179. this.getUser();
  180. setTimeout(() => {
  181. window.location.href = '/index.html';
  182. }, 500);
  183. }else{
  184. alert(res.data.message);
  185. }
  186. })
  187. .catch(err => {
  188. alert('登录失败,请重试');
  189. console.error(err);
  190. });
  191. },
  192. getUser(){
  193. // 获取token
  194. const token = localStorage.getItem('token');
  195. axios.get(url + '/api/account/userinfo', {
  196. headers: {
  197. 'Authorization': `${token}`
  198. }
  199. })
  200. .then(res => {
  201. if (res.data.code === 0) {
  202. localStorage.setItem('userInfo', JSON.stringify(res.data.data));
  203. }
  204. })
  205. },
  206. logout() { // 添加 logout 方法
  207. localStorage.removeItem('userInfo');
  208. localStorage.removeItem('token');
  209. this.userInfo = null;
  210. }
  211. }
  212. }).mount('#app');
  213. </script>
  214. </body>
  215. </html>