<template>
  <view>
    <up-waterfall>
      <template #left>
        <view class="demo-warter" v-for="(item, index) in props.leftList" :key="index" @click="goToDetail(item)">
          <view v-if="item.type == 'slideshow'" class="home-swiper" @click.stop>
            <view v-if="ValueZoneSwiper.length > 0">
              <up-swiper :list="ValueZoneSwiper" :indicator="false" class="Up-swiper" @click="handleSwiperClick"
                :height="'516rpx'"></up-swiper>
            </view>
          </view>

          <template v-else>
            <up-lazy-load threshold="50" border-radius="10" :image="item.volunteerPicture" :index="index"
              mode="aspectFill"></up-lazy-load>
            <view class="demo-title-container">
              <view class="demo-title">
                {{ item.businessTierName }}
              </view>
            </view>

            <view class="demo-skillDescribe">
              {{ item.skillDescribe }}
            </view>
            <view class="demo-PriceDome">
              <view class="demo-price">
                <image :src="item.volunteerPicture" class="name-image"></image>
                <text class="name-text">{{ item.name }}</text>
              </view>
              <view class="demo-price">
                <image src="/static/img/1x.png" class="image-1x"></image>
                <text class="name-textNumber">1w</text>
              </view>
            </view>
          </template>
        </view>
      </template>

      <template #right>
        <view class="demo-warter" v-for="(item, index) in props.rightList" :key="index" @click="goToDetail(item)">
          <up-lazy-load threshold="50" border-radius="10" :image="item.volunteerPicture" :index="index"
            mode="aspectFill"></up-lazy-load>
          <view class="demo-title-container">
            <view class="demo-title">
              {{ item.businessTierName }}
            </view>
          </view>
          <view class="demo-skillDescribe">
            {{ item.skillDescribe }}
          </view>
          <view class="demo-PriceDome">
            <view class="demo-price">
              <image :src="item.volunteerPicture" class="name-image"></image>
              <text class="name-text">{{ item.name }}</text>
            </view>
            <view class="demo-price">
              <image src="/static/img/1x.png" class="image-1x"></image>
              <text class="name-textNumber">1w</text>
            </view>
          </view>
        </view>
      </template>
    </up-waterfall>
  </view>
</template>

<script setup>
const props = defineProps({
  leftList: {
    type: Array,
    default: () => []
  },
  rightList: {
    type: Array,
    default: () => []
  },
  ValueZoneSwiper: {
    type: Array,
    default: () => []
  }
});

// 轮播图点击事件
const handleSwiperClick = (item) => {
  console.log('轮播图点击', item);
  // 这里可以添加轮播图的点击处理逻辑
}

const goToDetail = async (item) => {
  const params = {
    volunteerId: item.volunteerId, // 获取 volunteerId
    serviceCategory: item.serviceCategory, // 获取 serviceCategory
    businessManagementId: item.businessManagementId, //获取 businessManagementId
  };
  const data = encodeURIComponent(JSON.stringify(params))
  console.log(data, '>>>>>data');
  uni.navigateTo({
    url: `/pages_home/pages/Volunteerside/goodsDetails?params=${data}`
  });
}
</script>

<style scoped lang="scss">
/* 轮播图片 */
.home-swiper {
  width: 340rpx;
  height: 516rpx;

  :deep(.Up-swiper) {
    width: 100%;
    height: 100%;
  }
}

.demo-warter {
  margin-top: 80rpx;
  border-radius: 8px;
  margin: 5px;
  background-color: #ffffff;
  // padding-left: 10rpx;
  // padding-right: 10rpx;
  margin-bottom: 30rpx;
}

.u-close {
  position: absolute;
  top: 32rpx;
  right: 32rpx;
}

.demo-image {
  width: 100%;
  border-radius: 4px;
}

.demo-title-container {

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 4rpx 12rpx;
  // z-index: 0;
  margin-top: 10rpx;
  border-radius: 10rpx;
  box-sizing: border-box;
  border: 1rpx solid rgba(237, 93, 49, 0.8);
}

.demo-title {

  font-size: 22rpx;
  color: #ED5D31;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.demo-skillDescribe {
  width: 298rpx;
  height: 73rpx;

  font-family: PingFang SC;
  font-size: 26rpx;
  font-weight: 500;
  line-height: 36rpx;
  letter-spacing: normal;
  color: #141414;
  margin-top: 5px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.demo-img {
  width: 40rpx;
  height: 40rpx;
  border-radius: 50%;
}

.demo-PriceDome {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 15rpx;
}

.demo-price {
  display: flex;
  align-items: center;
  overflow: hidden;
  /* 防止内容溢出 */
}
.image-1x{
    width: 20rpx;
    height: 20rpx;
    z-index: 0;
}
.name-textNumber{
      font-size: 22rpx;
      font-weight: normal;
      line-height: 24rpx;
      text-align: right;
      letter-spacing: -0.04em;
      color: #FF6E51;
}


.name-text {
  width: 117rpx;
  height: 34rpx;
  font-family: PingFang SC;
  font-size: 24rpx;
  font-weight: normal;
  line-height: 34rpx;
  letter-spacing: -0.04em;
  color: rgba(0, 0, 0, 0.8);
}

.name-image {
  width: 40rpx;
  height: 40rpx;
  margin-right: 10rpx;
  border-radius: 50%;
}


.name-text {
  white-space: nowrap;
  /* 禁止换行 */
  overflow: hidden;
  /* 超出部分隐藏 */
  text-overflow: ellipsis;
  /* 显示省略号 */
  max-width: 120rpx;
  /* 6个中文字符大约占120rpx */
}
</style>