公众号登录

This commit is contained in:
zhanglipeng 2021-04-22 17:10:15 +08:00
parent f4f6716ce6
commit 04cb415ef0
3 changed files with 12 additions and 7 deletions

View File

@ -28,9 +28,13 @@ export default {
wxlogin(this.code).then((res) => { wxlogin(this.code).then((res) => {
console.log(res); console.log(res);
if (res.code == "200") { if (res.code == "200") {
if (res.token == "") {
this.$router.push({ path: "/login" });
} else {
setToken(res.token); setToken(res.token);
this.$router.push({ path: "/index" }); this.$router.push({ path: "/index" });
} }
}
}); });
} }
}, },

View File

@ -99,10 +99,10 @@ public class SysLoginController {
if (sysUser != null) { if (sysUser != null) {
token = loginService.wxlogin(sysUser.getUserName(), sysUser.getPw()); token = loginService.wxlogin(sysUser.getUserName(), sysUser.getPw());
} else { } else {
return AjaxResult.error("登录失败"); ajax.put("msg","登录失败");
} }
} catch (Exception e) { } catch (Exception e) {
return AjaxResult.error("登录失败"); ajax.put("msg","登录失败");
} }
ajax.put(Constants.TOKEN, token); ajax.put(Constants.TOKEN, token);
return ajax; return ajax;

View File

@ -248,6 +248,7 @@ public class SysUserController extends BaseController {
user.setEmail(user.getUserName() + "@benyi.com"); user.setEmail(user.getUserName() + "@benyi.com");
user.setCreateBy(SecurityUtils.getUsername()); user.setCreateBy(SecurityUtils.getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setPw(user.getPassword());
int bl = userService.insertUser(user); int bl = userService.insertUser(user);
if (bl > 0) { if (bl > 0) {
ByTeacherJbxx byTeacherJbxx = new ByTeacherJbxx(); ByTeacherJbxx byTeacherJbxx = new ByTeacherJbxx();