<template>
	<view class="intro-page common">
		<view class="top-class"></view>
		<view class="title">
			扫码记录
		</view>
    <view class="head">
      <u-row class="row-class"  justify="flex-end">
        <u-col span="4">
          <image class="logo-rules" @click="openDetail" src="https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/qilang/common/rules.png"  />
        </u-col>
      </u-row>
    </view>

		<!-- 公司简介内容卡片 -->
		<view class="content">

			<view class="content_text">
				<view class="filter-btn-group">
					<view class="row-text">发放状态：</view>
					<view v-for="(item, idx) in filterOptions" :key="idx"
						:class="['filter-btn', filterStatus === item.value ? 'active' : '']"
						@click="onFilterChange(item.value)">
						{{ item.label }}
					</view>
				</view>
				<view class="filter-btn-group list-title">
					<view class="son">
						奖品名称
					</view>
					<view class="son">
						中奖时间
					</view>
					<view class="son">
						兑换状态
					</view>

					<view>
						操作
					</view>
				</view>
				<view class="content-list">
					<image v-if="list == null || list.length == 0 " style="height: 240rpx;margin-top: 140rpx"
						src="https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/qilang/noData.png"
						mode="heightFix"></image>
					<template v-for="(item, index) in list">
						<view class="row-one" :key="index">
							<view class="filter-btn-group">
                <view class="son" v-if="item.prize_type === 2">
                  再来一包
                </view>
                <view class="son" v-else-if="item.prize_type === 4">
                  {{item.prize_detail}}积分
                </view>
                <view class="son" v-else>
                  {{ item.prize_name }}
                </view>
								<view class="son">
									{{ item.zhongjiang_time }}
								</view>
								<view class="son">
									{{ item.duijiang_status }}
								</view>
								<view class="detail-btn" @click="toggleDetail(index)">
									详情
								</view>
							</view>

							<!-- 只有当 detailVisible 为 true 时才显示 detail 部分 -->
							<view class="detail" v-if="item.detailVisible">
								<view class="text-one">
									详情：{{item.prize_detail}}
								</view>
								<view class="text-two">
									发放时间：{{ item.send_time != undefined ? item.send_time : '--'  }} <!-- 这里可以填入合适的数据 -->
								</view>
							</view>
						</view>
					</template>

				</view>
			</view>


			<view class="return_view">
				<view class="return-button"  @click="goBack">返回</view>
			</view>
		</view>

	</view>
</template>

<script>
import {
  scanQuery
} from '@/api/scan'
import recordMixin from '@/mixins/recordMixin.js'

export default {
  mixins: [recordMixin],
  onLoad() {
    this.scanCode = uni.getStorageSync('scanCode');
    // 调用 mixin 中的通用方法
    this.baseInitGetlist(scanQuery);
  },
  methods: {
    onFilterChange(val) {
      this.filterStatus = val;
      this.baseInitGetlist(scanQuery);
    },
    initGetlist() {
      // 调用 mixin 中的通用方法
      this.baseInitGetlist(scanQuery);
    },
    openDetail() {
      uni.navigateTo({
        url: '/pages/qilang/index/rules'
      });
    },
  }
}
</script>


<style lang="scss" scoped>
	@import url('../../../static/scss/common_qilang.css');

	.row-class {
		height: 80rpx;
	}
	.cardTop{
		background-image:
			url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/cjx/smjl.png");
	}

	.theme-text {
		height: 10vh;
		text-align: center;
		line-height: 11vh;

		.textImage {
			height: 80rpx;
			width: 400rpx;
		}
	}

	.content {
		height: 68vh;
		padding: 10rpx 24rpx;
		overflow: auto;
		align-items: center;
		justify-content: center;
    border-radius: 48px;
    background: #FDE2B1;
    border: 6px solid #FB911b;
    margin: 10vh 40rpx 0rpx;

	}

	.filter-btn-group {
		display: flex;
		justify-content: flex-start;
		align-items: center;
		gap: 24rpx;
		margin: 10rpx 0 10rpx 0;
	}

	.filter-btn {
		padding: 4rpx 20rpx;
		border: 2rpx solid #F94C28;
		color: #F94C28;
		font-size: 28rpx;
		transition: all 0.2s;
	}

	.filter-btn.active {
		background: #F94C28;
		color: #fff;
		border: 2rpx solid #F94C28;
	}

	.row-text {
		font-weight: bold;
		font-size: 14px;
		color: #493D3E ;
	}

	.list-title {
		font-weight: bold;
		font-size: 28rpx;
		color: #493D3E ;
	}

	.son {
		width: 140rpx;
	}

	.row-one {
		font-weight: 400;
		font-size: 28rpx;
		color: #4A3D3E ;
	}

	.detail {
		background-image: url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/qilang/detailImg.png");
		background-size: cover;
		/* 确保背景图片自适应填充整个容器 */
		background-position: inherit;
		/* 背景图片居中显示 */
		background-repeat: no-repeat;
		/* 防止背景图重复 */
		height: 134rpx;

		.text-one {
			height: 70rpx;
			line-height: 90rpx;
			text-align: left;
			margin-left: 20rpx;
		}

		.text-two {
			text-align: left;
			height: 60rpx;
			line-height: 60rpx;
			margin-left: 20rpx;

		}

	}



	.detail-btn {
		color: #F94C28;
	}

	.content-list {
		overflow: auto;
		text-align: center;
		height: calc(100% - 160rpx);
	}
</style>
