login.html 10 KB

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