<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>
			</view>
		</view>
	</view>
</template>

<script>
import ErpNavBar from '@/components/erp-nav-bar.vue';
export default {
	components: { ErpNavBar },
	data() {
		return {
			orderId: '',
			clientId: '',
			clientName: ''
		}
	},
	onLoad(options) {
		if (options.orderId) {
			this.orderId = options.orderId;
		}
		if (options.clientId) {
			this.clientId = decodeURIComponent(options.clientId);
		}
		if (options.clientName) {
			this.clientName = decodeURIComponent(options.clientName);
		}
	},
	methods: {
		handleReorder() {
			let url = '/pages/order/index';
			if (this.clientId) {
				url += `?clientId=${this.clientId}&clientName=${encodeURIComponent(this.clientName)}`;
			}
			uni.reLaunch({ url });
		},
		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;
}
</style>
