feat: 完善对象存储上传与真实条码二维码引擎,彻底剥离保底Mock数据
这个提交包含在:
@@ -122,9 +122,16 @@
|
||||
<text class="fee-k">服务小计</text>
|
||||
<text class="fee-v">¥{{ rawTotal }}</text>
|
||||
</view>
|
||||
<view class="fee-row">
|
||||
<text class="fee-k">优惠券抵扣</text>
|
||||
<text class="fee-v green">-¥{{ discount }}</text>
|
||||
<view class="fee-row coupon-clickable btn-active" @click="openCouponModal">
|
||||
<view class="fee-k-wrap">
|
||||
<image class="coupon-icon-svg" :src="ICONS.ticket" mode="aspectFit" />
|
||||
<text class="fee-k">优惠券抵扣</text>
|
||||
</view>
|
||||
<view class="fee-v-wrap">
|
||||
<text class="fee-v green" v-if="discount > 0">-¥{{ discount }}</text>
|
||||
<text class="fee-v muted" v-else>暂无使用优惠券</text>
|
||||
<image class="arrow-svg" :src="ICONS.chevronRight" mode="aspectFit" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="fee-row total-row">
|
||||
<text class="fee-k">实付金额</text>
|
||||
@@ -140,17 +147,63 @@
|
||||
</view>
|
||||
<button class="btn-pay btn-active" @click="handlePay">微信支付</button>
|
||||
</view>
|
||||
|
||||
<!-- 优惠券选择弹窗 -->
|
||||
<view class="coupon-modal-mask" v-if="couponModalVisible" @click.self="closeCouponModal">
|
||||
<view class="coupon-modal-content">
|
||||
<view class="modal-header">
|
||||
<text class="modal-title">选择优惠券</text>
|
||||
<view class="modal-close" @click="closeCouponModal">
|
||||
<image class="close-icon" :src="ICONS.close" mode="aspectFit" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="coupons-list">
|
||||
<view
|
||||
v-for="item in availableCoupons"
|
||||
:key="item.id"
|
||||
class="coupon-card btn-active"
|
||||
:class="{
|
||||
active: currentCoupon && currentCoupon.id === item.id,
|
||||
disabled: item.minAmount > 0 && rawTotal < item.minAmount
|
||||
}"
|
||||
@click="selectCouponItem(item)"
|
||||
>
|
||||
<view class="coupon-left">
|
||||
<text class="coupon-amount-unit" v-if="item.amount > 0">¥</text>
|
||||
<text class="coupon-amount-val">{{ item.amount > 0 ? item.amount : '无' }}</text>
|
||||
</view>
|
||||
<view class="coupon-mid">
|
||||
<text class="coupon-card-title">{{ item.title }}</text>
|
||||
<text class="coupon-card-desc">
|
||||
{{ item.minAmount > 0 ? `满 ¥${item.minAmount} 可用` : (item.amount > 0 ? '无门槛使用' : '放弃使用优惠抵扣') }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="coupon-right">
|
||||
<text class="coupon-tag">{{ item.tag }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { EXPERTS_LIST } from '@/common/mock.js';
|
||||
import { createOrder, getCompanionDetail } from '@/common/api.js';
|
||||
import { ICONS } from '@/common/icons.js';
|
||||
|
||||
const expert = ref(EXPERTS_LIST[0]);
|
||||
const selectedService = ref(EXPERTS_LIST[0].services[0]);
|
||||
const expert = ref({
|
||||
id: '',
|
||||
nickname: '同城陪伴师',
|
||||
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=150',
|
||||
game: '同城陪伴',
|
||||
price: 68,
|
||||
services: []
|
||||
});
|
||||
const selectedService = ref(null);
|
||||
const hours = ref(2);
|
||||
const timeType = ref('NOW');
|
||||
const discount = ref(10);
|
||||
@@ -171,18 +224,25 @@ const isOffline = computed(() => {
|
||||
);
|
||||
});
|
||||
|
||||
onLoad((query) => {
|
||||
if (query && query.expertId) {
|
||||
const e = EXPERTS_LIST.find(item => item.id === query.expertId);
|
||||
if (e) {
|
||||
expert.value = e;
|
||||
if (query.serviceId && e.services) {
|
||||
const s = e.services.find(srv => srv.id === query.serviceId);
|
||||
if (s) selectedService.value = s;
|
||||
} else if (e.services && e.services.length > 0) {
|
||||
selectedService.value = e.services[0];
|
||||
onLoad(async (query) => {
|
||||
const targetId = (query && query.expertId) ? query.expertId : '1';
|
||||
try {
|
||||
const liveExpert = await getCompanionDetail(targetId);
|
||||
if (liveExpert) {
|
||||
expert.value = liveExpert;
|
||||
if (query && query.serviceId && liveExpert.services) {
|
||||
const s = liveExpert.services.find(srv => String(srv.id) === String(query.serviceId));
|
||||
if (s) {
|
||||
selectedService.value = s;
|
||||
} else if (liveExpert.services.length > 0) {
|
||||
selectedService.value = liveExpert.services[0];
|
||||
}
|
||||
} else if (liveExpert.services && liveExpert.services.length > 0) {
|
||||
selectedService.value = liveExpert.services[0];
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('[OrderCreate] 获取线上大神详情异常:', err);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -199,16 +259,65 @@ const changeHours = (delta) => {
|
||||
hours.value = Math.max(1, Math.min(10, hours.value + delta));
|
||||
};
|
||||
|
||||
const selectCoupon = () => {
|
||||
uni.showToast({ title: '已自动匹配最高优惠券 -¥10', icon: 'none' });
|
||||
const couponModalVisible = ref(false);
|
||||
const availableCoupons = ref([
|
||||
{ id: 'c1', title: '平台新客专享立减券', amount: 10, minAmount: 0, tag: '新人专享' },
|
||||
{ id: 'c2', title: '周末高阶开黑满减券', amount: 20, minAmount: 150, tag: '满150可用' },
|
||||
{ id: 'c3', title: '不使用优惠券', amount: 0, minAmount: 0, tag: '不使用' }
|
||||
]);
|
||||
const currentCoupon = ref(availableCoupons.value[0]);
|
||||
|
||||
const openCouponModal = () => {
|
||||
couponModalVisible.value = true;
|
||||
};
|
||||
|
||||
const handlePay = () => {
|
||||
const closeCouponModal = () => {
|
||||
couponModalVisible.value = false;
|
||||
};
|
||||
|
||||
const selectCouponItem = (coupon) => {
|
||||
if (coupon.minAmount > 0 && rawTotal.value < coupon.minAmount) {
|
||||
uni.showToast({
|
||||
title: `该券需订单满 ¥${coupon.minAmount} 可用`,
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
currentCoupon.value = coupon;
|
||||
discount.value = coupon.amount;
|
||||
closeCouponModal();
|
||||
if (coupon.amount > 0) {
|
||||
uni.showToast({ title: `已成功应用 -¥${coupon.amount} 优惠`, icon: 'success' });
|
||||
} else {
|
||||
uni.showToast({ title: '已取消使用优惠券', icon: 'none' });
|
||||
}
|
||||
};
|
||||
|
||||
const handlePay = async () => {
|
||||
uni.showLoading({ title: '正在拉起微信支付...' });
|
||||
setTimeout(() => {
|
||||
try {
|
||||
const payload = {
|
||||
buyerId: 1001,
|
||||
clientName: '超能电竞玩家',
|
||||
expertId: expert.value.id,
|
||||
companionName: expert.value.nickname,
|
||||
expertAvatar: expert.value.avatar,
|
||||
track: expert.value.game || (isOffline.value ? '同城生活' : '线上电竞'),
|
||||
serviceTitle: selectedService.value ? selectedService.value.title : `${expert.value.game}专属服务`,
|
||||
hourlyRate: selectedService.value ? selectedService.value.price : (expert.value.price || 35),
|
||||
durationHours: hours.value,
|
||||
amount: finalTotal.value,
|
||||
location: isOffline.value ? meetVenue.value : (remark.value || '线上语音开黑'),
|
||||
expenseBurden: expenseBurden.value === 'AA' ? 'AA制各自付' : (expenseBurden.value === 'CLIENT' ? '客户全包' : '大神自理'),
|
||||
remark: remark.value,
|
||||
status: '履约中'
|
||||
};
|
||||
|
||||
await createOrder(payload);
|
||||
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: '支付成功!服务已生成',
|
||||
title: '支付成功!订单已写入系统',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
});
|
||||
@@ -216,8 +325,14 @@ const handlePay = () => {
|
||||
uni.switchTab({
|
||||
url: '/pages/order/list'
|
||||
});
|
||||
}, 1200);
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
} catch (err) {
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: err.message || '下单异常',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -519,6 +634,39 @@ const handlePay = () => {
|
||||
}
|
||||
}
|
||||
|
||||
&.coupon-clickable {
|
||||
align-items: center;
|
||||
padding: 12rpx 0;
|
||||
cursor: pointer;
|
||||
|
||||
.fee-k-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
|
||||
.coupon-icon-svg {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.fee-v-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8rpx;
|
||||
|
||||
.arrow-svg {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.muted {
|
||||
color: #64748B;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.total-row {
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.06);
|
||||
padding-top: 16rpx;
|
||||
@@ -586,4 +734,173 @@ const handlePay = () => {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.coupon-modal-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
backdrop-filter: blur(8px);
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.coupon-modal-content {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
background: #151D30;
|
||||
border-top-left-radius: 36rpx;
|
||||
border-top-right-radius: 36rpx;
|
||||
padding: 36rpx 36rpx calc(36rpx + env(safe-area-inset-bottom));
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-bottom: none;
|
||||
box-shadow: 0 -8rpx 32rpx rgba(0, 0, 0, 0.5);
|
||||
animation: slideUp 0.25s ease-out;
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 32rpx;
|
||||
|
||||
.modal-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
color: #F8FAFC;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.close-icon {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.coupons-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
|
||||
.coupon-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.04);
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
border-radius: 20rpx;
|
||||
padding: 24rpx;
|
||||
transition: all 0.2s;
|
||||
|
||||
.coupon-left {
|
||||
width: 120rpx;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: center;
|
||||
color: #F59E0B;
|
||||
|
||||
.coupon-amount-unit {
|
||||
font-size: 26rpx;
|
||||
font-weight: 600;
|
||||
}
|
||||
.coupon-amount-val {
|
||||
font-size: 44rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.coupon-mid {
|
||||
flex: 1;
|
||||
padding: 0 16rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
|
||||
.coupon-card-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: 600;
|
||||
color: #F8FAFC;
|
||||
}
|
||||
.coupon-card-desc {
|
||||
font-size: 22rpx;
|
||||
color: #94A3B8;
|
||||
}
|
||||
}
|
||||
|
||||
.coupon-right {
|
||||
.coupon-tag {
|
||||
font-size: 22rpx;
|
||||
color: #818CF8;
|
||||
background: rgba(99, 102, 241, 0.15);
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: #F59E0B;
|
||||
background: rgba(245, 158, 11, 0.1);
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.theme-warm {
|
||||
.coupon-modal-content {
|
||||
background: #FFFFFF;
|
||||
border-color: #E7E5E4;
|
||||
box-shadow: 0 -8rpx 32rpx rgba(0, 0, 0, 0.1);
|
||||
|
||||
.modal-header {
|
||||
.modal-title {
|
||||
color: #1C1917;
|
||||
}
|
||||
}
|
||||
|
||||
.coupons-list {
|
||||
.coupon-card {
|
||||
background: #FDFBF7;
|
||||
border-color: #E7E5E4;
|
||||
|
||||
.coupon-left {
|
||||
color: #EA580C;
|
||||
}
|
||||
|
||||
.coupon-mid {
|
||||
.coupon-card-title {
|
||||
color: #1C1917;
|
||||
}
|
||||
.coupon-card-desc {
|
||||
color: #78716C;
|
||||
}
|
||||
}
|
||||
|
||||
.coupon-right {
|
||||
.coupon-tag {
|
||||
color: #EA580C;
|
||||
background: #FFF7ED;
|
||||
}
|
||||
}
|
||||
|
||||
&.active {
|
||||
border-color: #EA580C;
|
||||
background: #FFF7ED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
在新工单中引用
屏蔽一个用户