<template>
	<view class="container">
		<u-navbar title="点单详情" :border-bottom="false" :background="bgc" back-icon-color="#fff" title-color='#fff'
			title-size='36' height='36' id="navbar">
		</u-navbar>
		<!-- 顶部酒吧信息 -->
		<view class="bar-info">
			<text class="bar-name">{{goodsList.storeName}}</text>
            <image @click="btntel" style="width: 42rpx;height: 42rpx;" src="https://api.ccttiot.com/smartmeter/img/static/uuGnSpvQrpdkNgQKbRak" mode=""></image>
		</view>

		<!-- 商品列表 -->
		<view class="goods-list">
			<view class="goods-item" v-for="(item, index) in goodsList.goodsOrderSkuVOList" :key="index">
				<image class="image-placeholder" :src="item.picture" mode=""></image>
				<view class="goods-detail">
					<view class="">
						<text class="goods-name">{{ item.goodsName }}</text>
						<view class="special-request">{{ item.description }}</view>
					</view>
					<view class="">
						<view class="price-group">
							<text class="goods-price">￥{{ item.price }}</text>
						</view>
						<text class="quantity">×{{ item.number }}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 价格总计 -->
		<view class="total-section">
			<text class="total-label">实付：</text>
			<text class="total-amount">￥{{ goodsList.payedAmount == null ? '0' : goodsList.payedAmount}}</text>
		</view>

		<!-- 订单详情 -->
		<view class="order-details">
			<view class="detail-item">
				<text class="detail-label">订单编号：</text>
				<text class="detail-value">{{ goodsList.orderNo }}</text>
			</view>
			<view class="detail-item">
				<text class="detail-label">订单状态：</text>
				<text class="detail-value" v-if="goodsList.status == 'WAIT_DELIVERY'">待配送</text>
				<text class="detail-value" v-if="goodsList.status == 'WAIT_PAY'">待支付</text>
				<text class="detail-value" v-if="goodsList.status == 'FINISHED'">已结束</text>
				<text class="detail-value" v-if="goodsList.status == 'CANCELED'">已取消</text>
				<text class="detail-value" v-if="goodsList.status == 'REFUNDED'">已退款</text>
			</view>
			<view class="detail-item">
				<text class="detail-label">下单时间：</text>
				<text class="detail-value">{{ goodsList.createTime }}</text>
			</view>
			<view class="detail-item">
				<text class="detail-label">支付方式：</text>
				<text class="detail-value">微信支付</text>
			</view>
			<view class="detail-item">
				<text class="detail-label">订单金额：</text>
				<text class="detail-value">￥{{ goodsList.payAmount == null ? '0' : goodsList.payAmount}}</text>
			</view>
			<view class="detail-item">
				<text class="detail-label">退款金额：</text>
				<text class="detail-value">￥{{ goodsList.payRefunded == null ? '0' : goodsList.payRefunded}}</text>
			</view>
			<view class="detail-item">
				<text class="detail-label">实际金额：</text>
				<text class="detail-value">￥{{ Number(goodsList.payedAmount) - Number(goodsList.payRefunded) }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsList: {},
				bgc: {
					backgroundColor: "#000000",
				},
				no: ''
			};
		},
		onLoad(option) {
			this.no = option.no
			this.getxq()
		},
		methods: {
			getxq() {
				this.$u.get(`/app/goodsOrder/goodsOrderDetail?eqNo=${this.no}`).then(res => {
					if (res.code == 200) {
						this.goodsList = res.data
					}
				})
			},
			// 点击拨打电话
			btntel(){
				if(this.goodsList.mchPhone){
					uni.makePhoneCall({
					  phoneNumber: String(this.goodsList.mchPhone),
					  success: () => {
					    console.log("拨打电话成功")
					  },
					  fail: (err) => {
					    console.log("拨打电话失败:", err)
					    uni.showToast({
					      title: '暂无电话',
					      icon: 'none',
						  duration:3000
					    })
					  }
					})
				}else{
					uni.showToast({
					  title: '暂无电话',
					  icon: 'none',
					  duration:3000
					})
				}
			}
		}
	};
</script>

<style scoped>
	.container {
		background-color: #000000;
		min-height: 100vh;
		padding: 24rpx;
	}

	.bar-info {
		padding: 32rpx;
		background-color: #1A1A1A;
		border-radius: 16rpx;
		margin-bottom: 32rpx;
		display: flex;
		justify-content: space-between;
	}

	.bar-name {
		display: block;
		font-size: 36rpx;
		font-weight: 600;
		color: #FFFFFF;
	}

	.bar-address {
		font-size: 28rpx;
		color: #999999;
		line-height: 1.4;
	}

	.goods-list {
		margin-bottom: 32rpx;
	}

	.goods-item {
		display: flex;
		align-items: flex-start;
		padding: 32rpx;
		background-color: #1A1A1A;
		border-radius: 16rpx;
		margin-bottom: 24rpx;
	}

	.image-placeholder {
		width: 120rpx;
		height: 120rpx;
		background-color: #333333;
		border-radius: 8rpx;
		margin-right: 24rpx;
		flex-shrink: 0;
	}

	.goods-detail {
		flex: 1;
		display: flex;
		justify-content: space-between;
	}

	.goods-name {
		display: block;
		font-size: 32rpx;
		color: #FFFFFF;
		margin-bottom: 12rpx;
	}

	.price-group {
		display: flex;
		align-items: center;
		margin-bottom: 12rpx;
	}

	.goods-price {
		font-size: 28rpx;
		color: #FFFFFF;
		margin-right: 16rpx;
	}

	.special-request {
		font-size: 24rpx;
		color: #999999;
		background-color: #333333;
		padding: 8rpx 16rpx;
		border-radius: 32rpx;
	}

	.quantity {
		font-size: 28rpx;
		color: #999999;
		display: block;
		margin-top: 50rpx;
	}

	.total-section {
		padding: 24rpx 32rpx;
		background-color: #1A1A1A;
		border-radius: 16rpx;
		margin-bottom: 32rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.total-label {
		font-size: 32rpx;
		color: #999999;
		margin-right: 16rpx;
	}

	.total-amount {
		font-size: 36rpx;
		color: #FFFFFF;
		font-weight: 600;
	}

	.order-details {
		background-color: #1A1A1A;
		border-radius: 16rpx;
		padding: 32rpx;
	}

	.detail-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 24rpx 0;
		border-bottom: 1rpx solid #333333;
	}

	.detail-item:last-child {
		border-bottom: none;
	}

	.detail-label {
		font-size: 28rpx;
		color: #999999;
	}

	.detail-value {
		font-size: 28rpx;
		color: #FFFFFF;
		text-align: right;
	}

	.status-item {
		margin-top: 16rpx;
		padding-top: 24rpx;
		border-top: 1rpx solid #333333;
	}

	.status-value {
		font-size: 32rpx;
		color: #4CD964;
		font-weight: 500;
	}
</style>