Browse Source

购物车酒店

dev
jiazhipeng 4 months ago
parent
commit
5fb999e662
  1. 60
      pages/cart/cart.vue
  2. 82
      subPackages/order/cartOrder.vue

60
pages/cart/cart.vue

@ -89,7 +89,7 @@
<uni-popup ref="calendarPopup" type="bottom">
<view style="width: 100vw;height: 60vh;" v-if="selectDate.show">
<SelectCalendar :startDate="selectDate.startDay" :endDate="selectDate.endDay"></SelectCalendar>
<SelectCalendar :startDate="selectDate.startDay" :endDate="selectDate.endDay" @changeHotelDate="judgeHotelTime"></SelectCalendar>
</view>
</uni-popup>
</view>
@ -117,19 +117,6 @@
},
}
},
onLoad() {
uni.$on('changeHotelDate', data => {
if(data) {
this.judgeHotelTime(data)
console.log(data)
} else {
this.$refs.calendarPopup.close();
}
})
},
onUnload() {
uni.$off('changeHotelDate')
},
onShow() {
this.getList()
},
@ -146,20 +133,32 @@
// })
let shopSelectIds = []
let skuSelectIds = []
let skuSelectIds = [] // skus
let skus = [] // skus skus
this.cartList.forEach(v=>{
if (v.is_seld) {shopSelectIds.push(v.id)}
v.goods.forEach(x=>{
if(x.is_seld) {skuSelectIds.push(x.sku_id)}
if (x.product.type == 'hotel') {
skus.push(x)
}
})
})
resData.forEach(v=>{
v.is_seld = shopSelectIds.includes(v.id)
// v.show = true
v.goods.forEach(x=>{
x.is_seld = skuSelectIds.includes(x.sku_id)
// v.show = true
if (x.product.type == 'hotel') {
let xData = skus.find(s=>s.sku_id == x.sku_id)
if (xData) {
x.startDay = xData.startDay
x.endDay = xData.endDay
x.differDays = xData.differDays
}
}
})
})
this.cartList = resData
@ -319,26 +318,31 @@
},
judgeHotelTime (data) {
this.$set(this.selectHotel, "startDay", data.startDay)
this.$set(this.selectHotel, "endDay", data.endDay)
this.$set(this.selectHotel, "differDays", data.differDays)
this.$refs.calendarPopup.close();
return
if(!data) {
this.$refs.calendarPopup.close();
return
}
// this.$set(this.selectHotel, "startDay", data.startDay)
// this.$set(this.selectHotel, "endDay", data.endDay)
// this.$set(this.selectHotel, "differDays", data.differDays)
// this.$refs.calendarPopup.close();
// return
this.Post({
sku_id: this.selectHotel.sku_id,
start_date: data.startDay,
end_date: data.endDay
}, "/api/product/product_date_buy").then(res=>{
if (res && res.code && res.data) {
this.$set(this.selectHotel, "startDay", data.startDay)
this.$set(this.selectHotel, "endDay", data.endDay)
this.$set(this.selectHotel, "differDays", data.differDays)
this.$refs.calendarPopup.close();
} else {
if (res.data === false) {
uni.showToast({
title:'当前时间不可预定',
icon:"none"
})
} else {
this.$set(this.selectHotel, "startDay", data.startDay)
this.$set(this.selectHotel, "endDay", data.endDay)
this.$set(this.selectHotel, "differDays", data.differDays)
this.selectHotel.sku.price = res.data
this.$refs.calendarPopup.close();
}
})
},

82
subPackages/order/cartOrder.vue

@ -2,6 +2,31 @@
<view class="bg" >
<view class="goods-container" v-if="hotelOrderList.length>0">
<view class="goods-type-tag">酒店</view>
<view class="ticket-item" v-for="(item,i) in hotelOrderList" :key="i">
<view class="sku-item">
<view class="sku-content">
<view class="title" style="font-weight: bold;font-size: 35rpx;color: #000000;">
{{item.sku_name}}
</view>
<view class="subtitle text-overflow" style="font-size: 26rpx;">
<text>{{new Date(item.selectDate.startDay).Format("MM-dd") }}{{new Date(item.selectDate.startDay).Format("MM-dd")}}</text>
<text style="padding: 0 6rpx;">|</text>
<text>{{item.sku_name}}</text>
</view>
</view>
</view>
<view class="other-info">
<view class="flex">
<view class="flex-shrink-0" style="color: #666666;">入住人:</view>
<view style="padding-left: 20rpx;">{{item.roomNames.join(" ")}}</view>
</view>
<view class="flex">
<view class="flex-shrink-0" style="color: #666666;">联系电话:</view>
<view style="padding-left: 20rpx;">{{item.phone}}</view>
</view>
</view>
</view>
<view class="cal-price">
小计: <text class="price">{{priceParam.hotelPrice/100}}</text>
@ -185,23 +210,24 @@ export default {
methods: {
handleOrderGoods () {
//
// let techanOrderList = this.$store.state.user.techanOrderList;
let techanOrderList = JSON.parse(uni.getStorageSync("techanOrderList"))
let techanOrderList = this.$store.state.user.techanOrderList;
// let techanOrderList = JSON.parse(uni.getStorageSync("techanOrderList"))
// console.log(techanOrderList)
//
this.postOrderList = techanOrderList.filter(v=>v.is_user_post == 1)
//
this.pickupOrderList = techanOrderList.filter(v=>v.is_user_post == 2)
//
// let ticketOrderList = this.$store.state.user.ticketOrderList;
// let foodOrderList = this.$store.state.user.foodOrderList;
let ticketOrderList = (uni.getStorageSync("ticketOrderList")) || []
let foodOrderList = (uni.getStorageSync("foodOrderList")) || []
let ticketOrderList = this.$store.state.user.ticketOrderList;
let foodOrderList = this.$store.state.user.foodOrderList;
// let ticketOrderList = (uni.getStorageSync("ticketOrderList")) || []
// let foodOrderList = (uni.getStorageSync("foodOrderList")) || []
console.log(ticketOrderList, foodOrderList)
this.playOrderList = ticketOrderList.concat(foodOrderList)
//
// let hotelOrderList = this.$store.state.user.hotelOrderList;
let hotelOrderList = JSON.parse(uni.getStorageSync("hotelOrderList"))
this.hotelOrderList = hotelOrderList
this.calPrice()
},
@ -221,7 +247,8 @@ export default {
skuIds.push(v.sInfo.id)
})
this.hotelOrderList.forEach(v=>{
// price4+= v.sInfo.price * v.sInfo.buyNum
price4+= v.price * v.buyNum
skuIds.push(v.id)
})
this.skuIds = skuIds
@ -266,16 +293,33 @@ export default {
//
order() {
let goods = []
//
this.postOrderList.forEach(item=>{
//
this.playOrderList.forEach(item=>{
let param = {
// type: item.pInfo.type,
// product_id: item.pInfo.id,
// sku_id: item.sInfo.id,
// product_num: item.sInfo.buyNum,
// phone: item.phone,
// remark: item.remark,
}
goods.push(param)
})
//
this.playOrderList.forEach(item=>{
let param = {
type: item.pInfo.type,
product_id: item.pInfo.id,
sku_id: item.sInfo.id,
product_num: item.sInfo.buyNum,
phone: item.phone,
remark: item.remark,
use_type:1,
post: item.contacts.id
}
if (item.showDate) {
param.use_date= item.showDate.date ||'';
param.start_time = item.showDate.start_time || '';
param.end_time = item.showDate.end_time || '';
}
goods.push(param)
})
@ -293,23 +337,21 @@ export default {
}
goods.push(param)
})
//
this.playOrderList.forEach(item=>{
//
this.postOrderList.forEach(item=>{
let param = {
type: item.pInfo.type,
product_id: item.pInfo.id,
sku_id: item.sInfo.id,
product_num: item.sInfo.buyNum,
phone: item.phone,
remark: item.remark,
}
if (item.showDate) {
param.use_date= item.showDate.date ||'';
param.start_time = item.showDate.start_time || '';
param.end_time = item.showDate.end_time || '';
use_type:1,
post: item.contacts.id
}
goods.push(param)
})
let data = {
product_list: goods,

Loading…
Cancel
Save