diff --git a/scr/food/app.json b/scr/food/app.json index 19062fe..b0dbd9a 100644 --- a/scr/food/app.json +++ b/scr/food/app.json @@ -11,7 +11,7 @@ "pages/change/change", "pages/answer/answer", "pages/paying/paying", - "pages/orderdoing/orderdoing", + "pages/orderlist/orderlist", "pages/address/address", "pages/turning/turning", "pages/addAddress/addAddress", diff --git a/scr/food/pages/addAddress/addAddress.js b/scr/food/pages/addAddress/addAddress.js index 6ab1484..b11613a 100644 --- a/scr/food/pages/addAddress/addAddress.js +++ b/scr/food/pages/addAddress/addAddress.js @@ -90,11 +90,13 @@ addresslist:{} return false } else { + var check=false var addresslist={} addresslist.name=this.data.consigneeName addresslist.phone=this.data.phone addresslist.address=this.data.consigneeRegion addresslist.detailedAddress=this.data.detailedAddress + addresslist.check=check this.setData({ addresslist:addresslist }) diff --git a/scr/food/pages/address/address.wxml b/scr/food/pages/address/address.wxml index 958504c..ab0d8d1 100644 --- a/scr/food/pages/address/address.wxml +++ b/scr/food/pages/address/address.wxml @@ -14,7 +14,7 @@ - {{item.detailAddress}} + {{item.detailedAddress}} diff --git a/scr/food/pages/detail/detail.js b/scr/food/pages/detail/detail.js index 711ecea..7d04bad 100644 --- a/scr/food/pages/detail/detail.js +++ b/scr/food/pages/detail/detail.js @@ -79,8 +79,15 @@ var userid=app.globalData.openid async immeBuy(event){ var index = event.currentTarget.dataset.item; console.log(index); + var detailObj=this.data.detailObj + var Selection=[] + + var num=1 + detailObj.num=num + Selection.push(detailObj) + var total=detailObj.price wx.navigateTo({ - url:'/pages/orderdoing/orderdoing?id='+ index, + url:'/pages/paying/paying?info='+JSON.stringify(Selection)+'&totalprice='+total }) }, /** diff --git a/scr/food/pages/orderdetail/orderdetail.js b/scr/food/pages/orderdetail/orderdetail.js index 7c7ec77..da1b124 100644 --- a/scr/food/pages/orderdetail/orderdetail.js +++ b/scr/food/pages/orderdetail/orderdetail.js @@ -5,13 +5,17 @@ Page({ * 页面的初始数据 */ data: { - + addresslist:{} }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { + console.log(options.info) +this.setData({ + orderlist:options.info +}) }, diff --git a/scr/food/pages/orderdetail/orderdetail.wxml b/scr/food/pages/orderdetail/orderdetail.wxml index a846378..247dec8 100644 --- a/scr/food/pages/orderdetail/orderdetail.wxml +++ b/scr/food/pages/orderdetail/orderdetail.wxml @@ -1,2 +1,2 @@ -pages/orderdetail/orderdetail.wxml +{{orderlist.address}} diff --git a/scr/food/pages/orderdetail/orderdetail.wxss b/scr/food/pages/orderdetail/orderdetail.wxss index 84af289..51ca20a 100644 --- a/scr/food/pages/orderdetail/orderdetail.wxss +++ b/scr/food/pages/orderdetail/orderdetail.wxss @@ -1 +1,110 @@ -/* pages/orderdetail/orderdetail.wxss */ \ No newline at end of file +/* pages/orderdetail/orderdetail.wxss */ +.scrol_view_style { + background: #f5f5f5; +} + +.carts_box { + display: flex; + align-items: center; + height: 100%; +} + +/*item*/ +.list_item_style { + height: 180rpx; + background: white; + padding-bottom: 20rpx; + padding-left: 20rpx; + padding-right: 20rpx; +} + +/*商品主图*/ + +.good_main_image { + width: 180rpx; + height: 180rpx; + margin-left: 10rpx; + border: 1rpx solid #bbb; +} + +/*商品名称*/ + +.item_good_title { + text-align: left; + font-size: 32rpx; + height: auto; + white-space: nowrap; + word-break: keep-all; + overflow: hidden; + text-overflow: ellipsis; + width: 90%; +} + +.cart_content_right { + display: flex; + flex-direction: column; + height: 100%; + margin-left: 20rpx; +} + +.btn_wrap { + display: flex; + flex-direction: row; + align-items: center; + width: 200rpx; +} + +.btn_wrap input { + background: #f8f8f8; + color: #666; + font-size: 26rpx; + right: 10rpx; + width: 50rpx; + text-align: center; +} + +.btn_wrap input:nth-child(2) { + margin: 0 10rpx; +} +.price_back_view { + display: flex; + align-items: center; + justify-content: space-between; + width: 460rpx; + padding-top: 20rpx; +} + +.cart_content_bottom { + display: flex; + align-items: center; + justify-content: space-between; + width: 460rpx; + padding-top: 25rpx; +} + +.cart_content_bottom .delete { + font-size: 28rpx; +} + +/*售价*/ + +.right_list_item_price { + color: #ff5d08; + font-size: 32rpx; +} + +/* 没有商品时的购物车样式 */ + +.no_shop { + text-align: center; + font-size: 50rpx; + color: #bbb; + margin-top: 100px; +} + +/*规格的样式*/ + +.guige { + font-size: 28rpx; +} + \ No newline at end of file diff --git a/scr/food/pages/orderdoing/orderdoing.js b/scr/food/pages/orderdoing/orderdoing.js deleted file mode 100644 index 3a04791..0000000 --- a/scr/food/pages/orderdoing/orderdoing.js +++ /dev/null @@ -1,82 +0,0 @@ -// pages/orderdoing/orderdoing.js -const db = wx.cloud.database({}); -const cont = db.collection('food'); -Page({ - - /** - * 页面的初始数据 - */ - data: { - orderfood:[] - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad:function(options) { - let foodid =options.id - cont.doc(foodid).get({ - success: res => { - console.log(res.data) - //这一步很重要,给ne赋值,没有这一步的话,前台就不会显示值 - this.setData({ - orderfood: res.data - }) - } - }) - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - }, - topay: function(){ - wx.navigateTo({ - url:'/pages/pay/pay', - }) - }, -}) \ No newline at end of file diff --git a/scr/food/pages/orderdoing/orderdoing.wxml b/scr/food/pages/orderdoing/orderdoing.wxml deleted file mode 100644 index 00cadad..0000000 --- a/scr/food/pages/orderdoing/orderdoing.wxml +++ /dev/null @@ -1,6 +0,0 @@ - -干饭地址: - - -{{orderfood.food_name}} - \ No newline at end of file diff --git a/scr/food/pages/orderdoing/orderdoing.wxss b/scr/food/pages/orderdoing/orderdoing.wxss deleted file mode 100644 index b0aa51f..0000000 --- a/scr/food/pages/orderdoing/orderdoing.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/orderdoing/orderdoing.wxss */ \ No newline at end of file diff --git a/scr/food/pages/orderlist/orderlist.js b/scr/food/pages/orderlist/orderlist.js new file mode 100644 index 0000000..abfd40b --- /dev/null +++ b/scr/food/pages/orderlist/orderlist.js @@ -0,0 +1,133 @@ +// pages/orderlist/orderlist.js +const db = wx.cloud.database({}); +const app=getApp() +const userid=app.globalData.openid +Page({ + + /** + * 页面的初始数据 + */ + data: { + orderlist:[] + }, + /** + * 点击删除订单 + */ + deleteGoods(event) { + var that = this; + const index = event.currentTarget.id; + console.log(index) + + let orderlist = this.data.orderlist;//购物车所有的商品数据 + let foodid=orderlist[index]._id + console.log(foodid) + wx.showModal({ + title: '温馨提示', + content: '确定删除当前商品吗?', + confirmColor: "#f00", + success: (res) => { + if (res.confirm) { + orderlist.splice(index, 1); + this.setData({ + orderlist:orderlist + }) + db.collection('user')//回调回云数据库 + . where({ + "_openid":userid + }) + .update( + { + data:{ + ['cartlist.'+[index]]:db.command.remove(), + } + }) + + db.collection('user')//回调回云数据库 + .where({ + "_openid":userid + }) + .update( + { + data:{ + ['Orderlist']:this.data.orderlist + } + } + ) + }} + }) + this.getTotalPrice() + console.log(orderlist) + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + db.collection("user") + .where({ + "_openid":userid + }) + .get() + .then(res => { + console.log("列表页", res.data); + console.log(res.data[0].Orderlist) + //再次显示数据 + this.setData({ + orderlist:res.data[0].Orderlist.reverse(), + + }) + }) + .catch(err => { + console.log("加载失败", err); + }) + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/scr/food/pages/orderdoing/orderdoing.json b/scr/food/pages/orderlist/orderlist.json similarity index 100% rename from scr/food/pages/orderdoing/orderdoing.json rename to scr/food/pages/orderlist/orderlist.json diff --git a/scr/food/pages/orderlist/orderlist.wxml b/scr/food/pages/orderlist/orderlist.wxml new file mode 100644 index 0000000..7ee721e --- /dev/null +++ b/scr/food/pages/orderlist/orderlist.wxml @@ -0,0 +1,28 @@ + + + + + + + + + {{item.food_name}} + + 总计:¥{{item.price}} + 时间:{{item.time}} + + + + + + + + + 删除 + + + + + + + \ No newline at end of file diff --git a/scr/food/pages/orderlist/orderlist.wxss b/scr/food/pages/orderlist/orderlist.wxss new file mode 100644 index 0000000..4eed314 --- /dev/null +++ b/scr/food/pages/orderlist/orderlist.wxss @@ -0,0 +1 @@ +/* pages/orderlist/orderlist.wxss */ \ No newline at end of file diff --git a/scr/food/pages/paying/paying.js b/scr/food/pages/paying/paying.js index f4d27af..006cc97 100644 --- a/scr/food/pages/paying/paying.js +++ b/scr/food/pages/paying/paying.js @@ -14,7 +14,22 @@ Page({ addresslist:[], buylist:[], orderlist:{}, - totalprice:0 + totalprice:0, + Selection_address:[] + + }, + allCheckbox: function(tap) { + var a = 0 //设置初始总价格 + var index = tap.currentTarget.dataset.index + console.log(index)//获取索引值 + let address = this.data.addresslist //获取地址列表 + const check = address[index].check; //获取当前地址的选中状态 + address[index].check = !check //改变当前商品的状态 + console.log(check) + this.setData({ + addresslist: address + }); + }, @@ -73,20 +88,56 @@ Page({ */ inputPwd(e){ this.setData({ pwdVal: e.detail.value }); - if (e.detail.value.length >= 6){ this.hidePayLayer(); wx.showModal({ title:'支付成功', success: (res) => { - if (res.confirm) { + var addresslist=this.data.addresslist + console.log(addresslist) + var addresslist_one1 = {} + var buylist=this.data.buylist + addresslist_one1.food_name=buylist[0].food_name + addresslist_one1.food_shop=buylist[0].food_shop + addresslist_one1.num=buylist[0].num + addresslist_one1.price=this.data.totalprice + addresslist_one1.url=buylist[0].url + for (var i = 0; i < this.data.addresslist.length; i++) { //循环地址列表中的地址 + if (addresslist[i].check == true) { + var Selection_address=[] + + addresslist_one1.address=addresslist[i].address + addresslist_one1.detailedAddress=addresslist[i].detailedAddress + addresslist_one1.name=addresslist[i].name + addresslist_one1.phone=addresslist[i].phone + + console.log(addresslist_one1) + +} +} + var time=new Date().toJSON().substring(0, 10) + ' ' + new Date().toTimeString().substring(0,8) + addresslist_one1.time=time + console.log(time) + db.collection('user').where({ + "_openid":userid + }).update({ + data:{ + Orderlist:db.command.push(addresslist_one1) + }, + + }) + + if (res.confirm) { + wx.navigateTo({ - url:'/pages/orderdetail/orderdetail' - }) - } - } - })} - }, + url:'/pages/orderlist/orderlist?info='+JSON.stringify(addresslist_one1) + })} +} +}) +}}, + + + diff --git a/scr/food/pages/paying/paying.wxml b/scr/food/pages/paying/paying.wxml index 6f3be57..f11205a 100644 --- a/scr/food/pages/paying/paying.wxml +++ b/scr/food/pages/paying/paying.wxml @@ -5,11 +5,17 @@ - - {{item.address}} - {{item.detailedAddress}} + + + + + {{item.address}}\n + {{item.detailedAddress}}\n + + 收货人:{{item.name}}\n + 电话:{{item.phone}} - + diff --git a/scr/food/pages/paying/paying.wxss b/scr/food/pages/paying/paying.wxss index 5ec37b6..8aeacc1 100644 --- a/scr/food/pages/paying/paying.wxss +++ b/scr/food/pages/paying/paying.wxss @@ -108,3 +108,20 @@ .activity-color-bg { background: #ff9c35; } +/*选择的样式*/ +checkbox .wx-checkbox-input { + border-radius: 50%; /* 圆角 */ + width: 35rpx; /* 背景的宽 */ + height: 35rpx; /* 背景的高 */ +} +/*选择地址的样式的样式*/ +.container{ + padding: 10px 20px; + align-content: center; +} +.text-content{ + padding: 10px; + align-content: center; + border-bottom: 1rpx solid #F5F5F5; + background-color: #FFFFFF +} \ No newline at end of file diff --git a/scr/food/pages/usercenter/usercenter.wxml b/scr/food/pages/usercenter/usercenter.wxml index 46c0436..e474d58 100644 --- a/scr/food/pages/usercenter/usercenter.wxml +++ b/scr/food/pages/usercenter/usercenter.wxml @@ -13,12 +13,14 @@ 待付款 + - 待发货 + 待发货 + - 待收货 + 待收货