diff --git a/web/.DS_Store b/web/.DS_Store index 31c3772..f988ffb 100644 Binary files a/web/.DS_Store and b/web/.DS_Store differ diff --git a/web/.classpath b/web/.classpath new file mode 100644 index 0000000..e845c72 --- /dev/null +++ b/web/.classpath @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/.project b/web/.project new file mode 100644 index 0000000..25281a8 --- /dev/null +++ b/web/.project @@ -0,0 +1,31 @@ + + + web + + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.jdt.core.javanature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/web/.settings/.jsdtscope b/web/.settings/.jsdtscope new file mode 100644 index 0000000..cca691f --- /dev/null +++ b/web/.settings/.jsdtscope @@ -0,0 +1,7 @@ + + + + + + + diff --git a/web/.settings/org.eclipse.jdt.core.prefs b/web/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f42de36 --- /dev/null +++ b/web/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/web/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs b/web/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs new file mode 100644 index 0000000..7c8126d --- /dev/null +++ b/web/.settings/org.eclipse.jst.j2ee.ejb.annotations.xdoclet.prefs @@ -0,0 +1,5 @@ +XDOCLETBUILDERACTIVE=true +XDOCLETHOME= +XDOCLETUSEGLOBAL=true +XDOCLETVERSION=1.2.1 +eclipse.preferences.version=1 diff --git a/web/.settings/org.eclipse.wst.common.component b/web/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..6e7676d --- /dev/null +++ b/web/.settings/org.eclipse.wst.common.component @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/web/.settings/org.eclipse.wst.common.project.facet.core.xml b/web/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..3d742bb --- /dev/null +++ b/web/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/web/.settings/org.eclipse.wst.jsdt.ui.superType.container b/web/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..49c8cd4 --- /dev/null +++ b/web/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.JRE_CONTAINER \ No newline at end of file diff --git a/web/.settings/org.eclipse.wst.jsdt.ui.superType.name b/web/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..11006e2 --- /dev/null +++ b/web/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Global \ No newline at end of file diff --git a/web/WEB-INF/.DS_Store b/web/WEB-INF/.DS_Store index 0ca8a47..71cd328 100644 Binary files a/web/WEB-INF/.DS_Store and b/web/WEB-INF/.DS_Store differ diff --git a/web/WEB-INF/lib/.DS_Store b/web/WEB-INF/lib/.DS_Store new file mode 100644 index 0000000..93a4cae Binary files /dev/null and b/web/WEB-INF/lib/.DS_Store differ diff --git a/web/WEB-INF/lib/fastjson-1.2.54.jar b/web/WEB-INF/lib/fastjson-1.2.54.jar new file mode 100644 index 0000000..11a0230 Binary files /dev/null and b/web/WEB-INF/lib/fastjson-1.2.54.jar differ diff --git a/web/WEB-INF/variable b/web/WEB-INF/variable new file mode 100644 index 0000000..0acc674 --- /dev/null +++ b/web/WEB-INF/variable @@ -0,0 +1,36 @@ +User 3 +UserID NUM +openID STRING +codeID STRING + +Book 6 +BookID NUM +BookName STRING +Author STRING +Price NUM +Introduce STRING +Type NUM + + +Address 4 +UserID NUM +MessageID NUM +telephone NUM +Address STRING + +Cart 3 +UserID NUM +BookID NUM +Count NUM + +Info 5 +OrderID NUM +BookID NUM +Count NUM +Status NUM +Extra STRING + +Ordered 3 +OrderID NUM +UserID NUM +MessageID NUM diff --git a/web/WEB-INF/web.xml b/web/WEB-INF/web.xml index 1792df5..e86f45c 100644 --- a/web/WEB-INF/web.xml +++ b/web/WEB-INF/web.xml @@ -9,14 +9,14 @@ url - jdbc:mysql://45.76.158.31/tushuxiaoshou + jdbc:mysql://139.159.205.5/tushuxiaoshou user - root + tushuxiaoshou passwd - yuanshao + 536szyx5B2xNF86H \ No newline at end of file diff --git a/web/build/classes/.DS_Store b/web/build/classes/.DS_Store new file mode 100644 index 0000000..8205ca2 Binary files /dev/null and b/web/build/classes/.DS_Store differ diff --git a/web/build/classes/WeChat/AddCart.class b/web/build/classes/WeChat/AddCart.class new file mode 100644 index 0000000..4ef5bc4 Binary files /dev/null and b/web/build/classes/WeChat/AddCart.class differ diff --git a/web/build/classes/WeChat/Address.class b/web/build/classes/WeChat/Address.class new file mode 100644 index 0000000..8b13860 Binary files /dev/null and b/web/build/classes/WeChat/Address.class differ diff --git a/web/build/classes/WeChat/Authentication.class b/web/build/classes/WeChat/Authentication.class new file mode 100644 index 0000000..908ff86 Binary files /dev/null and b/web/build/classes/WeChat/Authentication.class differ diff --git a/web/build/classes/WeChat/BookInfo.class b/web/build/classes/WeChat/BookInfo.class new file mode 100644 index 0000000..c4ad3e6 Binary files /dev/null and b/web/build/classes/WeChat/BookInfo.class differ diff --git a/web/build/classes/WeChat/Buy.class b/web/build/classes/WeChat/Buy.class new file mode 100644 index 0000000..4249db3 Binary files /dev/null and b/web/build/classes/WeChat/Buy.class differ diff --git a/web/build/classes/WeChat/CheckOrders.class b/web/build/classes/WeChat/CheckOrders.class new file mode 100644 index 0000000..cc1a92c Binary files /dev/null and b/web/build/classes/WeChat/CheckOrders.class differ diff --git a/web/build/classes/WeChat/Classify.class b/web/build/classes/WeChat/Classify.class new file mode 100644 index 0000000..daa6d8f Binary files /dev/null and b/web/build/classes/WeChat/Classify.class differ diff --git a/web/build/classes/WeChat/ExecuteUpd.class b/web/build/classes/WeChat/ExecuteUpd.class new file mode 100644 index 0000000..907e485 Binary files /dev/null and b/web/build/classes/WeChat/ExecuteUpd.class differ diff --git a/web/build/classes/WeChat/GetFrontInfo.class b/web/build/classes/WeChat/GetFrontInfo.class new file mode 100644 index 0000000..b76b784 Binary files /dev/null and b/web/build/classes/WeChat/GetFrontInfo.class differ diff --git a/web/build/classes/WeChat/GetJson.class b/web/build/classes/WeChat/GetJson.class new file mode 100644 index 0000000..847ec8d Binary files /dev/null and b/web/build/classes/WeChat/GetJson.class differ diff --git a/web/build/classes/WeChat/Item.class b/web/build/classes/WeChat/Item.class new file mode 100644 index 0000000..e103fd8 Binary files /dev/null and b/web/build/classes/WeChat/Item.class differ diff --git a/web/build/classes/WeChat/LoginDatabase.class b/web/build/classes/WeChat/LoginDatabase.class new file mode 100644 index 0000000..6bf6430 Binary files /dev/null and b/web/build/classes/WeChat/LoginDatabase.class differ diff --git a/web/build/classes/WeChat/ModifyStatus.class b/web/build/classes/WeChat/ModifyStatus.class new file mode 100644 index 0000000..306a2ac Binary files /dev/null and b/web/build/classes/WeChat/ModifyStatus.class differ diff --git a/web/build/classes/WeChat/Readclass.class b/web/build/classes/WeChat/Readclass.class new file mode 100644 index 0000000..e7e155a Binary files /dev/null and b/web/build/classes/WeChat/Readclass.class differ diff --git a/web/build/classes/WeChat/initUser.class b/web/build/classes/WeChat/initUser.class new file mode 100644 index 0000000..667557a Binary files /dev/null and b/web/build/classes/WeChat/initUser.class differ diff --git a/web/build/classes/WeChat/sqlfilter.class b/web/build/classes/WeChat/sqlfilter.class new file mode 100644 index 0000000..493bb4a Binary files /dev/null and b/web/build/classes/WeChat/sqlfilter.class differ diff --git a/web/live2d/model/kannaEX/kannaEX.2048/.DS_Store b/web/live2d/model/kannaEX/kannaEX.2048/.DS_Store index be2541e..0025693 100644 Binary files a/web/live2d/model/kannaEX/kannaEX.2048/.DS_Store and b/web/live2d/model/kannaEX/kannaEX.2048/.DS_Store differ diff --git a/web/music/Girlish Lover.mp3 b/web/music/Girlish Lover.mp3 new file mode 100644 index 0000000..b3e5d57 Binary files /dev/null and b/web/music/Girlish Lover.mp3 differ diff --git a/web/src/.DS_Store b/web/src/.DS_Store new file mode 100644 index 0000000..8205ca2 Binary files /dev/null and b/web/src/.DS_Store differ diff --git a/web/src/WeChat/AddCart.java b/web/src/WeChat/AddCart.java new file mode 100644 index 0000000..3650444 --- /dev/null +++ b/web/src/WeChat/AddCart.java @@ -0,0 +1,86 @@ +package WeChat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; + +// 对购物车的操作 +// 1.查询用户购物车内的书本的数量 +// 2.在购物表中添加一条条目 +// 3.在购物车中删除一条条目 +// 4.在购物车中修改一条条目 +@WebServlet(name = "AddCart", urlPatterns = {"/AddCart.do"}, loadOnStartup = 2) +public class AddCart extends HttpServlet { + private boolean _modify(HttpServletRequest request){ + if(!_delete(request)) return false; + return _add(request); + } + private boolean _add(HttpServletRequest request){ + String UserID = request.getParameter("UserID"); + String BookID = request.getParameter("BookID"); + String Count = request.getParameter("Count"); + if(sqlfilter.isNumber(UserID) && sqlfilter.isNumber(BookID) && + sqlfilter.isNumber(Count)){ + ArrayList add = new ArrayList<>(); + add.add(UserID); + add.add(BookID); + add.add(Count); + String sql = Readclass.getInsertString("Cart",add); + return ExecuteUpd.execute(request,sql); + } + return false; + } + private boolean _delete(HttpServletRequest request){ + String UserID = request.getParameter("UserID"); + String BookID = request.getParameter("BookID"); + if(sqlfilter.isNumber(UserID) && sqlfilter.isNumber(BookID)){ + String sql = "delete from Cart where UserID="+ UserID + + " and BookID=" + BookID; + return ExecuteUpd.execute(request,sql); + } + return false; + } + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if(Authentication.islegal(request)){ + String action = request.getParameter("action"); + if(action == null){ + response.setStatus(400); + }else if(action.equals("Modify")) { + boolean flag=_modify(request); + if(!flag) response.setStatus(400); + else response.setStatus(200); + }else if(action.equals("Add")){ + boolean flag=_add(request); + if(!flag) response.setStatus(400); + else response.setStatus(200); + }else if(action.equals("Delete")){ + boolean flag=_delete(request); + if(!flag) response.setStatus(400); + else response.setStatus(200); + }else if(action.equals("getinfo")){ + String UserID = request.getParameter("UserID"); + if (sqlfilter.isNumber(UserID)) { + String sql = "select Book.BookID,Count,BookName,Price from Cart " + + "join Book on Book.BookID=Cart.BookID "+ + "where UserID=" + UserID; + System.err.println(sql); + HashMap names = new HashMap<>(); + names.put("BookName","BookName"); + names.put("BookID","BookID"); + names.put("Count","Count"); + names.put("Price","Price"); + GetJson.Getinfo(request,response,sql,names); + } + } + } + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doPost(request,response); + } +} diff --git a/web/src/WeChat/Address.java b/web/src/WeChat/Address.java new file mode 100644 index 0000000..94e6167 --- /dev/null +++ b/web/src/WeChat/Address.java @@ -0,0 +1,100 @@ +package WeChat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.HashMap; + +// 这个界面的作用是对于该用户的地址进行管理 +// 添加一个,删除一个,或者修改一个 +// 如果修改失败,我们返回一个 +@WebServlet(name = "Address", urlPatterns = {"/Address.do"}, loadOnStartup = 2) +public class Address extends HttpServlet { + private boolean modify(HttpServletRequest request){ + if(!delete(request)) return false; + return add(request); + } + private boolean add(HttpServletRequest request){ + String UserID = request.getParameter("UserID"); + String telephone = request.getParameter("telephone"); + String Address = request.getParameter("Address"); + boolean flag = false; + if(sqlfilter.isNumber(UserID) && telephone !=null & Address !=null) { + flag = true; + telephone = sqlfilter.filter(telephone); + Address = sqlfilter.filter(Address); + String tmp = "select max(MessageID)+1 as ret from Address where UserID=" + UserID; + Statement state = (Statement) (request.getServletContext().getAttribute("state")); + try { + ResultSet Result = state.executeQuery(tmp); + String MessageID = "1"; + while (Result.next()) { + MessageID = Result.getString("ret"); + } + ArrayList add = new ArrayList<>(); + telephone = sqlfilter.filter(telephone); + Address = sqlfilter.filter(Address); + add.add(UserID); + add.add(MessageID); + add.add(telephone); + add.add(Address); + String sql = Readclass.getInsertString("Address", add); + if(!ExecuteUpd.execute(request,sql)) flag = false; + } catch (Exception e) { + flag = false; + e.printStackTrace(); + } + } + return flag; + } + private boolean delete(HttpServletRequest request){ + String UserID = request.getParameter("UserID"); + String MessageID = request.getParameter("MessageID"); + if(sqlfilter.isNumber(UserID) && sqlfilter.isNumber(MessageID)){ + String sql = "delete from Address where UserID="+ UserID + + " and MessageID=" + MessageID; + return ExecuteUpd.execute(request,sql); + } + return false; + } + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if(Authentication.islegal(request)){ + String action = request.getParameter("action"); + if(action == null){ + response.setStatus(400); + }else if(action.equals("Modify")) { + boolean flag=modify(request); + if(!flag) response.setStatus(400); + else response.setStatus(200); + }else if(action.equals("Add")){ + boolean flag=add(request); + if(!flag) response.setStatus(400); + else response.setStatus(200); + }else if(action.equals("Delete")){ + boolean flag=delete(request); + if(!flag) response.setStatus(400); + else response.setStatus(200); + }else if(action.equals("getinfo")){ + String UserID = request.getParameter("UserID"); + if (sqlfilter.isNumber(UserID)) { + String sql = "select MessageID,telephone,Address,MessageID from Address where UserID=" + UserID; + HashMap names = new HashMap<>(); + names.put("MessageID","MessageID"); + names.put("telephone","telephone"); + names.put("Address","Address"); + GetJson.Getinfo(request,response,sql,names); + } + } + } + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doPost(request,response); + } +} diff --git a/web/src/WeChat/Authentication.java b/web/src/WeChat/Authentication.java new file mode 100644 index 0000000..1132556 --- /dev/null +++ b/web/src/WeChat/Authentication.java @@ -0,0 +1,140 @@ +package WeChat; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.ArrayList; +import java.util.Random; +import com.alibaba.fastjson.JSONObject; + +// 验证该用户的身份 +// 首先我们要验证两件事 +// 1.该用户的请求是合法请求 +// 2.该用户发来的UserID如果存在。那么一定是对的UserID +public class Authentication { + // 用cookie验证用户身份 + private static String code = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + public static String getrandomcode() { + Random random=new Random(); + StringBuffer sb=new StringBuffer(); + for(int i=0;i<20;i++){ + int number=random.nextInt(62); + sb.append(code.charAt(number)); + } + return sb.toString(); + } + public static String sendGET(String url){ + StringBuffer result= new StringBuffer();//访问返回结果 + BufferedReader read=null;//读取访问结果 + URL realurl=null; + URLConnection connection=null; + try { + //创建url + realurl=new URL(url); + //打开连接 + connection=realurl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + //建立连接 + connection.connect(); + // 获取所有响应头字段 + // 定义 BufferedReader输入流来读取URL的响应 + read = new BufferedReader(new InputStreamReader( + connection.getInputStream(),"UTF-8")); + String line;//循环读取 + while ((line = read.readLine()) != null) { + result.append(line); + } + } catch (IOException e) { + e.printStackTrace(); + }finally{ + if(read!=null){//关闭流 + try { + read.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + return result.toString(); + } + public static void Store(HttpServletRequest request ,JSONObject json, String openid,String codeid) throws SQLException { + String sql1 = "select * from User where openID='" + openid +"'"; + Statement state = (Statement) request.getServletContext().getAttribute("state"); + ResultSet rs; + rs = state.executeQuery(sql1); + boolean isnull = true; + if(rs.next()) isnull = false; + String sql2 = "select max(UserID)+1 as ret from User"; + rs = state.executeQuery(sql2); + String Userid = "1"; + while(rs.next()) { + Userid = rs.getString("ret"); + } + // 如果不存在这个用户 + if(isnull){ + ArrayList arrayList = new ArrayList<>(); + arrayList.add(Userid); + arrayList.add(openid); + arrayList.add(codeid); + String sql3 = Readclass.getInsertString("User",arrayList); + ExecuteUpd.execute(request, sql3); + }else { + String sql4 = "update set codeID=" + "'" + codeid + "' where UserID = " + Userid; + ExecuteUpd.execute(request, sql4); + } + json.put("UserID", Userid); + json.put("codeID", codeid); + } + public static void init(HttpServletRequest request, HttpServletResponse response) throws IOException,SQLException { + response.setHeader("Content - Encoding","utf-8"); + response.setContentType("text/json; charset=utf-8"); + String code =request.getParameter("code"); + //向微信服务器发送请求 + StringBuffer url = new StringBuffer("https://api.weixin.qq.com/sns/jscode2session?"); + //开发者的小程序ID + url.append("appid=wxdc9f23490d56599c"); + url.append("&secret=c39052978a3e80d55ff53227013384ce"); + url.append("&js_code="); + url.append(code); + url.append("&grant_type=authorization_code"); + //收到微信的回应 + String res = sendGET(url.toString()); + JSONObject json = JSONObject.parseObject(res); + //从微信服务器得到验证码 + int errcode = json.getIntValue("errcode"); + PrintWriter out = response.getWriter(); + JSONObject toxcx = new JSONObject(); + if(errcode == 0) { + String openid = json.getString("openid"); + String codeid = getrandomcode(); + Store(request,json,openid,codeid); + } + else if(errcode == -1) { // 系统繁忙,此时请开发者稍候再试 + toxcx.put("errcode","-1 系统繁忙,请稍候再试"); + out.println(toxcx); + } + else if(errcode == 40029) { // code 无效 + toxcx.put("errcode","40029 code无效"); + out.println(toxcx); + } + else if(errcode == 45011){ //频率限制,每个用户每分钟100次 + toxcx.put("errcode","45011 操作过于频繁"); + out.println(toxcx); + out.flush(); + } + } + public static boolean islegal(HttpServletRequest request){ + return true; + } +} diff --git a/web/src/WeChat/BookInfo.java b/web/src/WeChat/BookInfo.java new file mode 100644 index 0000000..76c1dce --- /dev/null +++ b/web/src/WeChat/BookInfo.java @@ -0,0 +1,44 @@ +package WeChat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; + +// 首先明确我们这个目的是目标页面的分类功能,根据用户所需要返回所有该类别的图书 +@WebServlet(name = "BookInfo", urlPatterns = {"/BookInfo.do"}, loadOnStartup = 2) +public class BookInfo extends HttpServlet { + protected void doPost(HttpServletRequest request, + HttpServletResponse response) + throws ServletException, IOException { + if (Authentication.islegal(request)) { + String bookid = request.getParameter("bookid"); + String fuzzy = request.getParameter("fuzzy"); + String bookname = request.getParameter("bookname"); + if(bookname!=null) bookname = sqlfilter.filter(bookname); + boolean isfuzzy = false; + if(fuzzy != null && fuzzy.equals("true") && bookname != null) isfuzzy = true; + // 防止sql注入 + if (isfuzzy || sqlfilter.isNumber(bookid)) { + String sql = ""; + if(!isfuzzy) sql = "select * from Book where BookId = " + bookid; + else sql = "select * from Book where BookName like '"+bookname+"%'"; + HashMap names = new HashMap<>(); + names.put("BookID","BookId"); + names.put("BookName","BookName"); + names.put("Author","Author"); + names.put("Price","Price"); + names.put("Introduce","Introduce"); + GetJson.Getinfo(request,response,sql,names); + } + } + } + protected void doGet(HttpServletRequest request, + HttpServletResponse response) + throws ServletException, IOException { + doPost(request,response); + } +} diff --git a/web/src/WeChat/Buy.java b/web/src/WeChat/Buy.java new file mode 100644 index 0000000..f3982e0 --- /dev/null +++ b/web/src/WeChat/Buy.java @@ -0,0 +1,53 @@ +package WeChat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; + +@WebServlet(name = "Buy" ,urlPatterns = {"/Buy.do"}, loadOnStartup = 2) +// 实现从图书详情界面直接修改 +// 写触发器?不存在的 +// 错了就错了,不管了 +public class Buy extends HttpServlet { + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if(Authentication.islegal(request)){ + String UserID = request.getParameter("UserID"); + String MessageID = request.getParameter("MessageID"); + String OrderID = String.valueOf(++LoginDatabase.SerialID); + String BookID = request.getParameter("BookID"); + String Count = request.getParameter("Count"); + String Status = "1"; + String Extra = "未出货"; + //向两张表都插入数据 + if(sqlfilter.isNumber(UserID) && sqlfilter.isNumber(MessageID) && + sqlfilter.isNumber(BookID) && sqlfilter.isNumber(Count)){ + ArrayList order = new ArrayList<>(); + ArrayList info = new ArrayList<>(); + /************************/ + order.add(OrderID); + order.add(UserID); + order.add(MessageID); + /************************/ + info.add(OrderID); + info.add(BookID); + info.add(Count); + info.add(Status); + info.add(Extra); + /************************/ + String sql1 = Readclass.getInsertString("Ordered",order); + String sql2 = Readclass.getInsertString("Info",info); + boolean flag = (ExecuteUpd.execute(request,sql1) && ExecuteUpd.execute(request,sql2)); + if(!flag) response.setStatus(400); + else response.setStatus(200); + } + } + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doPost(request,response); + } +} diff --git a/web/src/WeChat/CheckOrders.java b/web/src/WeChat/CheckOrders.java new file mode 100644 index 0000000..a07b144 --- /dev/null +++ b/web/src/WeChat/CheckOrders.java @@ -0,0 +1,43 @@ +package WeChat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; + +// 检查该用户处于某一个状态下的所有订单 +// 要注意的就是保证该用户账户的合法性 +@WebServlet(name = "CheckOrders", urlPatterns = {"/CheckOrders.do"}, loadOnStartup = 2) +public class CheckOrders extends HttpServlet { + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if(Authentication.islegal(request)){ + String UserID = request.getParameter("UserID"); + String Status = request.getParameter("status"); + if(sqlfilter.isNumber(UserID) && sqlfilter.isNumber(Status)) { + String sql = "select Ordered.OrderID,Book.BookID,BookName,Count,Extra,telephone,Address,Ordered.MessageID " + + "from Ordered join Address on Address.UserID = Ordered.UserID and Address.MessageID " + + "= Ordered.MessageID join Info on Ordered.OrderID = Info.OrderID " + + "join Book on Book.BookID = Info.BookID " + + "where status =" + Status + + " and Ordered.UserID=" + UserID; + HashMap names = new HashMap<>(); + names.put("OrderID","OrderID"); + names.put("BookID","BookID"); + names.put("BookName","BookName"); + names.put("Count","Count"); + names.put("Extra","Extra"); + names.put("telephone","telephone"); + names.put("Address","Address"); + names.put("MessageID","MessageID"); + GetJson.Getinfo(request,response,sql,names); + } + } + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doPost(request, response); + } +} diff --git a/web/src/WeChat/Classify.java b/web/src/WeChat/Classify.java new file mode 100644 index 0000000..4ad2d5a --- /dev/null +++ b/web/src/WeChat/Classify.java @@ -0,0 +1,31 @@ +package WeChat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; + +// 首先明确我们这个目的是目标页面的分类功能,根据用户所需要返回所有该类别的图书 +@WebServlet(name = "Classify", urlPatterns = {"/Classify.do"}, loadOnStartup = 2) +public class Classify extends HttpServlet { + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if(Authentication.islegal(request)){ + String booktype = request.getParameter("booktype"); + // 防止sql注入 + if(sqlfilter.isNumber(booktype)) { + String sql = "select * from Book where Type = " + booktype; + HashMap names = new HashMap<>(); + names.put("BookID","BookID"); + names.put("BookName","BookName"); + GetJson.Getinfo(request,response,sql,names); + } + } + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doPost(request,response); + } +} diff --git a/web/src/WeChat/ExecuteUpd.java b/web/src/WeChat/ExecuteUpd.java new file mode 100644 index 0000000..0eaea99 --- /dev/null +++ b/web/src/WeChat/ExecuteUpd.java @@ -0,0 +1,20 @@ +package WeChat; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import java.sql.Statement; + +public class ExecuteUpd { + public static boolean execute(HttpServletRequest request, String QueryString){ + ServletContext context = request.getServletContext(); + Statement state = (Statement)context.getAttribute("state"); + boolean flag = true; + try{ + state.execute(QueryString); + }catch (Exception e){ + flag = false; + e.printStackTrace(); + } + return flag; + } +} diff --git a/web/src/WeChat/GetFrontInfo.java b/web/src/WeChat/GetFrontInfo.java new file mode 100644 index 0000000..e75eec9 --- /dev/null +++ b/web/src/WeChat/GetFrontInfo.java @@ -0,0 +1,30 @@ +package WeChat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.HashMap; + +// 得到首页信息 +@WebServlet(name = "GetFrontInfo", urlPatterns = {"/GetFrontInfo.do"}, loadOnStartup = 2) +public class GetFrontInfo extends HttpServlet { + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // 其实我们只要返回BookID对应的名称就可以了 + // 然后根据书本名字就可以在对应的目录 + if(Authentication.islegal(request)){ + String sql = "select BookID,BookName,Introduce from Book where BookID in (select BookID from Display)"; + HashMap names = new HashMap<>(); + names.put("BookID","BookID"); + names.put("BookName","BookName"); + names.put("Introduce","Introduce"); + GetJson.Getinfo(request,response,sql,names); + } + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doPost(request, response); + } +} diff --git a/web/src/WeChat/GetJson.java b/web/src/WeChat/GetJson.java new file mode 100644 index 0000000..459913b --- /dev/null +++ b/web/src/WeChat/GetJson.java @@ -0,0 +1,38 @@ +package WeChat; + +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.JSONArray; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.rmi.ServerException; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Map; + +public class GetJson { + public static void Getinfo(HttpServletRequest request, HttpServletResponse response, String QueryString, Map names) throws ServerException, IOException { + response.setHeader("Content - Encoding","utf-8"); + response.setContentType("text/json; charset=utf-8"); + ServletContext context = request.getServletContext(); + PrintWriter out = response.getWriter(); + Statement state = (Statement)context.getAttribute("state"); + JSONArray jsonArray = new JSONArray(); + try{ + ResultSet rs=state.executeQuery(QueryString); + while(rs.next()){ + JSONObject jsonObject = new JSONObject(); + for (Map.Entry entry : names.entrySet()) { + jsonObject.put(entry.getKey(), rs.getString(entry.getValue())); + } + //对于图片的话,我们直接返回对应的图书封面的url就可以了 + jsonArray.add(jsonObject); + } + }catch (Exception e){ + e.printStackTrace(); + } + out.println(jsonArray); + } +} diff --git a/web/src/WeChat/Item.java b/web/src/WeChat/Item.java new file mode 100644 index 0000000..bde7c1e --- /dev/null +++ b/web/src/WeChat/Item.java @@ -0,0 +1,9 @@ +package WeChat; + +import java.util.ArrayList; + +public class Item { + public ArrayList key=new ArrayList(); + public ArrayList type=new ArrayList(); + public int size=0; +} diff --git a/web/src/WeChat/LoginDatabase.java b/web/src/WeChat/LoginDatabase.java new file mode 100644 index 0000000..abe2b0a --- /dev/null +++ b/web/src/WeChat/LoginDatabase.java @@ -0,0 +1,79 @@ +package WeChat; + +import java.io.IOException; +import java.sql.*; +import java.util.HashMap; +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +// 连接数据库的我们是服务开始的时候 +@WebServlet(name = "LoginDatabase", urlPatterns = {"/Startup.do"}, loadOnStartup = 1) +public class LoginDatabase extends HttpServlet { + private String mysql, url, user, passwd; + private Connection conn; + private Statement state; + public static int SerialID ; + public static HashMap Map=new HashMap<>(); + private void initDataBase() throws ClassNotFoundException, SQLException { + Class.forName(mysql); + conn = DriverManager.getConnection(url,user,passwd); + state = conn.createStatement(); + ResultSet rs = state.executeQuery("select max(OrderID) as num from Ordered"); + SerialID = 1; + while(rs.next()){ + SerialID = rs.getInt("num") + 1; + } + } + private void closeDataBase(){ + if(state != null) { + try{ + state.close(); + }catch (Exception e) { + e.printStackTrace(); + } + } + if(conn != null) { + try{ + conn.close(); + }catch (Exception e) { + e.printStackTrace(); + } + } + } + public void init(ServletConfig config) throws ServletException{ + super.init(config); + Readclass.init(getServletContext()); + ServletContext context=getServletContext(); + mysql = context.getInitParameter("mysql"); + url = context.getInitParameter("url"); + user = context.getInitParameter("user"); + passwd = context.getInitParameter("passwd"); + try{ + initDataBase(); + }catch (Exception e){ + e.printStackTrace(); + } + System.out.println("Successful Connected!"); + context.setAttribute("conn",conn); + context.setAttribute("state",state); + } + public void destroy(){ + closeDataBase(); + super.destroy(); + } + public void doGet(HttpServletRequest request, + HttpServletResponse response) + throws ServletException, IOException { + response.sendRedirect("/index.html"); + } + public void doPost(HttpServletRequest request, + HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } +} diff --git a/web/src/WeChat/ModifyStatus.java b/web/src/WeChat/ModifyStatus.java new file mode 100644 index 0000000..566168a --- /dev/null +++ b/web/src/WeChat/ModifyStatus.java @@ -0,0 +1,39 @@ +package WeChat; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +//这个作用是改变一个订单的状态 +// 我们这里订单状态定义了四个状态 +// 1 待付款 +// 2 待发货 +// 3 待收货 +// 4 收货完成 +@WebServlet(name = "ModifyStatus", urlPatterns = {"/ModifyStatus.do"}, loadOnStartup = 2) +public class ModifyStatus extends HttpServlet { + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + if(Authentication.islegal(request)){ + String OrderID = request.getParameter("OrderID"); + String Status = request.getParameter("status"); + String Extra = request.getParameter("Extra"); + if(Extra == null) Extra = ""; + // 并且我们这里要做一个验证保证用户的身份正确 + if(sqlfilter.isNumber(OrderID) && sqlfilter.islegalStatus(Status)){ + Extra = sqlfilter.filter(Extra); + String sql = "update Info set Status='"+ Status + "'" + + ",Extra='" + Extra + "' where OrderID=" + OrderID; + boolean flag = ExecuteUpd.execute(request,sql); + if(!flag) response.setStatus(400); + else response.setStatus(200); + } + } + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + doPost(request, response); + } +} diff --git a/web/src/WeChat/Readclass.java b/web/src/WeChat/Readclass.java new file mode 100644 index 0000000..c868fbc --- /dev/null +++ b/web/src/WeChat/Readclass.java @@ -0,0 +1,61 @@ +package WeChat; + +import javax.servlet.ServletContext; +import java.util.ArrayList; +import java.util.Scanner; + +public class Readclass { + public static void init(ServletContext context){ + try{ + Scanner fin=new Scanner(context.getResourceAsStream("WEB-INF/variable")); + while(fin.hasNext()){ + String className=fin.next(); + int count=fin.nextInt(); + Item item=new Item(); + item.size=count; + for(int i=0;i getWord(String table, ArrayList value){ + Item item=LoginDatabase.Map.get(table); + ArrayList arrayList=new ArrayList(); + for(int i=0;i arrayList){ + int sz = arrayList.size(); + ArrayList ins = getWord(table,arrayList); + StringBuffer sb = new StringBuffer("insert into "); + sb.append(table); + sb.append(" values"); + sb.append(" ("); + for(int i=0;i10) return false; + for(int i=0; i='0'&&digit<='9')) return false; + } + return true; + } + public static String filter(String sqlQue) { + StringBuffer ft = new StringBuffer(); + for (int i=0; i=1 && Statusid<=4; + } +} diff --git a/web/variable b/web/variable new file mode 100644 index 0000000..0acc674 --- /dev/null +++ b/web/variable @@ -0,0 +1,36 @@ +User 3 +UserID NUM +openID STRING +codeID STRING + +Book 6 +BookID NUM +BookName STRING +Author STRING +Price NUM +Introduce STRING +Type NUM + + +Address 4 +UserID NUM +MessageID NUM +telephone NUM +Address STRING + +Cart 3 +UserID NUM +BookID NUM +Count NUM + +Info 5 +OrderID NUM +BookID NUM +Count NUM +Status NUM +Extra STRING + +Ordered 3 +OrderID NUM +UserID NUM +MessageID NUM diff --git a/江可飞/小程序开发/app.js b/江可飞/小程序开发/app.js index c890f9b..18ca26c 100644 --- a/江可飞/小程序开发/app.js +++ b/江可飞/小程序开发/app.js @@ -4,7 +4,8 @@ App({ globalData: { UserID:null, - CodeID:null + CodeID:null, + url:"http://45.76.158.31:8080/web" }, onLaunch: function () { @@ -19,18 +20,18 @@ App({ success: res => { // 发送 res.code 到后台换取 openId, sessionKey, unionId console.log(res.code) - wx.request({ - url: 'https://hunjianghu.xuanjis.com/web/Yanzheng', - data: { - "code": res.code - }, - method: 'GET', - success: res1 => { - that.globalData.UserID = res1.data.UserID; - that.globalData.CodeID = res1.data.CodeID; - console.log(that.globalData.UserID) - } - }) + // wx.request({ + // url: 'https://hunjianghu.xuanjis.com/web/Yanzheng', + // data: { + // "code": res.code + // }, + // method: 'GET', + // success: res1 => { + // that.globalData.UserID = res1.data.UserID; + // that.globalData.CodeID = res1.data.CodeID; + // console.log(that.globalData.UserID) + // } + // }) } diff --git a/江可飞/小程序开发/pages/detail/detail.js b/江可飞/小程序开发/pages/detail/detail.js index 8499e0f..eb29df2 100644 --- a/江可飞/小程序开发/pages/detail/detail.js +++ b/江可飞/小程序开发/pages/detail/detail.js @@ -18,7 +18,7 @@ Page({ console.log("in detail") var thats = this wx.request({ - url: "http://45.76.158.31:8080/web/BookInfo.do?bookid=" + options.id, + url: "https://hunjianghu.xuanjis.com/web/BookInfo.do?bookid=" + options.id, header: { "content-type": "json" }, @@ -51,7 +51,7 @@ Page({ addCar() { var that = this wx.request({ - url: 'http://45.76.158.31:8080/web/AddCart.do',//?action=Modify&UserID=1&BookID=' + that.data.book[0].BookID + '&Count=' + that.data.book[0].Count, + url: 'https://hunjianghu.xuanjis.com/web/AddCart.do',//?action=Modify&UserID=1&BookID=' + that.data.book[0].BookID + '&Count=' + that.data.book[0].Count, data: { 'action':'Modify', 'UserID':1, @@ -76,11 +76,24 @@ Page({ }, // 立即购买 immeBuy() { + var that = this wx.showToast({ title: '购买成功', icon: 'success', duration: 2000 }); + + wx.request({ + url: 'https://hunjianghu.xuanjis.com/web/Buy.do?UserID=1&BookID=' + that.data.book[0].BookID + '&Count=' + 1 + '&MessageID=' + 1, + header: { + + }, + success: function (res) { + if (res.statusCode == 200) { + } + } + }) + }, }) \ No newline at end of file diff --git a/江可飞/小程序开发/pages/detail/detail.wxml b/江可飞/小程序开发/pages/detail/detail.wxml index 6e2f964..6509d96 100644 --- a/江可飞/小程序开发/pages/detail/detail.wxml +++ b/江可飞/小程序开发/pages/detail/detail.wxml @@ -4,7 +4,7 @@ - + @@ -30,7 +30,7 @@ 商品详情 - + - + {{books.BookName}} diff --git a/江可飞/小程序开发/pages/gouwu/gouwu.js b/江可飞/小程序开发/pages/gouwu/gouwu.js index 53bc279..82a6815 100644 --- a/江可飞/小程序开发/pages/gouwu/gouwu.js +++ b/江可飞/小程序开发/pages/gouwu/gouwu.js @@ -115,14 +115,13 @@ Page({ let bookList = this.data.bookList; wx.request({ - url: "http://45.76.158.31:8080/web/AddCart.do?action=Delete&BookID=" + that.data.bookList[index].BookID + "&UserID=1", + url: "https://hunjianghu.xuanjis.com/web/AddCart.do?action=Delete&BookID=" + that.data.bookList[index].BookID + "&UserID=1", header: { "content-type": "json" }, success: function(res) { if (res.statusCode == 200) { - console.log(res.data) that.setData({ book: res.data, }) @@ -132,7 +131,6 @@ Page({ }) bookList.splice(index, 1); - console.log(index) this.setData({ bookList: bookList }); @@ -184,14 +182,13 @@ Page({ this.calculateTotal(); wx.request({ - url: "http://45.76.158.31:8080/web/AddCart.do?action=Modify&BookID=" + bookList[index].BookID + "&UserID=1&Count=" + bookList[index].Count, + url: "https://hunjianghu.xuanjis.com/web/AddCart.do?action=Modify&BookID=" + bookList[index].BookID + "&UserID=1&Count=" + bookList[index].Count, header: { "content-type": "json" }, success: function(res) { if (res.statusCode == 200) { - console.log(res.data) that.setData({ book: res.data, }) @@ -219,14 +216,13 @@ Page({ this.calculateTotal(); wx.request({ - url: "http://45.76.158.31:8080/web/AddCart.do?action=Modify&BookID=" + bookList[index].BookID + "&UserID=1&Count=" + bookList[index].Count, + url: "https://hunjianghu.xuanjis.com/web/AddCart.do?action=Modify&BookID=" + bookList[index].BookID + "&UserID=1&Count=" + bookList[index].Count, header: { "content-type": "json" }, success: function(res) { if (res.statusCode == 200) { - console.log(res.data) that.setData({ book: res.data, }) @@ -240,7 +236,7 @@ Page({ * 用户选择购物车商品 */ checkboxChange: function(e) { - console.log('checkbox发生change事件,携带value值为:', e.detail.value); + //console.log('checkbox发生change事件,携带value值为:', e.detail.value); var checkboxItems = this.data.bookList; var values = e.detail.value; for (var i = 0; i < checkboxItems.length; ++i) { @@ -297,7 +293,7 @@ Page({ todetail: function(e) { var id = e.target.dataset.id - console.log(id) + //console.log(id) wx.navigateTo({ url: "/pages/detail/detail?id=" + id }) @@ -323,7 +319,7 @@ Page({ onShow: function(options) { var that = this wx.request({ - url: "http://45.76.158.31:8080/web/AddCart.do?action=getinfo&UserID=1", + url: "https://hunjianghu.xuanjis.com/web/AddCart.do?action=getinfo&UserID=1", header: { "content-type": "json" }, @@ -331,22 +327,28 @@ Page({ for (var i = 0; i < res.data.length; i++) { res.data[i].checked = false; } - console.log(res.data) if (res.statusCode == 200) { that.setData({ bookList: res.data, + iscart: false }) + if (res.data.length == 0) { + that.setData({ + iscart: true + }) + } //wx.hideNavigationBarLoading() } } }) + }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { - + }, /** @@ -400,50 +402,72 @@ Page({ newAddress: function() { var that = this var checkList = []; - if (!this.data.iscart) { - var bookList = this.data.bookList - for (var i = 0; i < bookList.length; i++) { - if (bookList[i].checked) { - checkList.push(this.data.bookList[i]) - } - } - } - // var checkLists = JSON.stringify(checkList) - // console.log(checkLists) + // var flag = false if (this.data.totalCount > 0) { + if (!this.iscart) { //购物车不空 + var bookLists = this.data.bookList + for (var i = 0; i < bookLists.length; i++) { + if (bookLists[i].checked) { + var bookid = bookLists[i].BookID + var count = bookLists[i].Count + wx.request({ + url: 'https://hunjianghu.xuanjis.com/web/Buy.do?UserID=1&BookID=' + bookid + '&Count=' + count + '&MessageID=' + 1, + header: { + + }, + success: function(res) { + if (res.statusCode == 200) { + // that.setData({ + // // book: res.data, + // flag :true + // }) + //wx.hideNavigationBarLoading() + wx.showToast({ + title: '订单生成成功!', + icon: 'success', + duration: 2000 + }) + } + } + }) + + wx.request({ + url: "https://hunjianghu.xuanjis.com/web/AddCart.do?action=Delete&BookID=" + bookid + "&UserID=1", + header: { + "content-type": "json" + }, + success: function (res) { + + if (res.statusCode == 200) { + // that.setData({ + // book: res.data, + // }) + //wx.hideNavigationBarLoading() + } + } + }) - //向服务器传用户选中购买的东西生成订单 - for (var i = 0; i < checkList.length; i++) { - wx.request({ - url: "http://45.76.158.31:8080/web/Buy.do?UserID=1&BookID="+checkList[i].BookID+"&Count="+checkList[i].Count, - header: { - "content-type": "json" - }, - success: function(res) { - - if (res.statusCode == 200) { - console.log(res.data) - that.setData({ - book: res.data, - }) - //wx.hideNavigationBarLoading() - wx.showToast({ - title: '订单生成成功!', - icon: 'success', - duration: 2000 - }) - } } - }) + } } - setTimeout(function() { - //要延时执行的代码 - wx.navigateTo({ - url: '/pages/order/order?typeId=0' - }) - }, 3000) - + + + + // if (flag) { + setTimeout(function() { + //要延时执行的代码 + wx.navigateTo({ + url: '/pages/order/order?typeId=0' + }) + }, 3000) + // } else { + // wx.showToast({ + // title: '订单创建失败', + // icon: 'success', + // duration: 2000 + // }) + // } } else { wx.showToast({ title: '没有选择商品', diff --git a/江可飞/小程序开发/pages/gouwu/gouwu.wxml b/江可飞/小程序开发/pages/gouwu/gouwu.wxml index b1be35a..b708d0b 100644 --- a/江可飞/小程序开发/pages/gouwu/gouwu.wxml +++ b/江可飞/小程序开发/pages/gouwu/gouwu.wxml @@ -65,7 +65,7 @@ - + {{book.BookName}} diff --git a/江可飞/小程序开发/pages/order/order.js b/江可飞/小程序开发/pages/order/order.js index ea2a790..5a3beb8 100644 --- a/江可飞/小程序开发/pages/order/order.js +++ b/江可飞/小程序开发/pages/order/order.js @@ -19,7 +19,7 @@ Page({ 'unpaidList': [], //待付款 'dueinList': [], //待收货 'deliverList': [], //待发货 - 'checkList':[], + 'checkList': [], <<<<<<< HEAD 'unpaidLists': [ //待付款 @@ -156,25 +156,25 @@ Page({ onLoad: function(options) { var that = this //获取待付款订单信息 - wx.request({ - url: "http://45.76.158.31:8080/web/CheckOrders.do?UserID=1&status=1", - header: { - "content-type": "json" - }, - success: function(res) { - if (res.statusCode == 200) { - console.log(res.data) - that.setData({ - unpaidList :res.data - }) - //wx.hideNavigationBarLoading() - } + wx.request({ + url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&status=1", + header: { + "content-type": "json" + }, + success: function(res) { + console.log(res.data) + if (res.statusCode == 200) { + that.setData({ + unpaidList: res.data + }) + //wx.hideNavigationBarLoading() } - }) + } + }) //获取待收货订单信息 wx.request({ - url: "http://45.76.158.31:8080/web/GetFrontInfo.do", + url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&status=3", header: { "content-type": "json" }, @@ -191,11 +191,11 @@ Page({ //获取待发货信息 wx.request({ - url: "http://45.76.158.31:8080/web/GetFrontInfo.do", + url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&status=2", header: { "content-type": "json" }, - success: function (res) { + success: function(res) { if (res.statusCode == 200) { console.log(res.data) that.setData({ @@ -225,62 +225,63 @@ Page({ // }) }, - deleteList: function(e) { - var that = this - var index= e.currentTarget.dataset.index - this.setData({ - 'unpaidList': null - }); + // deleteList: function(e) { + // var that = this + // var index= e.currentTarget.dataset.index + // this.setData({ + // 'unpaidList': null + // }); - //删除订单 - wx.request({ - url: "http://45.76.158.31:8080/web/CheckOrders.do?UserID=1&OderId="+that.unpaidList[i].OrderID, - header: { - "content-type": "json" - }, - success: function (res) { - if (res.statusCode == 200) { - console.log(res.data) - that.setData({ - checkList: res.data - }) - //wx.hideNavigationBarLoading() - } - } - }) + // //删除订单 + // wx.request({ + // url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&OderId="+that.unpaidList[i].OrderID, + // header: { + // "content-type": "json" + // }, + // success: function (res) { + // if (res.statusCode == 200) { + // console.log(res.data) + // that.setData({ + // checkList: res.data + // }) + // //wx.hideNavigationBarLoading() + // } + // } + // }) - }, + // }, order_status: function(e) { var that = this var current = e.currentTarget.dataset.current - - if(current==1){ + console.log("current=") + console.log(current) + if (current == 0) { wx.request({ - url: "http://45.76.158.31:8080/web/CheckOrders.do?UserID=1&status=1", + url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&status=1", header: { "content-type": "json" }, - success: function (res) { + success: function(res) { if (res.statusCode == 200) { - console.log(res.data) + // console.log(res.data) that.setData({ - checkList: res.data + unpaidList: res.data }) //wx.hideNavigationBarLoading() } } }) - }else if(current==2){ + } else if (current == 1) { //获取待收货订单信息 wx.request({ - url: "http://45.76.158.31:8080/web/GetFrontInfo.do", + url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&status=3", header: { "content-type": "json" }, - success: function (res) { + success: function(res) { if (res.statusCode == 200) { - console.log(res.data) + // console.log(res.data) that.setData({ dueinList: res.data }) @@ -288,20 +289,21 @@ Page({ } } }) - }else if(current==3){ + } else if (current == 2) { //获取待发货信息 wx.request({ - url: "http://45.76.158.31:8080/web/GetFrontInfo.do", + url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&status=2", header: { "content-type": "json" }, - success: function (res) { + success: function(res) { if (res.statusCode == 200) { - console.log(res.data) + // console.log(res.data) that.setData({ deliverList: res.data }) - //wx.hideNavigationBarLoading() + console.log(that.data.deliverList) + wx.hideNavigationBarLoading() } } }) @@ -312,13 +314,47 @@ Page({ }) }, - toPay: function () { + toPay: function(e) { + var that = this + var id = e.currentTarget.dataset.id + wx.showToast({ title: '付款成功!', icon: 'success', duration: 2000 }) - this.deleteList() + + wx.request({ + url: "https://hunjianghu.xuanjis.com/web/ModifyStatus.do?OrderID=" + id + "&status=2", + header: { + "content-type": "json" + }, + success: function(res) { + if (res.statusCode == 200) { + // console.log(res.data) + // that.setData({ + // deliverList: res.data + // }) + //wx.hideNavigationBarLoading() + } + } + }) + + wx.request({ + url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&status=1", + header: { + "content-type": "json" + }, + success: function (res) { + if (res.statusCode == 200) { + // console.log(res.data) + that.setData({ + unpaidList: res.data + }) + //wx.hideNavigationBarLoading() + } + } + }) } diff --git a/江可飞/小程序开发/pages/order/order.wxml b/江可飞/小程序开发/pages/order/order.wxml index da882e3..1e71aca 100644 --- a/江可飞/小程序开发/pages/order/order.wxml +++ b/江可飞/小程序开发/pages/order/order.wxml @@ -25,13 +25,13 @@ - + {{book.BookName}} 数量:{{book.Count}} - {{book.Price*book.Count}} + @@ -41,14 +41,14 @@ 合计: - ¥{{totalPrice}} + ¥{{book.Price*book.Count}} - 删除订单 - 去付款 + + 去付款 @@ -68,7 +68,7 @@ - + {{book.BookName}} @@ -83,10 +83,11 @@ 收货地址: - {{book.Addresss}} + {{book.Address}} + + + - + 付款日期: @@ -126,7 +129,7 @@ - + {{book.BookName}} @@ -145,6 +148,7 @@ + + \ No newline at end of file diff --git a/江可飞/小程序开发/pages/shdz/shdz.js b/江可飞/小程序开发/pages/shdz/shdz.js index 8bf5a54..fc95826 100644 --- a/江可飞/小程序开发/pages/shdz/shdz.js +++ b/江可飞/小程序开发/pages/shdz/shdz.js @@ -10,6 +10,7 @@ Page({ onLoad: function () { }, +<<<<<<< HEAD userInfo: function () { wx.navigateTo({ url: '/pages/userInfo/userInfo' @@ -21,6 +22,9 @@ Page({ url: "/pages/wode/wode" }) }, +======= + +>>>>>>> 07cc8819d28ba7f7f16c159de7ad0994e47b4a1b bindDateChange: function (e) { this.setData({ date: e.detail.value @@ -41,7 +45,7 @@ Page({ icon: 'success', duration: 2000 }) - + setTimeout(function () { //要延时执行的代码 wx.switchTab({ diff --git a/江可飞/小程序开发/pages/shouye/shouye.js b/江可飞/小程序开发/pages/shouye/shouye.js index 8437dc3..c3d99f3 100644 --- a/江可飞/小程序开发/pages/shouye/shouye.js +++ b/江可飞/小程序开发/pages/shouye/shouye.js @@ -41,7 +41,8 @@ Page({ }) wx.request({ - url: "http://45.76.158.31:8080/web//BookInfo.do?bookname="+name+"&fuzzy=true", + url: "https://hunjianghu.xuanjis.com/web/BookInfo.do?bookname="+name+"&fuzzy=true", + // url: getApp.globalData.url + "/BookInfo.do?bookname="+name+"&fuzzy=true", header: { "content-type": "json" }, @@ -70,7 +71,8 @@ Page({ onLoad: function(options) { var thats = this wx.request({ - url: "http://45.76.158.31:8080/web/GetFrontInfo.do", + url: "https://hunjianghu.xuanjis.com/web/GetFrontInfo.do", + // url: getApp.globalData.url + "GetFrontInfo.do", header: { "content-type": "json" }, diff --git a/江可飞/小程序开发/pages/shouye/shouye.wxml b/江可飞/小程序开发/pages/shouye/shouye.wxml index a9fd359..6d6d80b 100644 --- a/江可飞/小程序开发/pages/shouye/shouye.wxml +++ b/江可飞/小程序开发/pages/shouye/shouye.wxml @@ -3,7 +3,7 @@ - + @@ -24,7 +24,7 @@ - + {{books.BookName}} diff --git a/江可飞/小程序开发/project.config.json b/江可飞/小程序开发/project.config.json index af52510..c70ca93 100644 --- a/江可飞/小程序开发/project.config.json +++ b/江可飞/小程序开发/project.config.json @@ -4,7 +4,7 @@ "ignore": [] }, "setting": { - "urlCheck": false, + "urlCheck": true, "es6": true, "postcss": true, "minified": true,