parent
4c8b9f506a
commit
a003b437ce
@ -1,52 +1,68 @@
|
||||
Page({
|
||||
formSubmit: function (e) {
|
||||
wx.request({
|
||||
url: 'http://localhost:9527/zxlogin/login',
|
||||
data: {
|
||||
'userid': e.detail.value.userid,
|
||||
'userpassword': e.detail.value.userpassword,
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
|
||||
methods: {
|
||||
method: "POST",
|
||||
},
|
||||
success: function (res) {
|
||||
console.log(res.data);
|
||||
if (res.data == "111") {
|
||||
wx.showModal({
|
||||
title: '登录消息',
|
||||
content: '登录成功',
|
||||
confirmColor: "rgba(253, 153, 65, 1)",
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
wx.switchTab({
|
||||
url: '../shouye/shouye',
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
else if (res.data == "100") {
|
||||
wx.showModal({
|
||||
title: '登录消息',
|
||||
content: '密码错误',
|
||||
confirmColor: "rgba(253, 153, 65, 1)"
|
||||
})
|
||||
}
|
||||
else if (res.data == "001") {
|
||||
wx.showModal({
|
||||
title: '登录消息',
|
||||
content: '用户名不存在',
|
||||
confirmColor: "rgba(253, 153, 65, 1)"
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log("失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
Page({
|
||||
formSubmit: function (e) {
|
||||
wx.request({
|
||||
url: 'http://localhost:9528/zxlogin/login',
|
||||
data: {
|
||||
'userid': e.detail.value.userid,
|
||||
'userpassword': e.detail.value.userpassword,
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
|
||||
methods: {
|
||||
method: "POST",
|
||||
},
|
||||
success: function (res) {
|
||||
var book = res.data
|
||||
let bookstr = JSON.stringify(book);
|
||||
console.log(book);
|
||||
if (res.data == "100") {
|
||||
wx.showModal({
|
||||
title: '登录消息',
|
||||
content: '密码错误',
|
||||
confirmColor: "rgba(253, 153, 65, 1)"
|
||||
})
|
||||
}
|
||||
|
||||
else if (res.data == "001") {
|
||||
wx.showModal({
|
||||
title: '登录消息',
|
||||
content: '用户名不存在',
|
||||
confirmColor: "rgba(253, 153, 65, 1)"
|
||||
})
|
||||
}
|
||||
else {
|
||||
wx.showModal({
|
||||
title: '登录消息',
|
||||
content: '登录成功',
|
||||
confirmColor: "rgba(253, 153, 65, 1)",
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
wx.switchTab({
|
||||
url: '../shouye/shouye',
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log("失败");
|
||||
}
|
||||
})
|
||||
},
|
||||
wx.request({
|
||||
url: 'http://localhost:9528/zxbook/find2',
|
||||
data: {
|
||||
'search': e.target.id,
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
methods: {
|
||||
method: "POST",
|
||||
},
|
||||
|
||||
})
|
@ -1,4 +1,5 @@
|
||||
<image class="wx-image_TCMtbw" mode="scaleToFill" src="//o3bnyc.creatby.com/diazo/images/image-placeholder.svg" style="background-size: 100% 100%; background-position: 0% 0%; background-repeat: no-repeat; background-image: url(http://o3bnyc.creatby.com/diazo/images/image-placeholder.svg);"/>
|
||||
<text class="c-block wx-text_3ayXhS" > 姓名:</text>
|
||||
<text class="c-block wx-text_cEEG0A" > 学号:</text>
|
||||
<text class="c-block wx-text_lkXRAs" > 密码:</text>
|
||||
<text class="c-block wx-text_3ayXhS" > 姓名:</text>
|
||||
<input class="inputText" maxlength="15" name="userid"value="{{userid}}" />
|
||||
<text class="c-block wx-text_cEEG0A" > 学号:${userpassword}</text>
|
||||
<text class="c-block wx-text_lkXRAs" > 密码:${username}</text>
|
@ -1,57 +1,61 @@
|
||||
package controller;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import service.LoginService;
|
||||
import domain.UserPO;
|
||||
|
||||
@Controller
|
||||
public class LoginController {
|
||||
@Autowired@Qualifier("LoginServiceImpl")
|
||||
private LoginService loginService;
|
||||
@RequestMapping("/login")
|
||||
public void login(int userid, int userpassword,
|
||||
HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
UserPO userPO=this.loginService.FindByUserid(userid);
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
/* 设置响应头允许ajax跨域访问 */
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
/* 星号表示所有的异域请求都可以接受, */
|
||||
response.setHeader("Access-Control-Allow-Methods", "GET,POST");
|
||||
System.out.println(userid);
|
||||
if(userPO!=null)
|
||||
if(userpassword==userPO.getUserpassword())
|
||||
{
|
||||
System.out.println("密码正确");
|
||||
Writer out = response.getWriter();
|
||||
out.write("111");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
else{
|
||||
System.out.println("密码错误");
|
||||
Writer out = response.getWriter();
|
||||
out.write("100");
|
||||
out.flush();
|
||||
}
|
||||
else{
|
||||
System.out.println("不存在用户名");
|
||||
Writer out = response.getWriter();
|
||||
out.write("001");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
package controller;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import service.LoginService;
|
||||
import domain.UserPO;
|
||||
|
||||
@Controller
|
||||
public class LoginController {
|
||||
@Autowired@Qualifier("LoginServiceImpl")
|
||||
private LoginService loginService;
|
||||
@RequestMapping("/login")
|
||||
public void login(int userid, int userpassword,
|
||||
HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
UserPO userPO=this.loginService.FindByUserid(userid);
|
||||
response.setContentType("text/html;charset=utf-8");
|
||||
/* 设置响应头允许ajax跨域访问 */
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
/* 星号表示所有的异域请求都可以接受, */
|
||||
response.setHeader("Access-Control-Allow-Methods", "GET,POST");
|
||||
System.out.println(userid);
|
||||
if(userPO!=null)
|
||||
if(userpassword==userPO.getUserpassword())
|
||||
{
|
||||
System.out.println("密码正确");
|
||||
String ss = new Gson().toJson(userPO);
|
||||
Writer out = response.getWriter();
|
||||
out.write(ss);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
else{
|
||||
System.out.println("密码错误");
|
||||
Writer out = response.getWriter();
|
||||
out.write("100");
|
||||
out.flush();
|
||||
}
|
||||
else{
|
||||
System.out.println("不存在用户名");
|
||||
Writer out = response.getWriter();
|
||||
out.write("001");
|
||||
out.flush();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
package mapperDAO;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import domain.UserPO;
|
||||
|
||||
@Repository("UserDAO")
|
||||
public interface UserDAO {
|
||||
public UserPO FindByUserid(int userid);
|
||||
|
||||
|
||||
}
|
||||
package mapperDAO;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import domain.UserPO;
|
||||
|
||||
@Repository("UserDAO")
|
||||
public interface UserDAO {
|
||||
public UserPO FindByUserid(int userid);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package service;
|
||||
|
||||
import domain.UserPO;
|
||||
|
||||
public interface LoginService{
|
||||
|
||||
public UserPO FindByUserid(int userid);
|
||||
}
|
||||
|
||||
package service;
|
||||
|
||||
import domain.UserPO;
|
||||
|
||||
public interface LoginService{
|
||||
|
||||
public UserPO FindByUserid(int userid);
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,23 @@
|
||||
|
||||
package serviceimpl;
|
||||
|
||||
import mapperDAO.UserDAO;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import domain.UserPO;
|
||||
import service.LoginService;
|
||||
|
||||
@Component("LoginServiceImpl")
|
||||
public class LoginServiceImpl implements LoginService{
|
||||
@Autowired@Qualifier("UserDAO")
|
||||
private UserDAO userDAO;
|
||||
|
||||
|
||||
public UserPO FindByUserid(int userid){
|
||||
return this.userDAO.FindByUserid(userid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package serviceimpl;
|
||||
|
||||
import mapperDAO.UserDAO;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import domain.UserPO;
|
||||
import service.LoginService;
|
||||
|
||||
@Component("LoginServiceImpl")
|
||||
public class LoginServiceImpl implements LoginService{
|
||||
@Autowired@Qualifier("UserDAO")
|
||||
private UserDAO userDAO;
|
||||
|
||||
|
||||
public UserPO FindByUserid(int userid){
|
||||
return this.userDAO.FindByUserid(userid);
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
Loading…
Reference in new issue