最终可执行文件

master
201630126029 6 years ago
commit 960c1cbb1e

BIN
web/.DS_Store vendored

Binary file not shown.

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="E:/OneDrive/share/servlet-api.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/mysql-connector-java-5.1.39-bin.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/fluent-hc-4.5.6.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/httpclient-4.5.6.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/httpclient-cache-4.5.6.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/httpclient-win-4.5.6.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/httpcore-4.4.10.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/httpmime-4.5.6.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/jna-4.4.0.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/httpcomponents-client-4.5.6/lib/jna-platform-4.4.0.jar"/>
<classpathentry kind="lib" path="E:/OneDrive/share/资源/fastjson-1.2.54.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v9.0 (2)"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>web</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="src" path=""/>
<classpathentry kind="output" path=""/>
</classpath>

@ -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

@ -0,0 +1,5 @@
XDOCLETBUILDERACTIVE=true
XDOCLETHOME=
XDOCLETUSEGLOBAL=true
XDOCLETVERSION=1.2.1
eclipse.preferences.version=1

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="web">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="web"/>
<property name="java-output-path" value="/web/build/classes"/>
</wb-module>
</project-modules>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>

@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.JRE_CONTAINER

Binary file not shown.

Binary file not shown.

@ -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

@ -9,14 +9,14 @@
</context-param> </context-param>
<context-param> <context-param>
<param-name>url</param-name> <param-name>url</param-name>
<param-value>jdbc:mysql://45.76.158.31/tushuxiaoshou</param-value> <param-value>jdbc:mysql://139.159.205.5/tushuxiaoshou</param-value>
</context-param> </context-param>
<context-param> <context-param>
<param-name>user</param-name> <param-name>user</param-name>
<param-value>root</param-value> <param-value>tushuxiaoshou</param-value>
</context-param> </context-param>
<context-param> <context-param>
<param-name>passwd</param-name> <param-name>passwd</param-name>
<param-value>yuanshao</param-value> <param-value>536szyx5B2xNF86H</param-value>
</context-param> </context-param>
</web-app> </web-app>

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
web/src/.DS_Store vendored

Binary file not shown.

@ -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<String> 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<String,String> 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);
}
}

@ -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<String> 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<String,String> 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);
}
}

@ -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<String> 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;
}
}

@ -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<String,String> 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);
}
}

@ -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<String> order = new ArrayList<>();
ArrayList<String> 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);
}
}

@ -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<String,String> 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);
}
}

@ -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<String,String> 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);
}
}

@ -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;
}
}

@ -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<String,String> 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);
}
}

@ -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<String,String> 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<String, String> entry : names.entrySet()) {
jsonObject.put(entry.getKey(), rs.getString(entry.getValue()));
}
//对于图片的话我们直接返回对应的图书封面的url就可以了
jsonArray.add(jsonObject);
}
}catch (Exception e){
e.printStackTrace();
}
out.println(jsonArray);
}
}

@ -0,0 +1,9 @@
package WeChat;
import java.util.ArrayList;
public class Item {
public ArrayList<String> key=new ArrayList<String>();
public ArrayList<String> type=new ArrayList<String>();
public int size=0;
}

@ -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<String,Item> 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);
}
}

@ -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);
}
}

@ -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<count;i++){
String name=fin.next();
String type=fin.next();
item.key.add(name);
item.type.add(type);
}
LoginDatabase.Map.put(className,item);
}
}catch (Exception e){
System.err.println("配置文件错误");
e.printStackTrace();
}
}
//方便sql 语句插入的操作
public static ArrayList<String> getWord(String table, ArrayList<String> value){
Item item=LoginDatabase.Map.get(table);
ArrayList<String> arrayList=new ArrayList<String>();
for(int i=0;i<item.size;i++){
String type=item.type.get(i);
String val=value.get(i);
if(val.equals("NULL")) {
arrayList.add("NULL");
}else if(type.equals("NUM")){
arrayList.add(sqlfilter.filter(val));
}else if(type.equals("STRING")){
arrayList.add("'"+sqlfilter.filter(val)+"'");
}
}
return arrayList;
}
public static String getInsertString(String table, ArrayList<String> arrayList){
int sz = arrayList.size();
ArrayList<String> ins = getWord(table,arrayList);
StringBuffer sb = new StringBuffer("insert into ");
sb.append(table);
sb.append(" values");
sb.append(" (");
for(int i=0;i<sz;i++){
sb.append(ins.get(i));
if(i != sz-1) sb.append(",");
}
sb.append(")");
return sb.toString();
}
}

