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