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"> <uni-popup ref="calendarPopup" type="bottom">
<view style="width: 100vw;height: 60vh;" v-if="selectDate.show"> <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> </view>
</uni-popup> </uni-popup>
</view> </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() { onShow() {
this.getList() this.getList()
}, },
@ -146,20 +133,32 @@
// }) // })
let shopSelectIds = [] let shopSelectIds = []
let skuSelectIds = [] let skuSelectIds = [] // skus
let skus = [] // skus skus
this.cartList.forEach(v=>{ this.cartList.forEach(v=>{
if (v.is_seld) {shopSelectIds.push(v.id)} if (v.is_seld) {shopSelectIds.push(v.id)}
v.goods.forEach(x=>{ v.goods.forEach(x=>{
if(x.is_seld) {skuSelectIds.push(x.sku_id)} if(x.is_seld) {skuSelectIds.push(x.sku_id)}
if (x.product.type == 'hotel') {
skus.push(x)
}
}) })
}) })
resData.forEach(v=>{ resData.forEach(v=>{
v.is_seld = shopSelectIds.includes(v.id) v.is_seld = shopSelectIds.includes(v.id)
// v.show = true
v.goods.forEach(x=>{ v.goods.forEach(x=>{
x.is_seld = skuSelectIds.includes(x.sku_id) 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 this.cartList = resData
@ -319,26 +318,31 @@
}, },
judgeHotelTime (data) { judgeHotelTime (data) {
this.$set(this.selectHotel, "startDay", data.startDay) if(!data) {
this.$set(this.selectHotel, "endDay", data.endDay) this.$refs.calendarPopup.close();
this.$set(this.selectHotel, "differDays", data.differDays) return
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({ this.Post({
sku_id: this.selectHotel.sku_id, sku_id: this.selectHotel.sku_id,
start_date: data.startDay, start_date: data.startDay,
end_date: data.endDay end_date: data.endDay
}, "/api/product/product_date_buy").then(res=>{ }, "/api/product/product_date_buy").then(res=>{
if (res && res.code && res.data) { if (res.data === false) {
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 {
uni.showToast({ uni.showToast({
title:'当前时间不可预定', title:'当前时间不可预定',
icon:"none" 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="bg" >
<view class="goods-container" v-if="hotelOrderList.length>0"> <view class="goods-container" v-if="hotelOrderList.length>0">
<view class="goods-type-tag">酒店</view> <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"> <view class="cal-price">
小计: <text class="price">{{priceParam.hotelPrice/100}}</text> 小计: <text class="price">{{priceParam.hotelPrice/100}}</text>
@ -185,23 +210,24 @@ export default {
methods: { methods: {
handleOrderGoods () { handleOrderGoods () {
// //
// let techanOrderList = this.$store.state.user.techanOrderList; let techanOrderList = this.$store.state.user.techanOrderList;
let techanOrderList = JSON.parse(uni.getStorageSync("techanOrderList")) // let techanOrderList = JSON.parse(uni.getStorageSync("techanOrderList"))
// console.log(techanOrderList) // console.log(techanOrderList)
// //
this.postOrderList = techanOrderList.filter(v=>v.is_user_post == 1) this.postOrderList = techanOrderList.filter(v=>v.is_user_post == 1)
// //
this.pickupOrderList = techanOrderList.filter(v=>v.is_user_post == 2) this.pickupOrderList = techanOrderList.filter(v=>v.is_user_post == 2)
// //
// let ticketOrderList = this.$store.state.user.ticketOrderList; let ticketOrderList = this.$store.state.user.ticketOrderList;
// let foodOrderList = this.$store.state.user.foodOrderList; let foodOrderList = this.$store.state.user.foodOrderList;
let ticketOrderList = (uni.getStorageSync("ticketOrderList")) || [] // let ticketOrderList = (uni.getStorageSync("ticketOrderList")) || []
let foodOrderList = (uni.getStorageSync("foodOrderList")) || [] // let foodOrderList = (uni.getStorageSync("foodOrderList")) || []
console.log(ticketOrderList, foodOrderList) console.log(ticketOrderList, foodOrderList)
this.playOrderList = ticketOrderList.concat(foodOrderList) this.playOrderList = ticketOrderList.concat(foodOrderList)
// //
// let hotelOrderList = this.$store.state.user.hotelOrderList; // let hotelOrderList = this.$store.state.user.hotelOrderList;
let hotelOrderList = JSON.parse(uni.getStorageSync("hotelOrderList"))
this.hotelOrderList = hotelOrderList
this.calPrice() this.calPrice()
}, },
@ -221,7 +247,8 @@ export default {
skuIds.push(v.sInfo.id) skuIds.push(v.sInfo.id)
}) })
this.hotelOrderList.forEach(v=>{ this.hotelOrderList.forEach(v=>{
// price4+= v.sInfo.price * v.sInfo.buyNum price4+= v.price * v.buyNum
skuIds.push(v.id)
}) })
this.skuIds = skuIds this.skuIds = skuIds
@ -266,16 +293,33 @@ export default {
// //
order() { order() {
let goods = [] 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 = { let param = {
type: item.pInfo.type, type: item.pInfo.type,
product_id: item.pInfo.id, product_id: item.pInfo.id,
sku_id: item.sInfo.id, sku_id: item.sInfo.id,
product_num: item.sInfo.buyNum, product_num: item.sInfo.buyNum,
phone: item.phone,
remark: item.remark, 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) goods.push(param)
}) })
@ -293,24 +337,22 @@ export default {
} }
goods.push(param) goods.push(param)
}) })
// //
this.playOrderList.forEach(item=>{ this.postOrderList.forEach(item=>{
let param = { let param = {
type: item.pInfo.type, type: item.pInfo.type,
product_id: item.pInfo.id, product_id: item.pInfo.id,
sku_id: item.sInfo.id, sku_id: item.sInfo.id,
product_num: item.sInfo.buyNum, product_num: item.sInfo.buyNum,
phone: item.phone,
remark: item.remark, remark: item.remark,
} use_type:1,
if (item.showDate) { post: item.contacts.id
param.use_date= item.showDate.date ||'';
param.start_time = item.showDate.start_time || '';
param.end_time = item.showDate.end_time || '';
} }
goods.push(param) goods.push(param)
}) })
let data = { let data = {
product_list: goods, product_list: goods,
coupon_id: this.coupon ? this.coupon.id : null, coupon_id: this.coupon ? this.coupon.id : null,

Loading…
Cancel
Save