<template>
	<view class="success-container">
		<erp-nav-bar title="下单成功" />
		<view class="success-card">
			<icon type="success" size="80" color="#C1001C" class="success-icon"></icon>
			<text class="status-title">提交成功</text>
			<text class="status-desc">您的订单已提交，正在等待业务员审核</text>

			<view class="btn-group">
				<!-- 查看订单：主按钮 -->
				<button class="primary-btn" @click="viewOrder">查看订单</button>
				<!-- 再来一单：次按钮 -->
				<button class="outline-btn" @click="handleReorder">再来一单</button>
				<!-- 返回下单页面：文字/轻量化链接风格按钮 -->
				<button class="text-btn" @click="handleReorder">返回下单页面</button>
			</view>
		</view>
	</view>
</template>

<script>
import ErpNavBar from '@/components/erp-nav-bar.vue';
export default {
	components: { ErpNavBar },
	data() {
		return {
			orderId: ''
		}
	},
	onLoad(options) {
		if (options.orderId) {
			this.orderId = options.orderId;
		}
	},
	methods: {
		// 将再来一单和返回页面功能合并：通过 reLaunch 自动重置数据
		handleReorder() {
			// reLaunch 会重新加载页面，彻底清空原有表单数据
			uni.reLaunch({
				url: '/pages/order/index'
			});
		},
		viewOrder() {
			if (!this.orderId) {
				uni.switchTab({
					url: '/pages/index/index'
				});
				return;
			}
			uni.navigateTo({
				url: '/pages/order/detail/index?rowId=' + this.orderId
			});
		}
	}
}
</script>

<style scoped>
.success-container {
	width: 100%;
	min-height: 100vh;
	background: #f7f8fa;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding-top: 15vh;
}

.success-card {
	width: 90%;
	background: #fff;
	border-radius: 32rpx;
	padding: 80rpx 40rpx;
	display: flex;
	flex-direction: column;
	align-items: center;
	box-shadow: 0 4rpx 30rpx rgba(0, 0, 0, 0.03);
}

.success-icon {
	margin-bottom: 40rpx;
}

.status-title {
	font-size: 40rpx;
	font-weight: bold;
	color: #333;
	margin-bottom: 16rpx;
}

.status-desc {
	font-size: 28rpx;
	color: #999;
	margin-bottom: 80rpx;
}

.btn-group {
	width: 100%;
	display: flex;
	flex-direction: column;
	gap: 24rpx;
}

.primary-btn {
	width: 100%;
	height: 96rpx;
	background: #C1001C;
	color: #fff;
	border-radius: 48rpx;
	font-size: 32rpx;
	font-weight: bold;
	display: flex;
	align-items: center;
	justify-content: center;
	border: none;
	box-shadow: 0 10rpx 20rpx rgba(193, 0, 28, 0.15);
}

.outline-btn {
	width: 100%;
	height: 96rpx;
	background: #fff;
	color: #C1001C;
	border-radius: 48rpx;
	font-size: 32rpx;
	font-weight: bold;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2rpx solid #C1001C;
}

.text-btn {
	margin-top: 20rpx;
	background: transparent;
	color: #666;
	font-size: 28rpx;
	border: none;
	text-decoration: underline;
	/* 增加下划线提示可点击 */
}

.text-btn:active {
	color: #333;
	opacity: 0.8;
}
</style>
