From 07cc8819d28ba7f7f16c159de7ad0994e47b4a1b Mon Sep 17 00:00:00 2001 From: Eridani11579 Date: Thu, 17 Jan 2019 10:06:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 江可飞/小程序开发/app.js | 27 ++-- .../小程序开发/pages/detail/detail.js | 17 +- .../小程序开发/pages/detail/detail.wxml | 4 +- .../小程序开发/pages/fenlei/fenlei.js | 4 +- .../小程序开发/pages/fenlei/fenlei.wxml | 2 +- .../小程序开发/pages/gouwu/gouwu.js | 126 +++++++++------ .../小程序开发/pages/gouwu/gouwu.wxml | 2 +- .../小程序开发/pages/order/order.js | 152 +++++++++++------- .../小程序开发/pages/order/order.wxml | 31 ++-- 江可飞/小程序开发/pages/shdz/shdz.js | 8 +- .../小程序开发/pages/shouye/shouye.js | 6 +- .../小程序开发/pages/shouye/shouye.wxml | 4 +- 江可飞/小程序开发/project.config.json | 2 +- 13 files changed, 231 insertions(+), 154 deletions(-) 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 182e079..dcd59ac 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,10 +76,23 @@ 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 f7d30c0..2ff5c89 100644 --- a/江可飞/小程序开发/pages/gouwu/gouwu.js +++ b/江可飞/小程序开发/pages/gouwu/gouwu.js @@ -65,14 +65,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, }) @@ -82,7 +81,6 @@ Page({ }) bookList.splice(index, 1); - console.log(index) this.setData({ bookList: bookList }); @@ -134,14 +132,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, }) @@ -169,14 +166,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, }) @@ -190,7 +186,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) { @@ -241,7 +237,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 }) @@ -267,7 +263,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" }, @@ -275,22 +271,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() { - + }, /** @@ -327,50 +329,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 20aabff..4c3c3f9 100644 --- a/江可飞/小程序开发/pages/gouwu/gouwu.wxml +++ b/江可飞/小程序开发/pages/gouwu/gouwu.wxml @@ -25,7 +25,7 @@ - + {{book.BookName}} diff --git a/江可飞/小程序开发/pages/order/order.js b/江可飞/小程序开发/pages/order/order.js index 2442062..5a24794 100644 --- a/江可飞/小程序开发/pages/order/order.js +++ b/江可飞/小程序开发/pages/order/order.js @@ -15,7 +15,7 @@ Page({ 'unpaidList': [], //待付款 'dueinList': [], //待收货 'deliverList': [], //待发货 - 'checkList':[], + 'checkList': [], // 'unpaidLists': [ //待付款 // { @@ -85,25 +85,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" }, @@ -120,11 +120,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({ @@ -154,62 +154,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 }) @@ -217,20 +218,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() } } }) @@ -241,13 +243,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 76e687d..98c685e 100644 --- a/江可飞/小程序开发/pages/shdz/shdz.js +++ b/江可飞/小程序开发/pages/shdz/shdz.js @@ -10,11 +10,7 @@ Page({ onLoad: function () { }, - userInfo: function () { - wx.navigateTo({ - url: '/pages/userInfo/userInfo' - }) - }, + bindDateChange: function (e) { this.setData({ date: e.detail.value @@ -32,7 +28,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 8b948f4..9fd2ea0 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,