登录页与注册页的配置

# 配置步骤 1. 新增子域名 2. 更新NGINX和网关 3. 静态文件的迁移, 页面的转移 4. 配置类 # 视图配置类 ## 为什么需要视图配置类 > 因为跳转到该页面不需要渲染视图, 因此, 如果一个controller里面的方法专门做跳转, 没有必要, 很麻烦 ## 代码 ```java @Configuration public class ViewConfig implements WebMvcConfigurer { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/reg.html") .setViewName("reg"); // 注册页面 } } ``` ```java @GetMapping("login.html") public ModelAndView toLogin(ModelAndView mv, HttpSession session) { if (session.getAttribute(UserConstant.SESSION_USER_NAME) != null) { // 已经登陆过了, 重定向到首页 mv.setViewName("redirect://http://www.bitmall.com"); }else { mv.setViewName("login"); } return mv; } ``` ## 页面修改 > 登录页的修改在jd.css文件 ### 倒计时的实现逻辑 ```js var num = 60; function timeoutChangeStyle() { $("#sendCode").attr("class","disabled"); if(num == 0) { $("#sendCode").text("发送验证码"); num = 61; $("#sendCode").attr("class",""); } else { var str = num + "s 后再次发送"; $("#sendCode").text(str); setTimeout("timeoutChangeStyle()",1000); } num --; } ``` > 倒计时的实现逻辑是递归, 因为setTime方法可以启动一个计时任务, 我们可以每过1秒递归一下, 并设置一个外部变量, 通过每次递归来减小这个便来来实现倒计时 > 该倒计时有一个问题, 即重复点击问题, 这样会同时启动多个倒计时, 导致飞快的衰减, 这里可以通过, 一旦点击就添加一个类, 如果有这个类就忽略点击, 倒计时结束再把这个类去掉