jiazhipeng 4 months ago
parent
commit
f5d88432ee
  1. 3
      static/js/CommonFunction.js
  2. 9
      subPackages/homestay/detail.vue
  3. 740
      subPackages/homestay/order.vue

3
static/js/CommonFunction.js

@ -291,12 +291,13 @@ Vue.prototype.goCartNextPage= function(currentPageIndex){
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 hotelOrderList = this.$store.state.user.hotelOrderList; let hotelOrderList = this.$store.state.user.hotelOrderList;
console.log(hotelOrderList)
let orderPage = [ let orderPage = [
{path: '/subPackages/techan/order', length: techanOrderList.length}, {path: '/subPackages/techan/order', length: techanOrderList.length},
{path: '/subPackages/ticket/order', length: ticketOrderList.length}, {path: '/subPackages/ticket/order', length: ticketOrderList.length},
{path: '/subPackages/food/order', length: foodOrderList.length}, {path: '/subPackages/food/order', length: foodOrderList.length},
{path: '',length: hotelOrderList.length} {path: '/subPackages/homestay/order',length: hotelOrderList.length}
] ]
let nextPage = orderPage.find((v,index)=>v.length>0&&index>=currentPageIndex) let nextPage = orderPage.find((v,index)=>v.length>0&&index>=currentPageIndex)
if (nextPage) { if (nextPage) {

9
subPackages/homestay/detail.vue

@ -319,11 +319,10 @@
if (item.stock == 0) { if (item.stock == 0) {
return return
} }
item.selectDate = this.selectDate
let param = { item.allSeldDate = []
skuInfo: item, item.buyNum = 1
selectDate: this.selectDate let param = [{skuInfo: item}]
}
uni.setStorageSync('hotelOrderInfo', JSON.stringify(param)) uni.setStorageSync('hotelOrderInfo', JSON.stringify(param))
uni.navigateTo({ uni.navigateTo({
url:`/subPackages/homestay/order` url:`/subPackages/homestay/order`

740
subPackages/homestay/order.vue

@ -1,374 +1,387 @@
<template> <template>
<view class="bg"> <view class="bg">
<view class="detail-container"> <!-- 循环渲染每个订单信息 -->
<view class="common-container info-container"> <view class="detail-container" v-for="(order, index) in skuInfo" :key="index">
<view class="flex-between" style="align-items: flex-start;"> <view class="common-container info-container">
<view class="info-title text-overflowRows">{{skuInfo.sku_name}}</view> <view class="flex-between" style="align-items: flex-start;">
<view class="policy-btn flex-shrink-0 flex flex-items-center" @click="openPopRule"> <view class="info-title text-overflowRows">{{order.sku_name}}</view>
房型信息 <view class="policy-btn flex-shrink-0 flex flex-items-center" @click="openPopRule(index)">
<uni-icons color="#71B580" style="height: 32rpx;" type="right" size="12"></uni-icons> 房型信息
</view> <uni-icons color="#71B580" style="height: 32rpx;" type="right" size="12"></uni-icons>
</view> </view>
</view>
<view class="tag-container text-overflow">
{{skuInfo.sku_model.bed_type}} | {{skuInfo.sku_model.area}} <view class="tag-container text-overflow">
| {{skuInfo.sku_model.window}} | 可入住{{skuInfo.sku_model.max_room_num}} {{order.sku_model.bed_type}} | {{order.sku_model.area}}
| {{skuInfo.sku_model.breakfast}} | {{order.sku_model.window}} | 可入住{{order.sku_model.max_room_num}}
</view> | {{order.sku_model.breakfast}}
</view>
<view class="order-time flex-between" style="justify-content: space-around;">
<view class="time"> <view class="order-time flex-between" style="justify-content: space-around;">
<view style="font-size: 35rpx;font-weight: bold;"> <view class="time">
{{new Date(selectDate.startDay).Format('MM-dd')}}</view> <view style="font-size: 35rpx;font-weight: bold;">
<view style="padding-left:14rpx">{{ ShowDateDay(new Date(selectDate.startDay).getDay()) }} {{new Date(order.selectDate.startDay).Format('MM-dd')}}</view>
</view> <view style="padding-left:14rpx">{{ ShowDateDay(new Date(order.selectDate.startDay).getDay()) }}
<view>入住</view> </view>
</view> <view>入住</view>
<view class="cal-day"> </view>
{{selectDate.differDays}} <view class="cal-day">
</view> {{order.selectDate.differDays}}
<view class="time"> </view>
<view style="font-size: 35rpx;font-weight: bold;"> <view class="time">
{{new Date(selectDate.endDay).Format('MM-dd')}}</view> <view style="font-size: 35rpx;font-weight: bold;">
<view style="padding-left:14rpx">{{ShowDateDay(new Date(selectDate.endDay).getDay()) }}</view> {{new Date(order.selectDate.endDay).Format('MM-dd')}}</view>
<view>离店</view> <view style="padding-left:14rpx">{{ShowDateDay(new Date(order.selectDate.endDay).getDay()) }}</view>
</view> <view>离店</view>
</view> </view>
</view>
<view class="notice-container">
<view class="flex" style="align-items: center;"> <view class="notice-container">
<view class="flex-shrink-0" style="padding-top: 4rpx;"> <view class="flex" style="align-items: center;">
<image src="https://static.ticket.sz-trip.com/shiweisuzhou/images/homestay/dui.png"></image> <view class="flex-shrink-0" style="padding-top: 4rpx;">
</view> <image src="https://static.ticket.sz-trip.com/shiweisuzhou/images/homestay/dui.png"></image>
<view class="flex-1 w-1rpx" style="padding-left: 14rpx;"> </view>
<view v-html="formateRichText(skuInfo.sku_model.bookinfo)"></view> <view class="flex-1 w-1rpx" style="padding-left: 14rpx;">
</view> <view v-html="formateRichText(order.sku_model.bookinfo)"></view>
</view> </view>
</view>
<view class="flex" style="padding-top: 22rpx;align-items: center;">
<view class="flex-shrink-0" style="padding-top: 4rpx;"> <view class="flex" style="padding-top: 22rpx;align-items: center;">
<image src="https://static.ticket.sz-trip.com/shiweisuzhou/images/homestay/tanhao.png"> <view class="flex-shrink-0" style="padding-top: 4rpx;">
</image> <image src="https://static.ticket.sz-trip.com/shiweisuzhou/images/homestay/tanhao.png">
</view> </image>
<view class="flex-1 w-1rpx" style="padding-left: 14rpx;"> </view>
<view>证件要求大陆居民身份证登记入住</view> <view class="flex-1 w-1rpx" style="padding-left: 14rpx;">
</view> <view>证件要求大陆居民身份证登记入住</view>
</view> </view>
</view>
</view>
</view>
</view>
</view>
<view class="common-container form-container">
<view class="form-title"> <view class="common-container form-container">
<text style="font-weight: bold;font-size: 35rpx;padding-right: 28rpx;">预订信息</text> <view class="form-title">
<text>姓名需与证件一致</text> <text style="font-weight: bold;font-size: 35rpx;padding-right: 28rpx;">预订信息</text>
</view> <text>姓名需与证件一致</text>
<view class="btn-box flex-column"> </view>
<view class="line w-full" style="border-top: none;"> <view class="btn-box flex-column">
<view class="left">房间数</view> <view class="line w-full" style="border-top: none;">
<view class="input flex" style="justify-content: flex-end;"> <view class="left">房间数</view>
<view class="num-box"> <view class="input flex" style="justify-content: flex-end;">
<view :class="['ctrl',buyNum>1?'':'disabled']" @click="reduce()">-</view> <view class="num-box">
<input class="num" type="text" v-model="buyNum" :disabled='true' /> <view :class="['ctrl',order.buyNum>1?'':'disabled']" @click="reduce(order,index)">-</view>
<view :class="['ctrl']" @click="plus()">+</view> <input class="num" type="text" v-model="order.buyNum" :disabled='true' />
</view> <view :class="['ctrl']" @click="plus(order,index)">+</view>
</view> </view>
</view> </view>
<view class="line w-full" v-for="(user,index) in roomUser" :key="index"> </view>
<view class="left">房间{{index+1}}</view> <view class="line w-full" v-for="(user, idx) in roomUser[index]" :key="idx">
<input class="input" type="text" placeholder="请输入住客姓名" v-model="user.name" /> <view class="left">房间{{idx+1}}</view>
</view> <input class="input" type="text" placeholder="请输入住客姓名" v-model="user.name" />
<view class="line w-full"> </view>
<view class="left">联系电话</view> <view class="line w-full">
<view class="flex flex-items-center input"> <view class="left">联系电话</view>
<input class="input" type="text" placeholder="请输入联系手机号" v-model="phone" /> <view class="flex flex-items-center input">
<uni-icons v-if="phone.length>0" style="margin-left: 30rpx;" type="closeempty" size="14" <input class="input" type="text" placeholder="请输入联系手机号" v-model="order.phone" />
@click="phone = ''"></uni-icons> <!-- <uni-icons v-if="order.phone.length>0" style="margin-left: 30rpx;" type="closeempty" size="14"
</view> @click="order.phone = ''"></uni-icons> -->
</view>
</view>
</view> </view>
</view> </view>
</view>
<navigator :url="'/subPackages/order/orderCoupon?allprice='+ price + '&sku_ids='+ skuInfo.id" class="coupon-box flex-between"> </view>
<text>优惠券</text>
<view style="display: flex;align-items: center;"> <navigator :url="'/subPackages/order/orderCoupon?allprice='+ price + '&sku_ids='+ skuIds" class="coupon-box flex-between" v-if="!isShoppingCart">
<view class="add-btn" v-if="!coupon">选择优惠券</view> <text>优惠券</text>
<view style="display: flex;align-items: center;color: #6A8A2D;font-weight: bold;" v-if="coupon && coupon.activity"> <view style="display: flex;align-items: center;">
<view v-if="coupon.activity.discount_type == 'pricebreak'">-{{coupon.activity.money/100}}</view> <view class="add-btn" v-if="!coupon">选择优惠券</view>
<view v-else>{{coupon.activity.fold}}</view> <view style="display: flex;align-items: center;color: #6A8A2D;font-weight: bold;" v-if="coupon && coupon.activity">
</view> <view v-if="coupon.activity.discount_type == 'pricebreak'">-{{coupon.activity.money/100}}</view>
<img src="https://static.ticket.sz-trip.com/changyoutaihu/images/user/rightIcon.png" class="icon-coupon"> <view v-else>{{coupon.activity.fold}}</view>
</view> </view>
</navigator> <img src="https://static.ticket.sz-trip.com/changyoutaihu/images/user/rightIcon.png" class="icon-coupon">
</view>
</view> </navigator>
<view class="btn-list">
<view class="btn-list"> <view class="price-box">
<view class="price-box"> <view class="text">合计:</view>
<view class="text">合计:</view> <view class="price">{{ total() / 100 }}</view>
<view class="price">{{ total() / 100 }}</view> <!-- <view class="post-text" v-if="sendType==1&&post">含邮费:¥{{ post / 100 }}</view> -->
<!-- <view class="post-text" v-if="sendType==1&&post">含邮费:¥{{ post / 100 }}</view> --> </view>
</view> <view class="btn" @click="order()">立即预订</view>
<view class="btn" @click="order()">立即预订</view> </view>
</view>
<!-- 酒店详情弹窗 -->
<!-- 酒店详情弹窗 --> <uni-popup ref="popupRule" type="bottom" :safe-area="false" background-color="#F7F7F7">
<uni-popup ref="popupRule" type="bottom" :safe-area="false" background-color="#F7F7F7"> <view class="popup-content-date">
<view class="popup-content-date"> <view class="popup-content-title flex">
<view class="popup-content-title flex"> <view class="flex-1 w-1rpx text-overflow">
<view class="flex-1 w-1rpx text-overflow"> {{skuInfo[popupIndex].sku_name}}
{{skuInfo.sku_name}} </view>
</view> <img src="https://static.ticket.sz-trip.com/taizhou/images/cha.png" @click="closePopupRule"
<img src="https://static.ticket.sz-trip.com/taizhou/images/cha.png" @click="closePopupRule" style="width: 31rpx;height: 31rpx;" class="flex-shrink-0">
style="width: 31rpx;height: 31rpx;" class="flex-shrink-0"> </view>
</view> <view class="content">
<view class="content"> <view class="swipe-box" style="height: 347rpx;" v-if="skuInfo[popupIndex] && skuInfo[popupIndex].listimg && skuInfo[popupIndex].listimg.length > 0">
<view class="swipe-box" style="height: 347rpx;" v-if="skuInfo.listimg && skuInfo.listimg.length > 0"> <swiper class="swiper" :autoplay="true" :interval="3000" :duration="1000" circular
<swiper class="swiper" :autoplay="true" :interval="3000" :duration="1000" circular indicator-dots indicator-color="rgba(255,255,255,.5)" indicator-active-color="#fff"
indicator-dots indicator-color="rgba(255,255,255,.5)" indicator-active-color="#fff" @change="popSwiperChange" :current="0">
@change="popSwiperChange" :current="0"> <swiper-item v-for="(item, idx) in skuInfo[popupIndex].listimg" :key="item.id">
<swiper-item v-for="(item, index) in skuInfo.listimg" :key="item.id"> <view class="swiper-item" style="height: 347rpx;">
<view class="swiper-item" style="height: 347rpx;"> <image class="item-img pop-swiper-image" :src="showImg(item)" mode="aspectFill">
<image class="item-img pop-swiper-image" :src="showImg(item)" mode="aspectFill"> </image>
</image> </view>
</view> </swiper-item>
</swiper-item> </swiper>
</swiper>
<view class="swiper-pointer" style="right:30rpx;bottom: 20rpx;">
<view class="swiper-pointer" style="right:30rpx;bottom: 20rpx;"> {{popSwiperCurrent}}/{{skuInfo[popupIndex].listimg.length}}
{{popSwiperCurrent}}/{{skuInfo.listimg.length}} </view>
</view> </view>
</view>
<view class="pop-detail-container" v-if="skuInfo[popupIndex] && skuInfo[popupIndex].sku_model">
<view class="pop-detail-container"> <view class="pop-detail-title">房型信息</view>
<view class="pop-detail-title">房型信息</view> <view v-html="formateRichText(skuInfo[popupIndex].sku_model.detailinfo)"></view>
<view v-html="formateRichText(skuInfo.sku_model.detailinfo)"></view> </view>
</view> </view>
</view> </view>
</view> </uni-popup>
</uni-popup>
</view>
</view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
id: null, id: null,
popSwiperCurrent: 1, popSwiperCurrent: 1,
popupIndex: 0,
skuInfo: {}, //
skuInfo: [], //
selectDate: { roomUser: [],
startDay: new Date().Format('yyyy-MM-dd'), allSeldDate: [],
endDay: new Date((new Date()).getFullYear(), (new Date()).getMonth(), new Date().getDate() + 1).Format( coupon: '',
'yyyy-MM-dd'), price: 0,
differDays: 1 skuIds: [],
}, isShoppingCart: 0,
orderList: []
phone: '', }
buyNum: 1, },
roomUser: [{ onReady() {
name: '' //
}], this.$store.commit("choseCoupon", "");
allSeldDate: [], },
coupon: '', onShow() {
price: 0 this.coupon = this.$store.state.user.coupon
} console.log(this.coupon)
}, },
onReady() { onLoad(options) {
// if(options.isShoppingCart) this.isShoppingCart = options.isShoppingCart
this.$store.commit("choseCoupon", ""); this.initOrderDate()
}, },
onShow() { methods: {
this.coupon = this.$store.state.user.coupon popSwiperChange(e) {
console.log(this.coupon) this.popSwiperCurrent = e.detail.current + 1
}, },
onLoad(options) {
this.initOrderDate() //
}, initOrderDate() {
methods: { let data = [];
popSwiperChange(e) { try {
this.popSwiperCurrent = e.detail.current + 1 data = JSON.parse(uni.getStorageSync('hotelOrderInfo'));
}, console.log(data)
} catch (e) {
// data = [];
initOrderDate() { setTimeout(() => {
let data = {} uni.navigateBack()
try { }, 1000);
data = JSON.parse(uni.getStorageSync('hotelOrderInfo')); }
console.log(data)
} catch (e) { this.skuInfo = [];
data = {} this.roomUser = [];
setTimeout(() => {
uni.navigateBack() data.forEach((item) => {
}, 1000) this.skuInfo.push(item.skuInfo);
} this.skuIds.push(item.skuInfo.id);
this.skuInfo = data.skuInfo
this.selectDate = data.selectDate
this.buyNum = 1
this.roomUser = [{
name: ''
}]
try {
this.phone = JSON.parse(uni.getStorageSync('userInfo')).mobile
} catch (e) {
this.phone = ''
}
this.getPriceCal(this.skuInfo.id)
},
//
viewDetail() {
this.popSwiperCurrent = 1
this.openPopRule()
},
plus() {
this.buyNum += 1;
this.roomUser.push({
name: ''
})
},
reduce() {
if (this.buyNum > 1) {
this.buyNum -= 1;
this.roomUser.pop()
}
},
total() {
let disfferMoney = 0
this.allSeldDate.forEach(v => {
disfferMoney += (v.price || 0)
})
this.price = ((disfferMoney * this.buyNum) || 0).toFixed(2)
if(this.coupon) { const num = item.skuInfo.buyNum || 1;
if (this.coupon.activity.discount_type == 'pricebreak') { // buyNum
disfferMoney = disfferMoney - this.coupon.activity.money const users = Array(num).fill().map(() => ({ name: '' }));
} else{ this.roomUser.push(users);
disfferMoney = disfferMoney - (disfferMoney * this.coupon.activity.fold/10) try {
} item.skuInfo.phone = (JSON.parse(uni.getStorageSync('userInfo')).mobile);
} } catch (e) {
return disfferMoney < 0 ? 0 : disfferMoney item.skuInfo.phone = '';
}, }
this.getPriceCal(item.skuInfo);
order() { });
this.roomUser.forEach(v => v.name = v.name.trim()) },
// //
if (!this.IsTel(this.phone)) { viewDetail() {
uni.showToast({ this.popSwiperCurrent = 1;
title: '手机号格式校验失败', this.openPopRule();
icon: 'none' },
});
return; plus(order,index) {
} order.buyNum += 1;
if (this.roomUser.some(v => { this.roomUser[index].push({ name: '' });
return v.name.length == 0 },
})) { reduce(order,index) {
uni.showToast({ if (order.buyNum > 1) {
title: '请输入住客姓名', order.buyNum -= 1;
icon: 'none' this.roomUser[index].pop();
}); }
return; },
}
total() {
let roomNames = [] let totalMoney = 0;
this.roomUser.forEach(item => { this.skuInfo.forEach((item, index) => {
roomNames.push(item.name) let disfferMoney = 0;
}) if(item.allSeldDate && item.allSeldDate.length > 0) {
item.allSeldDate.forEach(v => {
if (roomNames.length != Array.from(new Set(roomNames)).length) { disfferMoney += (v.price || 0);
uni.showToast({
title: '住客姓名不能相同',
icon: 'none'
}); });
return;
} }
disfferMoney = ((disfferMoney * item.buyNum) || 0);
totalMoney += disfferMoney < 0 ? 0 : disfferMoney;
});
this.price = totalMoney
if (this.coupon) {
if (this.coupon.activity.discount_type == 'pricebreak') {
totalMoney = totalMoney - this.coupon.activity.money;
} else {
totalMoney = totalMoney - (totalMoney * this.coupon.activity.fold / 10);
}
}
return totalMoney;
},
order() {
this.roomUser.forEach((users, index) => {
users.forEach(v => v.name = v.name.trim());
});
//
for (let i = 0; i < this.skuInfo.length; i++) {
if (!this.IsTel(this.skuInfo[i].phone)) {
uni.showToast({
title: '手机号格式校验失败',
icon: 'none'
});
return;
}
if (this.roomUser[i].some(v => {
return v.name.length == 0;
})) {
uni.showToast({
title: '请输入住客姓名',
icon: 'none'
});
return;
}
let roomNames = [];
this.roomUser[i].forEach(item => {
roomNames.push(item.name);
});
if (roomNames.length != Array.from(new Set(roomNames)).length) {
uni.showToast({
title: '住客姓名不能相同',
icon: 'none'
});
return;
}
this.skuInfo[i].roomNames = roomNames
}
//
if (this.isShoppingCart) {
this.$store.commit("changeHotelOrderList", this.skuInfo);
uni.setStorageSync("hotelOrderList", this.skuInfo)
this.goCartNextPage(4)
return
}
let data = { let data = {
coupon_id: this.coupon ? this.coupon.id : null, coupon_id: this.coupon ? this.coupon.id : null,
product_list: [ product_list: this.skuInfo.map((order, index) => {
{ let roomNames = this.roomUser[index].map(item => item.name);
type: 'hotel', return {
customer_name: roomNames.toString(), type: 'hotel',
reserve_mobile: this.phone, customer_name: roomNames.toString(),
product_id: this.skuInfo.product_id, reserve_mobile: order.phone,
sku_id: this.skuInfo.id, product_id: order.product_id,
start_date: this.selectDate.startDay, sku_id: order.id,
end_date: this.selectDate.endDay, start_date: order.selectDate.startDay,
product_num: this.buyNum end_date: order.selectDate.endDay,
} product_num: order.buyNum
] };
} })
};
console.log('data', data);
this.Post({
method: 'POST',
data: JSON.stringify(data)
}, '/api/order/create').then(res => {
console.log('成功');
if (res.code == 1) {
uni.removeStorageSync('hotelOrderInfo');
this.Post({
order_id: res.data.order_id,
pay_platform: "miniprogram",
pay_method: 'abc'
}, '/api/order/pay').then(res => {
if (res.data) {
uni.requestPayment({
nonceStr: res.data.nonceStr,
package: res.data.package,
paySign: res.data.paySign,
signType: res.data.signType,
timeStamp: res.data.timeStamp,
complete() {
uni.navigateTo({
url: '/subPackages/order/trades'
});
}
});
}
});
}
});
},
closePopupRule() {
this.$refs.popupRule.close();
},
openPopRule(index) {
this.popupIndex = index;
this.$refs.popupRule.open();
},
getPriceCal(sku) {
this.Post({
sku_id: sku.id,
start_date: sku.selectDate.startDay,
end_date: sku.selectDate.endDay,
}, '/api/product/product_date_price').then(res => {
let seldDate = res.data || [];
if (seldDate.length > 1) {
seldDate.pop();
}
sku.allSeldDate = seldDate;
console.log('data',data) this.total()
});
this.Post({ },
method: 'POST', }
data: JSON.stringify(data) }
}, '/api/order/create').then(res => {
console.log('成功');
if (res.code == 1) {
uni.removeStorageSync('hotelOrderInfo')
this.Post({
order_id: res.data.order_id,
pay_platform: "miniprogram",
pay_method: 'abc'
}, '/api/order/pay').then(res => {
if (res.data) {
uni.requestPayment({
nonceStr: res.data.nonceStr,
package: res.data.package,
paySign: res.data.paySign,
signType: res.data.signType,
timeStamp: res.data.timeStamp,
complete() {
uni.navigateTo({
url: '/subPackages/order/trades'
})
}
})
}
})
}
})
},
closePopupRule() {
this.$refs.popupRule.close()
},
openPopRule() {
this.$refs.popupRule.open()
},
getPriceCal(skuId, goodId) {
this.Post({
sku_id: skuId,
start_date: this.selectDate.startDay,
end_date: this.selectDate.endDay,
}, '/api/product/product_date_price').then(res => {
this.allSeldDate = res.data || []
if (this.allSeldDate.length > 0) {
this.allSeldDate.pop()
}
})
},
}
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@ -379,6 +392,7 @@
.bg { .bg {
min-height: 100vh; min-height: 100vh;
background: #F8F8F8; background: #F8F8F8;
padding-bottom: 200rpx;
} }
.swipe-box { .swipe-box {
@ -453,7 +467,6 @@
.detail-container { .detail-container {
width: 100%; width: 100%;
padding: 26rpx; padding: 26rpx;
padding-bottom: 200rpx;
} }
.common-container { .common-container {
@ -711,6 +724,7 @@
font-size: 31rpx; font-size: 31rpx;
color: #000000; color: #000000;
padding: 0 20rpx; padding: 0 20rpx;
margin: 20rpx 26rpx;
.add-btn { .add-btn {
width: 153rpx; width: 153rpx;

Loading…
Cancel
Save