price:'$50 per day - Professional local guide with deep knowledge of the area, available in multiple languages including English, Mandarin, and Japanese',
quantity:0
},
{
name:'Transportation',
price:'$30 per person - Comfortable air-conditioned vehicle transfer between cities, including hotel pickup and drop-off service',
quantity:0
},
{
name:'Meals included',
price:'$25 per meal - Authentic local cuisine experience, including breakfast, lunch, and dinner options with vegetarian alternatives available',
quantity:0
}
])
// Reset discount code result set
constresetDiscountCode=()=>{
discountCode.value=''
showCoupons.value=false
selectedCoupon.value=null
}
// Update addons based on selected date
constupdateAddonsByDate=()=>{
switch(selectedDate.value){
case'anytime':
addons.value=[
{
name:'Guide service',
price:'$50 per day - Professional local guide with deep knowledge of the area, available in multiple languages including English, Mandarin, and Japanese',
quantity:1// First addon default quantity is 1
},
{
name:'Transportation',
price:'$30 per person - Comfortable air-conditioned vehicle transfer between cities, including hotel pickup and drop-off service',
quantity:0// Other addons default quantity is 0
},
{
name:'Meals included',
price:'$25 per meal - Authentic local cuisine experience, including breakfast, lunch, and dinner options with vegetarian alternatives available',
quantity:0// Other addons default quantity is 0
}
]
break
case'jan31':
addons.value=[
{
name:'Guide service',
price:'$60 per day - Special Chinese New Year guide service with cultural insights, available in English and Mandarin',
quantity:1// First addon default quantity is 1
},
{
name:'Transportation',
price:'$35 per person - Luxury minivan transfer with complimentary snacks and drinks for the January 31st tour',
quantity:0// Other addons default quantity is 0
},
{
name:'Meals included',
price:'$30 per meal - Traditional Chinese New Year feast menu with special dishes and festive decorations',
quantity:0// Other addons default quantity is 0
},
{
name:'Fireworks viewing',
price:'$20 per person - Exclusive access to fireworks viewing area for the January 31st celebration',
quantity:0// Other addons default quantity is 0
}
]
break
case'feb20':
addons.value=[
{
name:'Guide service',
price:'$55 per day - Spring Festival guide service with temple visit arrangements, available in English, Mandarin, and Japanese',
quantity:1// First addon default quantity is 1
},
{
name:'Transportation',
price:'$28 per person - Group bus transfer with festival decorations and cultural activities on board',
quantity:0// Other addons default quantity is 0
},
{
name:'Meals included',
price:'$28 per meal - Spring Festival family-style meal with traditional dishes and tea ceremony',
quantity:0// Other addons default quantity is 0
},
{
name:'Temple entrance',
price:'$15 per person - Included entrance fees to famous temples for the February 20th tour',
quantity:0// Other addons default quantity is 0
}
]
break
default:
break
}
// Reset discount code result set when date changes
resetDiscountCode()
// Update total price after resetting addons quantities
updateTotalPrice()
}
// Price related state - initial values
constoriginalPrice=ref(0)// Original price before discount
constdiscountAmount=ref(0)// Discount amount
consttotalPrice=ref(0)// Final price after discount
// Update total price based on addon quantities and discount
constupdateTotalPrice=()=>{
// Calculate original price from addons
letaddonsTotal=0
addons.value.forEach(addon=>{
constprice=extractPrice(addon.price)
addonsTotal+=price*addon.quantity
})
originalPrice.value=addonsTotal
// Calculate discount amount
constdiscount=calculateDiscount(addonsTotal)
discountAmount.value=discount
// Calculate final price (ensure it's not negative)
totalPrice.value=Math.max(0,addonsTotal-discount)
}
// Watch selectedDate changes and update addons
watch(selectedDate,()=>{
updateAddonsByDate()
})
// Initialize when component mounts - set default addons and calculate price
updateAddonsByDate()
// 优惠券数据
constcoupons=ref([
{
...
...
@@ -175,29 +367,32 @@ const coupons = ref([
}
])
// Add-ons data
constaddons=ref([
{
name:'Guide service',
price:'$50 per day - Professional local guide with deep knowledge of the area, available in multiple languages including English, Mandarin, and Japanese',
quantity:0
},
{
name:'Transportation',
price:'$30 per person - Comfortable air-conditioned vehicle transfer between cities, including hotel pickup and drop-off service',
quantity:0
},
{
name:'Meals included',
price:'$25 per meal - Authentic local cuisine experience, including breakfast, lunch, and dinner options with vegetarian alternatives available',
quantity:0
}
])
// Update addon quantity
// Update addon quantity - ensure at least one item has quantity >= 1