Feat:体验项目订单流程对接

This commit is contained in:
linxi
2026-03-17 19:29:13 +08:00
parent 7091d7e124
commit e608382075
6 changed files with 1172 additions and 210 deletions
@@ -0,0 +1,558 @@
<template>
<view class="coupon-order-detail">
<view class="status-banner" :class="{ 'completed': isCompleted || isExpired }">
<view v-if="isCompleted">
<view class="status-text dark-text">已完成</view>
<view class="status-subtext">期待再次光临</view>
</view>
<view v-else-if="isExpired">
<view class="status-text dark-text">已过期</view>
<view class="status-subtext">很遗憾,你的体验券已过期</view>
</view>
<text v-else class="status-text">{{ statusText }}</text>
</view>
<view class="qrcode-card" v-if="!isCompleted && !isExpired">
<view class="merchant-header" v-if="orderInfo.merchantName">
<image :src="webUrl + '/orderIcon/shop.png'" class="shop-icon" />
<text class="merchant-name">{{ orderInfo.merchantName }}</text>
<image :src="webUrl + '/orderIcon/arrow.png'" class="arrow-icon" />
</view>
<view class="project-name v12-font-34">
{{ orderInfo.merchantName || '' }}
</view>
<view class="qrcode-wrap" v-if="orderInfo.code">
<image :src="orderInfo.code" class="qrcode-image" mode="aspectFit" />
</view>
<view class="verify-code">
<text class="label">核销码:</text>
<text class="value">{{ orderInfo.verifyCode || '-' }}</text>
<image :src="webUrl + '/orderIcon/copy.png'" class="copy-icon" @click="copyVerifyCode" v-if="orderInfo.verifyCode" />
</view>
<view v-if="orderInfo.startTime && orderInfo.endTime" class="valid-time">
有效期至{{ orderInfo.startTime }}至{{ orderInfo.endTime }}
</view>
</view>
<view class="merchant-card">
<image :src="orderInfo.merchantAvatar || webUrl + '/experienceCoupon/store-placeholder.png'" class="merchant-avatar" mode="aspectFill" />
<view class="merchant-info">
<view class="merchant-name-large">{{ orderInfo.experienceItemInfo && orderInfo.experienceItemInfo.themeName ? orderInfo.experienceItemInfo.themeName : '' }}</view>
<view class="merchant-time one-t" v-if="formattedBusinessTime">营业时间:{{ formattedBusinessTime }}</view>
<view class="merchant-location-wrap">
<image :src="webUrl + '/orderIcon/map.png'" class="location-icon" />
<text class="distance-text" v-if="distanceText">距该地{{ distanceText }}km</text>
<text class="address-text one-t">{{ orderInfo.address }}</text>
</view>
</view>
<view class="merchant-actions">
<image :src="webUrl + '/orderIcon/nav.png'" class="action-icon" @click="openLocation" />
<image :src="webUrl + '/orderIcon/phone.png'" class="action-icon" @click="callMerchant" v-if="orderInfo.merchantPhone" />
</view>
</view>
<view class="detail-section">
<view class="section-title">订单详情</view>
<view class="info-row" v-if="isCompleted || isExpired">
<text class="label">名 称:</text>
<text class="value">{{ orderInfo.experienceItemInfo && orderInfo.experienceItemInfo.themeName ? orderInfo.experienceItemInfo.themeName : '' }}</text>
</view>
<view class="info-row">
<text class="label">订单号:</text>
<text class="value">{{ orderInfo.orderId || '' }}</text>
</view>
<view class="info-row">
<text class="label">订单类型:</text>
<text class="value">{{ orderInfo.orderTypeDesc || '免费体验券' }}</text>
</view>
<view class="info-row" v-if="isCompleted">
<text class="label">核销时间:</text>
<text class="value">{{ formatTime(orderInfo.verifyTime) || '-' }}</text>
</view>
<view class="info-row" v-if="isCompleted">
<text class="label">订单状态:</text>
<text class="value">核销完成</text>
</view>
<view class="info-row" v-if="isExpired">
<text class="label">到期时间:</text>
<text class="value">{{ orderInfo.endTime || '-' }}</text>
</view>
<view class="info-row" v-if="isExpired">
<text class="label">订单状态:</text>
<text class="value">已过期</text>
</view>
</view>
<view class="notice-section" v-if="!isCompleted && !isExpired">
<view class="section-title">使用须知</view>
<view class="rich-text-content">
<u-parse :content="orderInfo.experienceItemInfo && orderInfo.experienceItemInfo.useNotice ? orderInfo.experienceItemInfo.useNotice : ''"></u-parse>
</view>
</view>
<view class="bottom-bar" v-if="isCompleted || isExpired">
<view class="home-btn" @click="goHome">
<image :src="webUrl + '/orderIcon/home.png'" class="home-icon" />
<text>返回主页</text>
</view>
</view>
</view>
</template>
<script>
import { getExperienceCouponOrderDetail } from '@/api/product'
export default {
data() {
return {
webUrl: this.$VUE_APP_RESOURCES_URL,
orderId: '',
orderInfo: {},
userLatitude: null,
userLongitude: null,
distanceText: ''
}
},
computed: {
statusText() {
const status = this.orderInfo.experienceOrderStatus
if (status === 0) {
return '待使用'
}
if (status === 1) {
return '已完成'
}
if (status === 2) {
return '已过期'
}
return ''
},
isCompleted() {
return this.orderInfo.experienceOrderStatus === 1
},
isExpired() {
return this.orderInfo.experienceOrderStatus === 2
},
formattedBusinessTime() {
if (this.orderInfo && this.orderInfo.experienceItemInfo) {
const { validityStartTime, validityEndTime } = this.orderInfo.experienceItemInfo
if (validityStartTime && validityEndTime) {
return `${this.formatTimestamp(validityStartTime)}~${this.formatTimestamp(validityEndTime)}`
}
}
return this.orderInfo.businessTime || ''
}
},
onLoad(options) {
if (options && options.orderId) {
this.orderId = options.orderId
this.fetchDetail()
}
this.getUserLocation()
},
methods: {
fetchDetail() {
if (!this.orderId) {
return
}
getExperienceCouponOrderDetail(this.orderId).then(({ data }) => {
this.orderInfo = data || {}
this.updateDistance()
}).catch(() => {})
},
getUserLocation() {
uni.getLocation({
type: 'gcj02',
success: res => {
this.userLatitude = res.latitude
this.userLongitude = res.longitude
this.updateDistance()
}
})
},
formatTimestamp(timestamp) {
if (!timestamp) return ''
const date = new Date(Number(timestamp))
const year = date.getFullYear()
const month = String(date.getMonth() + 1).padStart(2, '0')
const day = String(date.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
},
formatTime(timestamp) {
if (!timestamp) return ''
const date = new Date(Number(timestamp))
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
return `${year}年${month}月${day}日`
},
goHome() {
uni.switchTab({
url: '/pages/tabBar/home/index'
})
},
updateDistance() {
if (
this.userLatitude == null ||
this.userLongitude == null ||
this.orderInfo.latitude == null ||
this.orderInfo.longitude == null
) {
return
}
const lat1 = Number(this.userLatitude)
const lon1 = Number(this.userLongitude)
const lat2 = Number(this.orderInfo.latitude)
const lon2 = Number(this.orderInfo.longitude)
const R = 6371
const dLat = (lat2 - lat1) * Math.PI / 180
const dLon = (lon2 - lon1) * Math.PI / 180
const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
Math.sin(dLon / 2) * Math.sin(dLon / 2)
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a))
const d = R * c
this.distanceText = d.toFixed(1)
},
openLocation() {
if (this.orderInfo.latitude && this.orderInfo.longitude) {
uni.openLocation({
latitude: Number(this.orderInfo.latitude),
longitude: Number(this.orderInfo.longitude),
name: this.orderInfo.merchantName,
address: this.orderInfo.address
})
}
},
callMerchant() {
if (this.orderInfo.merchantPhone) {
uni.makePhoneCall({
phoneNumber: this.orderInfo.merchantPhone
})
}
},
copyVerifyCode() {
if (!this.orderInfo.verifyCode) {
return
}
uni.setClipboardData({
data: this.orderInfo.verifyCode,
success: () => {
uni.showToast({
title: '已复制核销码',
icon: 'none'
})
}
})
}
}
}
</script>
<style scoped lang="less">
.coupon-order-detail {
min-height: 100vh;
padding: 24rpx;
box-sizing: border-box;
background: #f5f5f5;
padding-bottom: 120rpx;
}
.status-banner {
background: #C52733;
border-radius: 16rpx;
padding: 24rpx 32rpx;
margin-bottom: 24rpx;
}
.status-banner.completed {
// background: #E6EAF3;
padding: 32rpx;
}
.status-text {
color: #fff;
font-size: 32rpx;
font-weight: bold;
}
.status-text.dark-text {
color: #333;
font-size: 36rpx;
margin-bottom: 8rpx;
}
.status-subtext {
font-size: 24rpx;
color: #666;
}
.qrcode-card {
background: #fff;
border-radius: 16rpx;
padding: 32rpx;
margin-bottom: 24rpx;
display: flex;
flex-direction: column;
align-items: center;
}
.merchant-header {
width: 100%;
display: flex;
align-items: center;
margin-bottom: 24rpx;
align-self: flex-start;
}
.shop-icon {
width: 32rpx;
height: 32rpx;
margin-right: 12rpx;
}
.merchant-name {
font-size: 28rpx;
color: #333;
font-weight: 500;
}
.arrow-icon {
width: 24rpx;
height: 24rpx;
margin-left: 8rpx;
}
.project-name {
font-size: 36rpx;
color: #333;
font-weight: bold;
margin-bottom: 24rpx;
text-align: center;
}
.qrcode-wrap {
width: 336rpx;
height: 336rpx;
margin-bottom: 24rpx;
border-radius: 20px;
border: 1px solid #B8B8B8;
padding: 20rpx;
box-sizing: border-box;
}
.qrcode-image {
width: 100%;
height: 100%;
}
.verify-code {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
.verify-code .label {
font-size: 28rpx;
color: #666;
}
.verify-code .value {
font-size: 40rpx;
color: #333;
font-weight: bold;
margin: 0 16rpx;
}
.copy-icon {
width: 32rpx;
height: 32rpx;
}
.valid-time {
font-size: 24rpx;
color: #999;
}
.merchant-card {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
display: flex;
position: relative;
}
.merchant-avatar {
width: 140rpx;
height: 140rpx;
border-radius: 12rpx;
margin-right: 24rpx;
flex-shrink: 0;
}
.merchant-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
overflow: hidden;
}
.merchant-name-large {
font-size: 32rpx;
color: #333;
font-weight: bold;
margin-bottom: 8rpx;
}
.merchant-time {
font-size: 24rpx;
color: #666;
margin-bottom: 8rpx;
}
.merchant-location-wrap {
display: flex;
align-items: center;
font-size: 24rpx;
color: #999;
padding-right: 160rpx;
}
.location-icon {
width: 24rpx;
height: 24rpx;
margin-right: 4rpx;
flex-shrink: 0;
}
.distance-text {
margin-right: 12rpx;
flex-shrink: 0;
}
.address-text {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.merchant-actions {
display: flex;
flex-direction: row;
align-items: flex-end;
position: absolute;
right: 24rpx;
bottom: 24rpx;
}
.action-icon {
width: 64rpx;
height: 64rpx;
margin-left: 16rpx;
}
.detail-section {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 24rpx;
}
.section-title {
font-size: 32rpx;
color: #333;
font-weight: bold;
margin-bottom: 24rpx;
}
.info-row {
display: flex;
margin-bottom: 16rpx;
}
.info-row:last-child {
margin-bottom: 0;
}
.info-row .label {
font-size: 28rpx;
color: #666;
width: 160rpx;
}
.info-row .value {
font-size: 28rpx;
color: #333;
flex: 1;
}
.notice-section {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
}
.notice-item {
display: flex;
align-items: flex-start;
margin-bottom: 12rpx;
}
.notice-item:last-child {
margin-bottom: 0;
}
.notice-item .dot {
color: #666;
margin-right: 8rpx;
font-size: 24rpx;
}
.notice-item .text {
color: #666;
font-size: 26rpx;
line-height: 1.5;
}
.rich-text-content {
font-size: 26rpx;
color: #666;
line-height: 1.6;
}
.bottom-bar {
position: fixed;
bottom: 40rpx;
left: 0;
right: 0;
display: flex;
justify-content: center;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
.home-btn {
width: 686rpx;
height: 88rpx;
// background: #E8EBF0;
border: 2rpx solid #C52733;
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 32rpx;
color: #C52733;
font-weight: bold;
}
.home-icon {
width: 32rpx;
height: 32rpx;
margin-right: 12rpx;
}
</style>