订单完成

master
wbb 2 years ago
parent 0c872d31dc
commit ee98635253

@ -11,7 +11,7 @@
"pages/change/change", "pages/change/change",
"pages/answer/answer", "pages/answer/answer",
"pages/paying/paying", "pages/paying/paying",
"pages/orderdoing/orderdoing", "pages/orderlist/orderlist",
"pages/address/address", "pages/address/address",
"pages/turning/turning", "pages/turning/turning",
"pages/addAddress/addAddress", "pages/addAddress/addAddress",

@ -90,11 +90,13 @@ addresslist:{}
return false return false
} }
else { else {
var check=false
var addresslist={} var addresslist={}
addresslist.name=this.data.consigneeName addresslist.name=this.data.consigneeName
addresslist.phone=this.data.phone addresslist.phone=this.data.phone
addresslist.address=this.data.consigneeRegion addresslist.address=this.data.consigneeRegion
addresslist.detailedAddress=this.data.detailedAddress addresslist.detailedAddress=this.data.detailedAddress
addresslist.check=check
this.setData({ this.setData({
addresslist:addresslist addresslist:addresslist
}) })

@ -14,7 +14,7 @@
<view class="ui-list-item-address"> <view class="ui-list-item-address">
{{item.detailAddress}} <text>{{item.detailedAddress}}</text>
</view> </view>

@ -79,8 +79,15 @@ var userid=app.globalData.openid
async immeBuy(event){ async immeBuy(event){
var index = event.currentTarget.dataset.item; var index = event.currentTarget.dataset.item;
console.log(index); 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({ wx.navigateTo({
url:'/pages/orderdoing/orderdoing?id='+ index, url:'/pages/paying/paying?info='+JSON.stringify(Selection)+'&totalprice='+total
}) })
}, },
/** /**

@ -5,13 +5,17 @@ Page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
addresslist:{}
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
console.log(options.info)
this.setData({
orderlist:options.info
})
}, },

@ -1,2 +1,2 @@
<!--pages/orderdetail/orderdetail.wxml--> <!--pages/orderdetail/orderdetail.wxml-->
<text>pages/orderdetail/orderdetail.wxml</text> <text>{{orderlist.address}}</text>

@ -1 +1,110 @@
/* pages/orderdetail/orderdetail.wxss */ /* 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;
}

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

@ -1,6 +0,0 @@
<view>干饭地址:</view>
<image src="{{orderfood.url}}"></image>
<view>{{orderfood.food_name}}</view>
<button bindtap="primary" style="background-color: rgb(253, 228, 84);" bindtap="topay">立即支付</button>

@ -1 +0,0 @@
/* pages/orderdoing/orderdoing.wxss */

@ -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() {
}
})

@ -0,0 +1,28 @@
<!--pages/orderlist/orderlist.wxml-->
<view>
<scroll-view class="scrol_view_style" scroll-x="{{false}}" scroll-y="{{true}}">
<view style="height: 10rpx;"></view>
<view wx:for-items="{{orderlist}}" class="list_item_style" wx:key="{{ index }}">
<view class="carts_box">
<image src="{{item.url}}" class="good_main_image" style="border-radius: 20px;"></image>
<view class="cart_content_right">
<text class="item_good_title">{{item.food_name}}</text>
<view class="price_back_view">
<text class="right_list_item_price">总计:¥{{item.price}}</text>
<text>时间:{{item.time}}</text>
</view>
<view class="cart_content_bottom">
<view class='btn_wrap'>
<!-- <image src="/images/reduce.png" class = "reduce_image_style" id = "{{index}}" bindtap = "reduceButtonClick"></image> -->
<input type='text' value="*{{item.num}}" />
<!-- <image src="/images/add.png" class = "add_image_style" id = "{{index}}" bindtap = "addButtonClick"></image> -->
</view>
<view class="delete" bindtap="deleteGoods" id="{{index}}">删除</view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>

@ -0,0 +1 @@
/* pages/orderlist/orderlist.wxss */

@ -14,7 +14,22 @@ Page({
addresslist:[], addresslist:[],
buylist:[], buylist:[],
orderlist:{}, 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){ inputPwd(e){
this.setData({ pwdVal: e.detail.value }); this.setData({ pwdVal: e.detail.value });
if (e.detail.value.length >= 6){ if (e.detail.value.length >= 6){
this.hidePayLayer(); this.hidePayLayer();
wx.showModal({ wx.showModal({
title:'支付成功', title:'支付成功',
success: (res) => { 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({ wx.navigateTo({
url:'/pages/orderdetail/orderdetail' url:'/pages/orderlist/orderlist?info='+JSON.stringify(addresslist_one1)
}) })}
} }
} })
})} }},
},

@ -5,11 +5,17 @@
<view><text class="iconfont icon-arrowright"></text></view> <view><text class="iconfont icon-arrowright"></text></view>
</view> </view>
<view class="Receiving_address" bindtap="bindaddress"> <view class="Receiving_address" bindtap="bindaddress">
<view wx:for="{{addresslist}}">
<text>{{item.address}}</text> <view wx:for="{{addresslist}}" class="container1">
<text>{{item.detailedAddress}}</text> <view class="text-content">
<checkbox checked="{{item.check}}" class="checkbox_one" data-index="{{index}}" bindtap="allCheckbox" />
<text>{{item.address}}\n</text>
<text>{{item.detailedAddress}}\n</text>
<text>收货人:{{item.name}}\n</text>
<text>电话:{{item.phone}}</text>
</view>
</view> </view>
<view><text class="iconfont icon-arrowright"></text></view> <view><text class="iconfont icon-arrowright"></text></view>
</view> </view>

@ -108,3 +108,20 @@
.activity-color-bg { .activity-color-bg {
background: #ff9c35; 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
}

@ -13,12 +13,14 @@
<text class="text_saoyisao">待付款</text> <text class="text_saoyisao">待付款</text>
</view> </view>
<view class="view_tupianwenzi"> <view class="view_tupianwenzi">
<navigator url="/pages/orderlist/orderlist">
<image class="image_tupian" src="/images/test2.jpg"></image> <image class="image_tupian" src="/images/test2.jpg"></image>
<text class="text_saoyisao">待发货</text> <text class="text_saoyisao">待发货</text></navigator>
</view> </view>
<view class="view_tupianwenzi"> <view class="view_tupianwenzi">
<navigator url="/pages/orderlist/orderlist">
<image class="image_tupian" src="/images/test3.jpg"></image> <image class="image_tupian" src="/images/test3.jpg"></image>
<text class="text_saoyisao">待收货</text> <text class="text_saoyisao">待收货</text></navigator>
</view> </view>
<view class="view_tupianwenzi"> <view class="view_tupianwenzi">
<image class="image_tupian" src="/images/test4.jpg"></image> <image class="image_tupian" src="/images/test4.jpg"></image>

Loading…
Cancel
Save