<template>
  <view class="container">
	  <u-navbar title="购买会员卡详情" :border-bottom="false" :background="bgc" back-icon-color="#333333" title-color='#333333'
	      		title-size='36' height='36' id="navbar">
	      	</u-navbar>
    <!-- 订单卡片 -->
    <view class="order-card">
      <!-- 订单基本信息 -->
      <view class="section">
		  <view class="info-item">
		    <text class="label">订单状态</text>
		    <text class="value">已支付</text>
		  </view>
        <view class="info-item">
          <text class="label">订单编号</text>
          <text class="value">{{ orderData.no }}</text>
        </view>
        <view class="info-item">
          <text class="label">下单时间</text>
          <text class="value">{{ orderData.createTime }}</text>
        </view>
      </view>
      
      <!-- 会员卡信息 -->
      <view class="section" style="margin-top: 20rpx;">
        <view class="info-item">
          <text class="label">会员名称</text>
          <text class="value">{{ orderData.vipName }}</text>
        </view>
        <view class="info-item">
          <text class="label">购买用户</text>
          <text class="value">{{ orderData.userName }}</text>
        </view>
        <view class="info-item">
          <text class="label">售价</text>
          <text class="value price">¥{{ orderData.vipPrice }}</text>
        </view>
        <view class="info-item">
          <text class="label">卡券类型</text>
          <text class="value">{{ isDeductionCard(orderData) ? '抵扣券' : '折扣卡' }}</text>
        </view>
        <view class="info-item">
          <text class="label">{{ isDeductionCard(orderData) ? '抵扣金额' : '折扣' }}</text>
          <text class="value">{{ getCardValueText(orderData) }}</text>
        </view>
        <view class="info-item">
          <text class="label">有效期</text>
          <text class="value">{{ orderData.vipValidDays }}天</text>
        </view>
        <view class="info-item" v-if="item.vipEnableLimit">
          <text class="label">使用限制</text>
          <text class="value">{{ orderData.vipLimitRound }}天内可用{{ orderData.vipLimitCount }}次</text>
        </view>
		<view class="info-item">
		  <text class="label">总次数</text>
		  <text class="value">{{ orderData.vipLimitTotal }}次</text>
		</view>
		<view class="info-item">
		  <text class="label">适用运营区</text>
		  <text class="value">{{ orderData.vipAreaName }}</text>
		</view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      orderData: {},
	  id:''
    }
  },
  onLoad(option) {
  	this.id = option.id
	this.getxq()
  },
  methods: {
	   isDeductionCard(item) {
	   	 const cardType = item ? (item.vipType !== undefined && item.vipType !== null ? item.vipType : item.type) : ''
	   	 return Number(cardType) === 2
	   },
	   getCardValueText(item) {
	   	 const amountOrDiscount = item ? item.vipDiscountValue : ''
	   	 if (this.isDeductionCard(item)) {
	   	 	const num = Number(amountOrDiscount)
	   	 	return `${Number.isFinite(num) ? num.toFixed(2) : amountOrDiscount}元`
	   	 }
	   	 return `${amountOrDiscount}折`
	   },
       // 获取订单详情
	   getxq() {
	       this.$u.get(`/app/vipOrder/detail?id=${this.id}`).then((res) => {
	       	   if (res.code == 200) {
	   			   this.orderData = res.data
	       	   }
	       })
	   },
  }
}
</script>

<style lang="scss" scoped>
.container {
  padding: 20rpx;
  background-color: #f5f5f5;
  min-height: 100vh;
}

.status-bar {
  padding: 20rpx;
  text-align: center;
  font-size: 32rpx;
  font-weight: bold;
  color: #fff;
  margin-bottom: 20rpx;
  border-radius: 8rpx;
  
  &.paid {
    background-color: #67C23A;
  }
  
  &.unpaid {
    background-color: #E6A23C;
  }
}

.order-card {
  background-color: #fff;
  border-radius: 12rpx;
  padding: 30rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}

.info-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 24rpx;
  font-size: 28rpx;
  
  &:last-child {
    margin-bottom: 0;
  }
  
  .label {
    color: #999;
    width: 180rpx;
  }
  
  .value {
    color: #333;
    flex: 1;
    text-align: right;
    
    &.price {
      color: #f56c6c;
      font-weight: bold;
    }
  }
}

.action-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 40rpx;
  padding: 0 20rpx;
  
  .btn {
    flex: 1;
    height: 80rpx;
    line-height: 80rpx;
    font-size: 30rpx;
    border-radius: 40rpx;
    
    &.secondary {
      background-color: #fff;
      color: #666;
      border: 1rpx solid #ddd;
      margin-right: 20rpx;
    }
    
    &.primary {
      background-color: #4a8cff;
      color: #fff;
    }
  }
}
</style>