@ -0,0 +1,24 @@
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;
@WebServlet(name = "initUser", urlPatterns = "/InitUser.do", loadOnStartup = 2)
public class initUser extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
Authentication.init(request,response);
}catch (Exception e){
e.printStackTrace();
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
}

@ -0,0 +1,29 @@
package WeChat;
// 过滤掉奇奇怪怪的英文字符
public class sqlfilter {
private static String danger="`~!@#$^&*()=|{}';'\\[].<>/?~@#¥……&*——|{}";
public static boolean isNumber(String text) {
if(text == null) return false;
int length = text.length();
if(length>10) return false;
for(int i=0; i<length; i++){
char digit = text.charAt(i);
if(!(digit>='0'&&digit<='9')) return false;
}
return true;
}
public static String filter(String sqlQue) {
StringBuffer ft = new StringBuffer();
for (int i=0; i<sqlQue.length(); i++) {
char sign = sqlQue.charAt(i);
if (danger.indexOf(sign) == -1) ft.append(sign);
}
return ft.toString();
}
public static boolean islegalStatus(String Status){
if(!isNumber(Status)) return false;
int Statusid = Integer.parseInt(Status);
return Statusid>=1 && Statusid<=4;
}
}

@ -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

@ -4,7 +4,8 @@ App({
globalData: { globalData: {
UserID:null, UserID:null,
CodeID:null CodeID:null,
url:"http://45.76.158.31:8080/web"
}, },
onLaunch: function () { onLaunch: function () {
@ -19,18 +20,18 @@ App({
success: res => { success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId // 发送 res.code 到后台换取 openId, sessionKey, unionId
console.log(res.code) console.log(res.code)
wx.request({ // wx.request({
url: 'https://hunjianghu.xuanjis.com/web/Yanzheng', // url: 'https://hunjianghu.xuanjis.com/web/Yanzheng',
data: { // data: {
"code": res.code // "code": res.code
}, // },
method: 'GET', // method: 'GET',
success: res1 => { // success: res1 => {
that.globalData.UserID = res1.data.UserID; // that.globalData.UserID = res1.data.UserID;
that.globalData.CodeID = res1.data.CodeID; // that.globalData.CodeID = res1.data.CodeID;
console.log(that.globalData.UserID) // console.log(that.globalData.UserID)
} // }
}) // })
} }

@ -18,7 +18,7 @@ Page({
console.log("in detail") console.log("in detail")
var thats = this var thats = this
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
@ -51,7 +51,7 @@ Page({
addCar() { addCar() {
var that = this var that = this
wx.request({ 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: { data: {
'action':'Modify', 'action':'Modify',
'UserID':1, 'UserID':1,
@ -76,11 +76,24 @@ Page({
}, },
// 立即购买 // 立即购买
immeBuy() { immeBuy() {
var that = this
wx.showToast({ wx.showToast({
title: '购买成功', title: '购买成功',
icon: 'success', icon: 'success',
duration: 2000 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) {
}
}
})
}, },
}) })

@ -4,7 +4,7 @@
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<block> <block>
<swiper-item> <swiper-item>
<image src="http://45.76.158.31:8080/web/BookImage/{{books.BookName}}.jpg" data-src="{{item}}" bindtap="previewImage"></image> <image src="https://hunjianghu.xuanjis.com/web/BookImage/{{books.BookName}}.jpg" data-src="{{item}}" bindtap="previewImage"></image>
</swiper-item> </swiper-item>
</block> </block>
</swiper> </swiper>
@ -30,7 +30,7 @@
<view class="separate"></view> <view class="separate"></view>
<view> <view>
<text>商品详情</text> <text>商品详情</text>
<image class="image_detail" src="http://45.76.158.31:8080/web/BookImage/{{books.BookName}}.jpg" /> <image class="image_detail" src="https://hunjianghu.xuanjis.com/web/BookImage/{{books.BookName}}.jpg" />
</view> </view>
<!--<block wx:for-items="{{detailImg}}" wx:key="name"> <!--<block wx:for-items="{{detailImg}}" wx:key="name">
<image class="image_detail" src="{{item}}" /> <image class="image_detail" src="{{item}}" />

@ -117,7 +117,7 @@ Page({
onLoad: function (){ onLoad: function (){
var thats = this var thats = this
wx.request({ wx.request({
url: "http://45.76.158.31:8080/web/Classify.do?booktype=" + 1, url: "https://hunjianghu.xuanjis.com/web/Classify.do?booktype=" + 1,
header: { header: {
"content-type": "json" "content-type": "json"
}, },
@ -141,7 +141,7 @@ Page({
console.log(id) console.log(id)
var thats = this var thats = this
wx.request({ wx.request({
url: "http://45.76.158.31:8080/web/Classify.do?booktype="+id, url: "https://hunjianghu.xuanjis.com/web/Classify.do?booktype="+id,
header: { header: {
"content-type": "json" "content-type": "json"
}, },

@ -17,7 +17,7 @@
<view class="nav_right_items"> <view class="nav_right_items">
<!--界面跳转 --> <!--界面跳转 -->
<navigator url="/pages/detail/detail?id={{books.BookID}}"> <navigator url="/pages/detail/detail?id={{books.BookID}}">
<image src="http://45.76.158.31:8080/web/BookImage/{{books.BookName}}.jpg"></image> <image src="https://hunjianghu.xuanjis.com/web/BookImage/{{books.BookName}}.jpg"></image>
<text>{{books.BookName}}</text> <text>{{books.BookName}}</text>
</navigator> </navigator>
</view> </view>

@ -115,14 +115,13 @@ Page({
let bookList = this.data.bookList; let bookList = this.data.bookList;
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
success: function(res) { success: function(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
console.log(res.data)
that.setData({ that.setData({
book: res.data, book: res.data,
}) })
@ -132,7 +131,6 @@ Page({
}) })
bookList.splice(index, 1); bookList.splice(index, 1);
console.log(index)
this.setData({ this.setData({
bookList: bookList bookList: bookList
}); });
@ -184,14 +182,13 @@ Page({
this.calculateTotal(); this.calculateTotal();
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
success: function(res) { success: function(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
console.log(res.data)
that.setData({ that.setData({
book: res.data, book: res.data,
}) })
@ -219,14 +216,13 @@ Page({
this.calculateTotal(); this.calculateTotal();
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
success: function(res) { success: function(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
console.log(res.data)
that.setData({ that.setData({
book: res.data, book: res.data,
}) })
@ -240,7 +236,7 @@ Page({
* 用户选择购物车商品 * 用户选择购物车商品
*/ */
checkboxChange: function(e) { 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 checkboxItems = this.data.bookList;
var values = e.detail.value; var values = e.detail.value;
for (var i = 0; i < checkboxItems.length; ++i) { for (var i = 0; i < checkboxItems.length; ++i) {
@ -297,7 +293,7 @@ Page({
todetail: function(e) { todetail: function(e) {
var id = e.target.dataset.id var id = e.target.dataset.id
console.log(id) //console.log(id)
wx.navigateTo({ wx.navigateTo({
url: "/pages/detail/detail?id=" + id url: "/pages/detail/detail?id=" + id
}) })
@ -323,7 +319,7 @@ Page({
onShow: function(options) { onShow: function(options) {
var that = this var that = this
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
@ -331,15 +327,21 @@ Page({
for (var i = 0; i < res.data.length; i++) { for (var i = 0; i < res.data.length; i++) {
res.data[i].checked = false; res.data[i].checked = false;
} }
console.log(res.data)
if (res.statusCode == 200) { if (res.statusCode == 200) {
that.setData({ that.setData({
bookList: res.data, bookList: res.data,
iscart: false
}) })
if (res.data.length == 0) {
that.setData({
iscart: true
})
}
//wx.hideNavigationBarLoading() //wx.hideNavigationBarLoading()
} }
} }
}) })
}, },
/** /**
@ -400,50 +402,72 @@ Page({
newAddress: function() { newAddress: function() {
var that = this var that = this
var checkList = []; var checkList = [];
if (!this.data.iscart) { // var flag = false
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)
if (this.data.totalCount > 0) { 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 { } else {
wx.showToast({ wx.showToast({
title: '没有选择商品', title: '没有选择商品',

@ -65,7 +65,7 @@
</label> </label>
</view> </view>
<view class='good_img'> <view class='good_img'>
<image class='cover' src='http://45.76.158.31:8080/web/BookImage/{{book.BookName}}.jpg' data-id='{{book.BookID}}' bindtap='todetail'></image> <image class='cover' src='https://hunjianghu.xuanjis.com/web/BookImage/{{book.BookName}}.jpg' data-id='{{book.BookID}}' bindtap='todetail'></image>
</view> </view>
<view class='content'> <view class='content'>
<view class='titles'>{{book.BookName}}</view> <view class='titles'>{{book.BookName}}</view>

@ -19,7 +19,7 @@ Page({
'unpaidList': [], //待付款 'unpaidList': [], //待付款
'dueinList': [], //待收货 'dueinList': [], //待收货
'deliverList': [], //待发货 'deliverList': [], //待发货
'checkList':[], 'checkList': [],
<<<<<<< HEAD <<<<<<< HEAD
'unpaidLists': [ //待付款 'unpaidLists': [ //待付款
@ -156,25 +156,25 @@ Page({
onLoad: function(options) { onLoad: function(options) {
var that = this var that = this
//获取待付款订单信息 //获取待付款订单信息
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
success: function(res) { success: function(res) {
if (res.statusCode == 200) { console.log(res.data)
console.log(res.data) if (res.statusCode == 200) {
that.setData({ that.setData({
unpaidList :res.data unpaidList: res.data
}) })
//wx.hideNavigationBarLoading() //wx.hideNavigationBarLoading()
}
} }
}) }
})
//获取待收货订单信息 //获取待收货订单信息
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
@ -191,11 +191,11 @@ Page({
//获取待发货信息 //获取待发货信息
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
success: function (res) { success: function(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
console.log(res.data) console.log(res.data)
that.setData({ that.setData({
@ -225,62 +225,63 @@ Page({
// }) // })
}, },
deleteList: function(e) { // deleteList: function(e) {
var that = this // var that = this
var index= e.currentTarget.dataset.index // var index= e.currentTarget.dataset.index
this.setData({ // this.setData({
'unpaidList': null // 'unpaidList': null
}); // });
//删除订单 // //删除订单
wx.request({ // wx.request({
url: "http://45.76.158.31:8080/web/CheckOrders.do?UserID=1&OderId="+that.unpaidList[i].OrderID, // url: "https://hunjianghu.xuanjis.com/web/CheckOrders.do?UserID=1&OderId="+that.unpaidList[i].OrderID,
header: { // header: {
"content-type": "json" // "content-type": "json"
}, // },
success: function (res) { // success: function (res) {
if (res.statusCode == 200) { // if (res.statusCode == 200) {
console.log(res.data) // console.log(res.data)
that.setData({ // that.setData({
checkList: res.data // checkList: res.data
}) // })
//wx.hideNavigationBarLoading() // //wx.hideNavigationBarLoading()
} // }
} // }
}) // })
}, // },
order_status: function(e) { order_status: function(e) {
var that = this var that = this
var current = e.currentTarget.dataset.current var current = e.currentTarget.dataset.current
console.log("current=")
if(current==1){ console.log(current)
if (current == 0) {
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
success: function (res) { success: function(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
console.log(res.data) // console.log(res.data)
that.setData({ that.setData({
checkList: res.data unpaidList: res.data
}) })
//wx.hideNavigationBarLoading() //wx.hideNavigationBarLoading()
} }
} }
}) })
}else if(current==2){ } else if (current == 1) {
//获取待收货订单信息 //获取待收货订单信息
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
success: function (res) { success: function(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
console.log(res.data) // console.log(res.data)
that.setData({ that.setData({
dueinList: res.data dueinList: res.data
}) })
@ -288,20 +289,21 @@ Page({
} }
} }
}) })
}else if(current==3){ } else if (current == 2) {
//获取待发货信息 //获取待发货信息
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
success: function (res) { success: function(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
console.log(res.data) // console.log(res.data)
that.setData({ that.setData({
deliverList: res.data 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({ wx.showToast({
title: '付款成功!', title: '付款成功!',
icon: 'success', icon: 'success',
duration: 2000 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()
}
}
})
} }

@ -25,13 +25,13 @@
<view class="same_stroe"> <view class="same_stroe">
<view class="flexRowBetween orderlistShow"> <view class="flexRowBetween orderlistShow">
<view class="order_left"> <view class="order_left">
<image src="http://45.76.158.31:8080/web/BookImage/{{book.BookName}}.jpg"></image> <image src="https://hunjianghu.xuanjis.com/web/BookImage/{{book.BookName}}.jpg"></image>
</view> </view>
<view class="order_name"> <view class="order_name">
<view class="text1">{{book.BookName}}</view> <view class="text1">{{book.BookName}}</view>
<view class="orders flexRowBetween"> <view class="orders flexRowBetween">
<text class="order_type">数量:{{book.Count}}</text> <text class="order_type">数量:{{book.Count}}</text>
<text class="order_price">{{book.Price*book.Count}}</text> <!--<text class="order_price">{{book.Price*book.Count}}</text>-->
</view> </view>
</view> </view>
</view> </view>
@ -41,14 +41,14 @@
<view class="flexRowBetween"> <view class="flexRowBetween">
<view class="total_money"> <view class="total_money">
<text>合计:</text> <text>合计:</text>
<text class="text2">¥{{totalPrice}}</text> <text class="text2">¥{{book.Price*book.Count}}</text>
</view> </view>
</view> </view>
</view> </view>
<view class="handle_order"> <view class="handle_order">
<view class="flexRowBetween"> <view class="flexRowBetween">
<view class="handle_orders delete_order" bindtap='deleteList'>删除订单</view> <!--<view class="handle_orders delete_order" bindtap='deleteList'>删除订单</view>-->
<view class="handle_orders comment_order" bindtap='toPay' data-index="{{index}}">去付款</view> <view class="handle_orders comment_order" bindtap='toPay' data-index="{{index}}" data-id="{{book.OrderID}}">去付款</view>
</view> </view>
</view> </view>
</view> </view>
@ -68,7 +68,7 @@
<view class="same_stroe"> <view class="same_stroe">
<view class="flexRowBetween orderlistShow"> <view class="flexRowBetween orderlistShow">
<view class="order_left"> <view class="order_left">
<image src="http://45.76.158.31:8080/web/BookImage/{{book.BookName}}.jpg"></image> <image src="https://hunjianghu.xuanjis.com/web/BookImage/{{book.BookName}}.jpg"></image>
</view> </view>
<view class="order_name"> <view class="order_name">
<view class="text1">{{book.BookName}}</view> <view class="text1">{{book.BookName}}</view>
@ -83,10 +83,11 @@
<view class="flexRowBetween"> <view class="flexRowBetween">
<view class="total_money"> <view class="total_money">
<text>收货地址:</text> <text>收货地址:</text>
<text class="text2">{{book.Addresss}}</text> <text class="text2">{{book.Address}}</text>
</view> </view>
</view> </view>
</view> </view>
<!--
<view class="total_order"> <view class="total_order">
<view class="flexRowBetween"> <view class="flexRowBetween">
<view class="total_money"> <view class="total_money">
@ -94,7 +95,8 @@
<text class="text2">{{book.consignee}}</text> <text class="text2">{{book.consignee}}</text>
</view> </view>
</view> </view>
</view> </view>-->
<!--
<view class="total_order"> <view class="total_order">
<view class="flexRowBetween"> <view class="flexRowBetween">
<view class="total_money"> <view class="total_money">
@ -102,7 +104,7 @@
<text class="text2">{{book.phone}}</text> <text class="text2">{{book.phone}}</text>
</view> </view>
</view> </view>
</view> </view>-->
<!-- <!--
<view class="handle_order"> <view class="handle_order">
<view class="flexRowBetween"> <view class="flexRowBetween">
@ -112,8 +114,9 @@
</view>--> </view>-->
</view> </view>
<!--待发货-->
</view> </view>
<view class="order_all {{currentTap ==2?'order_show':''}}" wx:if="{{deliverList!=null}}" wx:for='{{dueinList}}' wx:for-item="book" wx:key="book.BookID"> <view class="order_all {{currentTap ==2?'order_show':''}}" wx:if="{{deliverList!=null}}" wx:for='{{deliverList}}' wx:for-item="book" wx:key="book.BookID">
<view class="order_tlt flexRowBetween"> <view class="order_tlt flexRowBetween">
<view class="tlt_left"> <view class="tlt_left">
<text>付款日期:</text> <text>付款日期:</text>
@ -126,7 +129,7 @@
<view class="same_stroe"> <view class="same_stroe">
<view class="flexRowBetween orderlistShow"> <view class="flexRowBetween orderlistShow">
<view class="order_left"> <view class="order_left">
<image src="http://45.76.158.31:8080/web/BookImage/{{book.BookName}}.jpg"></image> <image src="https://hunjianghu.xuanjis.com/web/BookImage/{{book.BookName}}.jpg"></image>
</view> </view>
<view class="order_name"> <view class="order_name">
<view class="text1">{{book.BookName}}</view> <view class="text1">{{book.BookName}}</view>
@ -145,6 +148,7 @@
</view> </view>
</view> </view>
</view> </view>
<!--
<view class="total_order"> <view class="total_order">
<view class="flexRowBetween"> <view class="flexRowBetween">
<view class="total_money"> <view class="total_money">
@ -152,7 +156,8 @@
<text class="text2">{{book.consignee}}</text> <text class="text2">{{book.consignee}}</text>
</view> </view>
</view> </view>
</view> </view>-->
<!--
<view class="total_order"> <view class="total_order">
<view class="flexRowBetween"> <view class="flexRowBetween">
<view class="total_money"> <view class="total_money">
@ -160,7 +165,7 @@
<text class="text2">{{book.phone}}</text> <text class="text2">{{book.phone}}</text>
</view> </view>
</view> </view>
</view> </view>-->
</view> </view>
</view> </view>
</view> </view>

@ -10,6 +10,7 @@ Page({
onLoad: function () { onLoad: function () {
}, },
<<<<<<< HEAD
userInfo: function () { userInfo: function () {
wx.navigateTo({ wx.navigateTo({
url: '/pages/userInfo/userInfo' url: '/pages/userInfo/userInfo'
@ -21,6 +22,9 @@ Page({
url: "/pages/wode/wode" url: "/pages/wode/wode"
}) })
}, },
=======
>>>>>>> 07cc8819d28ba7f7f16c159de7ad0994e47b4a1b
bindDateChange: function (e) { bindDateChange: function (e) {
this.setData({ this.setData({
date: e.detail.value date: e.detail.value

@ -41,7 +41,8 @@ Page({
}) })
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },
@ -70,7 +71,8 @@ Page({
onLoad: function(options) { onLoad: function(options) {
var thats = this var thats = this
wx.request({ 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: { header: {
"content-type": "json" "content-type": "json"
}, },

@ -3,7 +3,7 @@
<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"> <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<block wx:for="{{ppt}}" wx:for-item="ppts"> <block wx:for="{{ppt}}" wx:for-item="ppts">
<swiper-item> <swiper-item>
<image src="http://45.76.158.31:8080/web/BookImage/{{ppts.BookName}}.jpg" class="slide-image" width="355" height="240" /> <image src="https://hunjianghu.xuanjis.com/web/BookImage/{{ppts.BookName}}.jpg" class="slide-image" width="355" height="240" />
</swiper-item> </swiper-item>
</block> </block>
</swiper> </swiper>
@ -24,7 +24,7 @@
<view class="weui-panel__bd"> <view class="weui-panel__bd">
<navigator wx:for="{{book}}" wx:for-item="books" url="../detail/detail?id={{books.BookID}}" data-id="{{books.BookID}}" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active"> <navigator wx:for="{{book}}" wx:for-item="books" url="../detail/detail?id={{books.BookID}}" data-id="{{books.BookID}}" class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg" style="width:120px;height:80px;"> <view class="weui-media-box__hd weui-media-box__hd_in-appmsg" style="width:120px;height:80px;">
<image class="weui-media-box__thumb" src="http://45.76.158.31:8080/web/BookImage/{{books.BookName}}.jpg" /> <image class="weui-media-box__thumb" src="https://hunjianghu.xuanjis.com/web/BookImage/{{books.BookName}}.jpg" />
</view> </view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg"> <view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">{{books.BookName}}</view> <view class="weui-media-box__title">{{books.BookName}}</view>

@ -4,7 +4,7 @@
"ignore": [] "ignore": []
}, },
"setting": { "setting": {
"urlCheck": false, "urlCheck": true,
"es6": true, "es6": true,
"postcss": true, "postcss": true,
"minified": true, "minified": true,

Loading…
Cancel
Save