代码已上传至Github 地址:https://github.com/ylw-github/pingyougou.git 版本:7dd367d056e4929670012a059cd52db4333f6b87
前端修改 register.html 引入 JS
指令
绑定表单(部分代码)
登陆名(不可修改):
登陆密码:
修改 sellerController.js ,在保存成功后跳转到登陆页
// 保存
$scope.save = function() {
//商家注册
sellerService.add($scope.entity).success(function(response) {
if (response.success) {
// 跳转到商品登录页面
location.href = "shoplogin.html";
} else {
alert(response.message);
}
});
}
绑定“申请入驻”按钮
申请入驻
后端代码
修改后端代码,设置默认状态为 0,也可以使用insertSelctive 进行保存。
/**
* 增加
* @param seller
* @return
*/
@RequestMapping("/add")
public PygResult add(@RequestBody TbSeller seller){
try {
//给商家密码加密
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
String newpwd = passwordEncoder.encode(seller.getPassword());
//把加密后密码设置到对象中
seller.setPassword(newpwd);
//保存
sellerService.add(seller);
return new PygResult(true, "增加成功");
} catch (Exception e) {
e.printStackTrace();
return new PygResult(false, "增加失败");
}
}