Feat:订单退款,礼品下单

This commit is contained in:
linxi
2025-10-21 17:51:40 +08:00
parent 64db7b8cd4
commit bf4861f088
7 changed files with 328 additions and 131 deletions
+2 -4
View File
@@ -7,7 +7,6 @@
:maxRange="999"
:defaultDate="defaultDate"
:minDate="minDate"
:disabledDate="disabledDates"
color="#C52733"
@confirm="handleDateChange"
@close="hideCalendar"
@@ -111,10 +110,9 @@ export default {
startDate: e[0],
endDate: e[e.length - 1]
}
// 如果选择的天数小于minDay,提示用户选择至少minDay天
if (e.length < this.minDay) {
if (e.length !== this.minDay) {
uni.showToast({
title: `请选择至少${this.minDay}天`,
title: `团购天数必须为${this.minDay}天`,
icon: 'none'
})
this.resetSelection()
+26 -45
View File
@@ -155,50 +155,7 @@ export default {
giftBg: '',
id: '',
activePeriod: 0,
detail: {
title: '【正牌爆售】30天29晚臻享特色小院/庵食套餐',
price: 3888,
images: [
'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/hotel-1.jpg',
'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/hotel-2.jpg',
'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/hotel-3.jpg'
],
periods: [
{ batch: 1, range: '6/13-6/15' },
{ batch: 2, range: '6/16-6/18' },
{ batch: 3, range: '6/19-6/21' },
{ batch: 4, range: '6/22-6/24' }
],
combos: [
{ img: 'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/room-1.jpg', text: '温泉泡汤·双人早餐' },
{ img: 'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/room-2.jpg', text: '茶室体验·手作禅食' },
{ img: 'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/room-3.jpg', text: '山景露台·下午茶' },
{ img: 'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/room-4.jpg', text: '夜间电影·星空灯' },
{ img: 'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/room-5.jpg', text: '精品床品·加湿香氛' },
{ img: 'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/room-6.jpg', text: '小院烧烤·庭院篝火' }
],
highlights: [
'小院临海风光,步行可达观景台',
'馆内私厨,提供本地特色庵食',
'房间带露台,景观视野绝佳',
'每期限定名额,错峰享受更安静'
],
rules: [
'需至少提前3日预订,节假日价格略有浮动',
'不可与其他优惠同享;支持改期一次',
'如遇不可抗因素,支持无损退款',
'入住需持有效身份证件,遵守园区规定'
],
fees: [
{ name: '下单即赠惊喜', value: '免费' },
{ name: '入住加床', value: 'x' },
{ name: '儿童入园', value: 'x' }
],
gallery: [
'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/courtyard-1.jpg',
'https://cdn.jsdelivr.net/gh/trae-ai/assets-placeholder/courtyard-2.jpg'
]
},
detail: {},
calendar: [],
currentWeek: [],
rules: "",
@@ -223,6 +180,12 @@ export default {
})
},
methods: {
toGift(){
uni.navigateTo({
// + '&couponId=' + coupId
url: '/pkg_user/views/gift/gift?cartId=' + this.id + '&isGroupBuy=1'
})
},
handleDateSelected(dateRange) {
console.log(dateRange, 'dateRange');
@@ -300,7 +263,25 @@ export default {
},
contactService() {
uni.showToast({ title: '已为您接入管家', icon: 'none' })
uni.showModal({
title: '商家电话',
content: this.detail.phone || '暂无电话',
confirmText: '立即拨打',
cancelText: '取消',
success: (res) => {
if (res.confirm && this.detail.phone) {
uni.makePhoneCall({
phoneNumber: this.detail.phone,
fail: () => {
uni.showToast({
title: '拨打电话失败',
icon: 'none'
})
}
})
}
}
})
},
bookNow() {
uni.navigateTo({ url: '/pkg_product/views/submitOrder?id=' + this.id + '&orderStartDate=' + this.rangeDate.startDate + '&orderEndDate=' + this.rangeDate.endDate })
+157 -18
View File
@@ -2,7 +2,7 @@
<view class="order-details v12-px-3 v12-pt-3">
<!-- 订单状态 -->
<view class="status-section">
<view class="v12-font-32 v12-primary-text">{{orderInfo._status._title}}</view>
<view class="v12-font-28 v12-font-bold v12-primary-text">{{orderInfo._status._title}}</view>
<view class="v12-font-24 v12-mt-3" style="color: #666;" v-if="orderInfo._status && ['1','2'].includes(orderInfo._status._type)">
您已下单成功,请联系商家确认具体的入住时间
</view>
@@ -27,8 +27,8 @@
<view class="v12-font-32 v12-font-bold more_t">{{orderInfo.travelGroupOrderInfo.travelGroupProduct.name}}</view>
<view class="product-price">
<text style="font-size: 28rpx; color: #A1A1A1;">实付:</text>
<text class="v12-primary-text">
<text class="v12-font-28 v12-primary-text">¥</text>
<text class="v12-primary-text v12-font-bold">
<text class="v12-font-26 v12-primary-text">¥</text>
<text class="v12-font-36 v12-primary-text">{{orderInfo.payPrice}}</text>
</text>
</view>
@@ -40,11 +40,34 @@
<view class="verify-title v12-font-28 v12-primary-text">核销码:{{orderInfo.verifyCode}}</view>
<image class="qr-code" :src="orderInfo.verifyQrCode" mode="aspectFit"></image>
<view class="contact-buttons">
<button class="contact-btn merchant-phone" @click="contactMerchant('phone')">商家电话</button>
<button class="contact-btn merchant-wechat" @click="contactMerchant('wechat')">商家微信</button>
<button class="contact-btn merchant-phone" @click="showPhoneDialog('phone')">商家电话</button>
<button class="contact-btn merchant-wechat" @click="showPhoneDialog('wechat')">商家微信</button>
</view>
</view>
<!-- 商家电话弹窗 -->
<u-popup :show="showPhonePopup" mode="center" round="10" :safe-area-inset-bottom="false">
<view class="phone-popup">
<view class="phone-title">{{ title }}</view>
<view class="phone-number">{{ popContent || '暂无'}}</view>
<view class="phone-actions v12-align-center" v-if="title === '商家电话'">
<!-- <button class="action-btn cancel" @click="showPhonePopup = false">取消</button>
<button class="action-btn call" @click="makePhoneCall">立即拨打</button> -->
<view class="v12-font-28 v12-primary-text" @click="contactMerchant('phone')">立即拨打</view> | <view class="v12-font-28" @click="showPhonePopup = false">取消</view>
</view>
<view class="phone-actions v12-align-center" v-if="title === '商家微信'">
<!-- <button class="action-btn cancel" @click="showPhonePopup = false">取消</button>
<button class="action-btn call" @click="makePhoneCall">立即拨打</button> -->
<view class="v12-font-28 v12-primary-text" @click="contactMerchant('wechat')">立即复制</view> | <view class="v12-font-28" @click="showPhonePopup = false">取消</view>
</view>
<view class="phone-actions v12-align-center" v-if="title === '平台电话'" >
<!-- <button class="action-btn cancel" @click="showPhonePopup = false">取消</button>
<button class="action-btn call" @click="makePhoneCall">立即拨打</button> -->
<view v-if="title === '平台电话'" class="v12-font-28 v12-primary-text" @click="contactMerchant('phone')">立即拨打</view> | <view class="v12-font-28" @click="showPhonePopup = false">取消</view>
</view>
</view>
</u-popup>
<!-- 联系人信息 -->
<view class="contact-section">
<view class="section-title v12-font-28 v12-font-bold">联系人信息</view>
@@ -90,13 +113,20 @@
<!-- 底部按钮 -->
<view class="bottom-buttons">
<button class="btn customer-service" @click="contactCustomerService">平台客服</button>
<view class="v12-align-center">
<button class="btn customer-service" @click="showPhoneDialog('phone')">平台客服</button>
<view class="v12-align-center" v-if="orderInfo._status && ['1','2'].includes(orderInfo._status._type)">
<button class="btn v12-primary-border v12-primary-text modify-time" @click="modifyStayTime">修改入住时间</button>
<button class="btn v12-primary-border v12-primary-text refund" @click="applyRefund">申请退款</button>
</view>
<view class="v12-align-center" v-if="orderInfo._status && ['1','2'].includes(orderInfo._status._type)">
<button class="btn v12-dark-border v12-dark-text modify-time" @click="showPhoneDialog('phone')">联系商家</button>
</view>
</view>
<Calendar ref="calendar" @dateSelected="handleDateSelected"></Calendar>
<Calendar
ref="calendar"
:minDay="orderInfo.minBookingDays"
@dateSelected="handleDateSelected">
</Calendar>
</view>
</template>
@@ -110,10 +140,14 @@ export default {
data() {
return {
key: '',
popContent: '',
title: '',
orderInfo: {
travelGroupOrderInfo: {},
_status: {}
}
_status: {},
merchantPhone: '' // 添加商家电话字段
},
showPhonePopup: false // 控制电话弹窗显示
}
},
onLoad(otps) {
@@ -121,11 +155,17 @@ export default {
this.getSojoumOrderDetail();
},
methods: {
getDaysCount() {
// 根据开始日期和结束日期计算天数
const startDate = new Date(this.orderInfo.travelGroupOrderInfo.orderStartDate);
const endDate = new Date(this.orderInfo.travelGroupOrderInfo.orderEndDate);
const timeDiff = endDate - startDate;
const daysCount = Math.ceil(timeDiff / (1000 * 60 * 60 * 24));
return daysCount + 1;
},
handleDateSelected(dateRange) {
console.log('selectedRange', dateRange);
const params = {
orderId: this.orderInfo.travelGroupOrderInfo.travelGroupProduct.id,
orderId: this.key,
orderStartDate: dateRange.startDate,
orderEndDate: dateRange.endDate
}
@@ -139,6 +179,7 @@ export default {
title: '入住时间修改成功',
icon: 'success'
})
this.getSojoumOrderDetail();
}
}).finally(() => {
uni.hideLoading();
@@ -169,6 +210,7 @@ export default {
const res = await fetchSojoumOrderDetail(params);
if (res.status === 200) {
this.orderInfo = res.data;
this.orderInfo.minBookingDays = this.getDaysCount();
uni.hideLoading();
}
},
@@ -202,6 +244,8 @@ export default {
uni.makePhoneCall({
phoneNumber: this.orderInfo.merPhone,
success: () => {
console.log('///');
uni.showToast({
title: '正在拨打电话',
icon: 'none'
@@ -218,6 +262,7 @@ export default {
uni.setClipboardData({
data: this.orderInfo.merWechat,
success: () => {
console.log('//微信号已复制/');
uni.showToast({
title: '微信号已复制',
icon: 'success'
@@ -228,10 +273,21 @@ export default {
},
contactCustomerService() {
// 这里可以添加跳转到客服页面或打开客服会话的逻辑
uni.showToast({
title: '正在连接客服...',
icon: 'none'
})
uni.makePhoneCall({
phoneNumber: this.orderInfo.merPhone,
success: () => {
uni.showToast({
title: '正在拨打电话',
icon: 'none'
})
},
fail: () => {
uni.showToast({
title: '拨打失败',
icon: 'none'
})
}
})
},
modifyStayTime() {
// 这里可以添加修改入住时间的逻辑,比如打开日期选择器
@@ -242,7 +298,42 @@ export default {
uni.navigateTo({
url: '/pkg_product/views/sojoumOrderRefund?id=' + this.key
})
}
},
// 显示电话弹窗
showPhoneDialog(type) {
if (!this.orderInfo.merPhone) {
uni.showToast({
title: '暂无商家电话',
icon: 'none'
});
return;
}
if (type === 'phone') {
this.title = '商家电话';
this.popContent = this.orderInfo.merPhone;
} else if (type === 'wechat') {
this.title = '商家微信';
this.popContent = this.orderInfo.merWechat;
}
this.showPhonePopup = true;
},
// 拨打电话
makePhoneCall() {
if (!this.orderInfo.merchantPhone) return;
uni.makePhoneCall({
phoneNumber: this.orderInfo.merchantPhone,
success: () => {
this.showPhonePopup = false;
},
fail: () => {
uni.showToast({
title: '拨号失败',
icon: 'none'
});
}
});
},
}
}
</script>
@@ -325,6 +416,8 @@ export default {
padding: 0 40rpx;
border-radius: 40rpx;
font-size: 28rpx;
height: 60rpx;
line-height: 60rpx;
&.merchant-phone {
background-color: #fff;
border: 2rpx solid #333;
@@ -405,4 +498,50 @@ export default {
}
}
}
.phone-popup {
width: 400rpx;
background-color: #fff;
border-radius: 20rpx;
padding: 40rpx;
.phone-title {
font-size: 32rpx;
color: #333;
text-align: center;
margin-bottom: 30rpx;
font-weight: bold;
}
.phone-number {
font-size: 32rpx;
color: #333;
text-align: center;
margin-bottom: 40rpx;
}
.phone-actions {
display: flex;
justify-content: space-around;
gap: 20rpx;
.action-btn {
flex: 1;
height: 80rpx;
line-height: 80rpx;
text-align: center;
border-radius: 40rpx;
font-size: 28rpx;
&.cancel {
background-color: #f5f5f5;
color: #666;
}
&.call {
background-color: var(--v12-color-primary);
color: #fff;
}
}
}
}
</style>
+43 -11
View File
@@ -55,12 +55,13 @@
</template>
<script>
import { sojoumOrderRefundInfo, sojoumOrderRefund } from '@/api/sojoumOrder.js'
export default {
data() {
return {
refundAmount: 3500.0,
orderAmount: 3888,
deductionAmount: 388.8,
refundAmount: '',
orderAmount: '',
deductionAmount: '',
refundReasons: [
'行程变更',
'定错时间/地址',
@@ -70,24 +71,55 @@ export default {
'其他'
],
selectedReason: '',
otherReason: ''
otherReason: '',
key: ''
}
},
onLoad(opts) {
this.key = opts.id
this.getRefundInfo(opts.id)
},
methods: {
getRefundInfo(id) {
sojoumOrderRefundInfo({
orderId: id
}).then(res => {
if (res.status === 200) {
this.refundAmount = res.data.refundPrice
this.orderAmount = res.data.payPrice
this.deductionAmount = res.data.penalty
}
})
},
selectReason(reason) {
this.selectedReason = reason
},
submitRefund() {
// TODO: 实现退款提交逻辑
// orderId string 订单号
// refundReasonWap string 选择的退款原因
// refundReasonWapExplain string 退款原因说明(其他个人原因)
const refundData = {
amount: this.refundAmount,
reason: this.selectedReason,
otherReason: this.otherReason
orderId: this.key,
refundReasonWap: this.selectedReason,
refundReasonWapExplain: this.otherReason
}
console.log('提交退款申请:', refundData)
uni.showToast({
title: '退款申请已提交',
icon: 'success'
uni.showLoading({
title: '加载中...',
mask: true,
})
sojoumOrderRefund(refundData).then(res => {
if (res.status === 200) {
uni.showToast({
title: '退款申请已提交',
icon: 'success'
})
uni.navigateBack({
url: '/pkg_product/views/sojoumOrderDetails?id=' + this.key
})
}
}).finally(() => {
uni.hideLoading();
})
}
}