文件
fenleixinxi/uniapp/pages/order/success.vue

426 行
10 KiB
Vue

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<view class="success-page fc-page">
<!-- 自定义导航栏:深绿渐变沉浸式 -->
<fc-navbar title="支付结果" theme="gradient" :show-back="true" />
<!-- 顶部深绿沉浸底座 -->
<view class="success-page__backdrop">
<view class="success-page__backdrop-ambient"></view>
</view>
<view class="success-page__body">
<!-- 支付成功核心凭据卡片 -->
<view class="fc-card success-card">
<!-- 成功对勾图标(春绿外圆 + 白色微质感对勾) -->
<view class="success-card__icon-box">
<view class="success-card__check-icon">✓</view>
</view>
<text class="success-card__status">支付成功</text>
<text class="success-card__desc">{{ successSubText }}</text>
<!-- 实付金额大字展示(阳光金) -->
<view class="success-card__amount-row">
<text class="success-card__amount-yen">¥</text>
<text class="success-card__amount-val">{{ formattedAmount }}</text>
</view>
<!-- 若有优惠券抵扣,展示立省标签 -->
<view v-if="hasDiscount" class="success-card__saved-pill">
<text>已享优惠券抵扣 ¥{{ formattedDiscount }}</text>
</view>
<!-- 订单详细清单分割线 -->
<view class="success-card__divider"></view>
<!-- 订单明细列表 -->
<view class="success-card__items">
<view class="success-card__item">
<text class="success-card__label">商品名称</text>
<text class="success-card__value fc-ellipsis">{{ title || '会员服务' }}</text>
</view>
<view class="success-card__item">
<text class="success-card__label">支付方式</text>
<text class="success-card__value">{{ payTypeName }}</text>
</view>
<view v-if="hasDiscount" class="success-card__item">
<text class="success-card__label">订单原价</text>
<text class="success-card__value">¥{{ formattedOriginAmount }}</text>
</view>
<view v-if="hasDiscount" class="success-card__item">
<text class="success-card__label">优惠券抵扣</text>
<text class="success-card__value success-card__value--discount">-¥{{ formattedDiscount }}</text>
</view>
<view v-if="orderNo" class="success-card__item">
<text class="success-card__label">交易单号</text>
<text class="success-card__value success-card__value--mono">{{ orderNo }}</text>
</view>
<view class="success-card__item">
<text class="success-card__label">支付时间</text>
<text class="success-card__value">{{ payTimeText }}</text>
</view>
</view>
</view>
<!-- 底部操作按钮组 -->
<view class="success-page__actions">
<!-- 主操作按钮(春绿渐变底 + 深墨绿字,严格遵循对比度规范) -->
<view class="success-page__btn success-page__btn--primary" @click="handlePrimaryAction">
<text class="success-page__btn-text success-page__btn-text--primary">{{ primaryActionText }}</text>
</view>
<!-- 次操作按钮(白底浅描边) -->
<view class="success-page__btn success-page__btn--secondary" @click="handleSecondaryAction">
<text class="success-page__btn-text success-page__btn-text--secondary">返回个人中心</text>
</view>
</view>
</view>
</view>
</template>
<script>
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
import { formatTime } from '@/common/utils/format.js'
import { useUserStore } from '@/common/store/index.js'
export default {
name: 'PaymentSuccessPage',
components: {
FcNavbar,
},
data() {
return {
/** 订单编号 */
orderNo: '',
/** 业务类型:member(会员开通) | post(发帖付费) | recharge(充值) */
type: 'member',
/** 商品/套餐标题 */
title: '',
/** 实付金额 */
amount: '0.00',
/** 原价金额 */
originAmount: '0.00',
/** 优惠抵扣金额 */
discount: '0.00',
/** 支付类型:wxpay | balance */
payType: 'wxpay',
/** 支付完成时间戳(毫秒) */
payTime: Date.now(),
}
},
computed: {
/**
* 格式化实付金额
* @returns {string}
*/
formattedAmount() {
const n = Number(this.amount)
return isNaN(n) ? '0.00' : n.toFixed(2)
},
/**
* 格式化原价金额
* @returns {string}
*/
formattedOriginAmount() {
const n = Number(this.originAmount)
return isNaN(n) ? this.formattedAmount : n.toFixed(2)
},
/**
* 格式化优惠金额
* @returns {string}
*/
formattedDiscount() {
const n = Number(this.discount)
return isNaN(n) ? '0.00' : n.toFixed(2)
},
/**
* 是否存在优惠券优惠抵扣
* @returns {boolean}
*/
hasDiscount() {
return Number(this.discount) > 0
},
/**
* 支付方式名称
* @returns {string}
*/
payTypeName() {
return this.payType === 'balance' ? '余额支付' : '微信支付'
},
/**
* 格式化支付时间
* @returns {string}
*/
payTimeText() {
return formatTime(this.payTime / 1000)
},
/**
* 成功副标题描述
* @returns {string}
*/
successSubText() {
if (this.type === 'member') return '恭喜您已成功开通 VIP 尊享会员'
if (this.type === 'post') return '信息已提交,祝您生活愉快'
if (this.type === 'recharge') return '账户余额已即时充值入账'
return '订单已顺利支付完成'
},
/**
* 主操作按钮文案
* @returns {string}
*/
primaryActionText() {
if (this.type === 'member') return '查看会员特权'
if (this.type === 'post') return '查看我的发布'
if (this.type === 'recharge') return '查看充值明细'
return '返回首页'
},
},
/**
* 页面加载生命周期
* @param {Object} options 携带的支付参数
*/
onLoad(options) {
if (options) {
this.orderNo = options.orderNo || ''
this.type = options.type || 'member'
this.title = options.title ? decodeURIComponent(options.title) : ''
this.amount = options.amount || '0.00'
this.originAmount = options.originAmount || this.amount
this.discount = options.discount || '0.00'
this.payType = options.payType || 'wxpay'
}
// 刷新全局用户信息(更新会员身份、余额等)
try {
useUserStore().fetchProfile()
} catch (e) {}
},
methods: {
/**
* 点击主操作按钮
*/
handlePrimaryAction() {
if (this.type === 'member') {
// 返回会员中心页面刷新状态
uni.redirectTo({ url: '/pages/member/index' })
} else if (this.type === 'post') {
uni.redirectTo({ url: '/pages/post/mine' })
} else if (this.type === 'recharge') {
uni.redirectTo({ url: '/pages/member/orders' })
} else {
uni.switchTab({ url: '/pages/index/index' })
}
},
/**
* 点击次操作按钮:返回个人中心
*/
handleSecondaryAction() {
uni.switchTab({ url: '/pages/mine/index' })
},
},
}
</script>
<style lang="scss" scoped>
.success-page {
min-height: 100vh;
background-color: $fc-bg;
position: relative;
padding-bottom: 60rpx;
}
/* 顶部沉浸渐变底座 */
.success-page__backdrop {
position: absolute;
top: 0;
left: 0;
right: 0;
height: 380rpx;
background: $fc-gradient-hero;
overflow: hidden;
z-index: 0;
}
.success-page__backdrop-ambient {
position: absolute;
top: -60rpx;
right: -60rpx;
width: 320rpx;
height: 320rpx;
border-radius: 50%;
background: radial-gradient(circle, rgba(0, 224, 112, 0.28) 0%, rgba(0, 224, 112, 0) 70%);
filter: blur(20px);
}
.success-page__body {
position: relative;
z-index: 2;
padding: 24rpx 32rpx;
}
/* 凭据卡片 */
.success-card {
background: #ffffff;
border-radius: 28rpx;
box-shadow: 0 10rpx 32rpx rgba(4, 48, 30, 0.08);
padding: 48rpx 36rpx;
display: flex;
flex-direction: column;
align-items: center;
}
/* 成功对勾图标 */
.success-card__icon-box {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
background: linear-gradient(135deg, #00e070 0%, #00b85c 100%);
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8rpx 24rpx rgba(0, 224, 112, 0.35);
margin-bottom: 24rpx;
}
.success-card__check-icon {
color: #ffffff;
font-size: 64rpx;
font-weight: 800;
line-height: 1;
}
.success-card__status {
font-size: 40rpx;
font-weight: 800;
color: $fc-text;
margin-bottom: 8rpx;
}
.success-card__desc {
font-size: 24rpx;
color: $fc-text-placeholder;
margin-bottom: 28rpx;
}
/* 实付金额 */
.success-card__amount-row {
display: flex;
align-items: baseline;
color: $fc-accent;
margin-bottom: 12rpx;
}
.success-card__amount-yen {
font-size: 34rpx;
font-weight: 700;
margin-right: 4rpx;
}
.success-card__amount-val {
font-size: 68rpx;
font-weight: 800;
line-height: 1;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
/* 立省胶囊 */
.success-card__saved-pill {
padding: 6rpx 20rpx;
border-radius: 30rpx;
background: rgba(245, 166, 35, 0.12);
color: $fc-accent-dark;
font-size: 22rpx;
font-weight: 600;
margin-bottom: 36rpx;
}
/* 分割线 */
.success-card__divider {
width: 100%;
height: 1rpx;
background-color: #eaf1ed;
margin-bottom: 32rpx;
}
/* 订单明细清单 */
.success-card__items {
width: 100%;
display: flex;
flex-direction: column;
gap: 20rpx;
}
.success-card__item {
display: flex;
align-items: center;
justify-content: space-between;
}
.success-card__label {
font-size: 26rpx;
color: #6c887b;
}
.success-card__value {
font-size: 26rpx;
color: $fc-text;
font-weight: 600;
max-width: 440rpx;
&--discount {
color: #e65100;
}
&--mono {
font-family: monospace;
font-size: 24rpx;
color: #557766;
}
}
/* 底部操作按钮 */
.success-page__actions {
margin-top: 48rpx;
display: flex;
flex-direction: column;
gap: 24rpx;
}
.success-page__btn {
height: 92rpx;
border-radius: 46rpx;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
&:active {
transform: scale(0.98);
}
}
/* 主操作按钮:亮绿底必须墨绿字 */
.success-page__btn--primary {
background: $fc-gradient-primary;
box-shadow: 0 8rpx 24rpx rgba(0, 224, 112, 0.3);
}
.success-page__btn-text--primary {
font-size: 30rpx;
font-weight: 700;
color: $fc-primary-ink; /* 春绿规范强制:亮绿背景上的文字使用深墨绿 */
}
/* 次操作按钮 */
.success-page__btn--secondary {
background: #ffffff;
border: 1rpx solid #dbe6e0;
}
.success-page__btn-text--secondary {
font-size: 28rpx;
font-weight: 600;
color: #3b5f4d;
}
</style>