<template>
  <view
    class="recharge flex align-items justify-start flex-column"
    :style="{
      zIndex: '-1',
      backgroundPosition: 'top',
      backgroundRepeat: 'no-repeat',
    }"
  >


    <view class="box">
      <!-- logo -->
      <view>
        <image
          src="/static/index/logo1.png"
          mode=""
          style="width: 430rpx; height: 80rpx;margin-top: 65rpx;"
        ></image>
      </view>
      <!-- 搜索 -->
      <view class="serch_top">
        <u-search
          class="u-search"
          v-model="keywords"
          placeholder="搜索您要找的内容"
          :showAction="false"
          search-icon="/static/index/search.png"
          @change="search()"
        >
        </u-search>
        <span class="searchBtn" @click.stop="search()">搜索</span>
      </view>

      <view class="swiper-box">
        <MySwiper :list="swiperList"></MySwiper>
      </view>

      <!-- 标签 -->
      <view class="tab_all">
        <view class="tabs">
          <view
            v-for="(tab, index) in list"
            :key="index"
            :class="['tab-item', { active: current === index }]"
            @click="handleClick(index)"
          >
            <image
              v-if="index != 0"
              :src="tab.url"
              mode=""
              class="imgs_bq"
            ></image>
            <span>{{ tab.name }}</span>
          </view>
        </view>
        <view class="allbq" @click="openBq">
          <image src="/static/index/qbbq.png" mode="" class="imgs_all"></image>
        </view>
      </view>
      <!-- 热门活动 -->
      <view class="hot flex flex-column">
        <view class="content flex align-items flex-column">
          <view
				class="flex flex-column w-100 bbb"
				v-for="(item, index) in hotList"
				:key="index"
				@click="detail(item.id)"
			>
            <view
              class="flex "
              style="margin-top: 24rpx"
            >
              <view
                class="right flex flex-column"
                style="align-items: self-start"
              >
                <span class="title white-space">{{ item.title }}</span>
                <view class="first-image flex align-items" style="margin-top: 20rpx;width: 100%;">
                  <image :src="item.user.avatar" style="width: 36rpx;height: 36rpx;"></image>
                  <span style="color: #9C9C9C;margin-left: 10rpx;width: 35%;">{{ item.user.nickname }}</span>
                  <view class="white-space" style="width: 60%;">
                    <span style="color:#0CA013;margin-left: 20rpx;" v-for="item in item.classes_cate">#{{ item }}</span>
                  </view>
                </view>

                <view class="flex flex-column"  style="margin-top: 20rpx;">
                  <view class="time flex align-items white-space">
                    <span class="time_tex" v-if="item.status == 2">{{ '报名中' }}</span>
                    <span style="margin:0 8rpx;">{{ dateWeeks(item.sign_start_time) }}</span>|
                    <span class="white-space" style="margin-left: 8rpx;width: 260rpx;">{{ item.address_detail }}</span>
                  </view>

                </view>

                <view class="flex align-items justify-center" style="margin-top: 20rpx;" >
                  <image class="imgs_con" v-for="(item,index) in item.images.slice(0,3)" :key="index" :src="item"></image>
                </view>
              </view>
            </view>
            <view class="bottom flex align-items">
              <view class="flex align-items toptext">
                <span class="flex align-items">
                  <u-avatar-group
                    :urls="item.join_info.users"
                    keyName="avatar"
                    size="30"
					          maxCount="5"
                    gap="0.4"
                  ></u-avatar-group>
                  <image
                    v-if="item.join_info.users.length > 0"
                    src="/static/index/dian.png"
                    style="width: 60rpx;height: 60rpx;margin-left:-20rpx;"
                  ></image>
                </span>
                <view class="number flex align-items" >
                  {{  Number(item.join_info.people_number)+"人已上车" }}
                </view>
              </view>
              <span v-if="item.status == 5" class="part1 flex justify-center align-items">
                已结束
              </span>
              <span v-if="item.status == 2" class="part flex justify-center align-items">
                上车
              </span>
              
            </view>
          </view>
        </view>
      </view>

      <!-- 全部标签 -->
			<u-popup :show="showPopbq" mode="bottom" round="20" :customStyle="{'width':'750rpx','height':'1304rpx'}" :closeable="true"
				@close="closebq">
				<view class="popup_bq">
					<img src="https://naweigetetest2.hschool.com.cn/dyqc/biaoqian.png" alt="" />
          <view class="flex flex-column w-100 bqlist">
              <span>我的标签</span>
              <view class="flex align-items bqpiece">
                <span>篮球</span>
                <u-icon name="close" color="#babdc7"></u-icon>
              </view>
              <span style="margin-top: 50rpx;">全部标签</span>
              <view class="flex align-items allbqs">
                <view class="flex align-items bqpiece" v-for="(item,index) in bqList" :key="index">
                  <span>{{ item.name }}</span>
                  <u-icon name="plus" color="#babdc7"></u-icon>
                </view>
              </view>
          </view>   

				</view>
			</u-popup>



      <u-loadmore style="margin-bottom: 120rpx;" :status="loadStatus" />
    </view>
    <tab-bar :tabBarShow="0"></tab-bar>
  </view>
</template>

<script>
import MySwiper from "@/components/fuyu-MixSwiper/fuyu-MixSwiper.vue";
import {
		dateWeek
	} from '../../utils/dateFormat'
export default {
  components: {
    MySwiper,
  },
  data() {
    return {
      showPopbq:false,//标签弹窗
      bqList:[],//标签列表
      loadStatus:'nomore',
      swiperList: [],
      teacherList: [],
      wqList: [],
      hotList: [],
      unread_number: "",
      keywords: "",
      count: 1,
      current: 0,
      autoplay: true,
      scrollTop: 0,
      dotsShow: true,
      videoList: [],
      currentItemType: "",
      tjShow: true,
      videoAutoplay: false,
      list: [
        {
          name: "全部",
        },
        {
          name: "篮球",
          url: "/static/index/lanqiu.png",
        },
        {
          name: "徒步",
          url: "/static/index/tubu.png",
        },
        {
          name: "羽毛球",
          url: "/static/index/tubu.png",
        },
        {
          name: "乒乓球",
          url: "/static/index/tubu.png",
        },
      ],
      show: false,
      // backgroundImage: 'https://testy.hschool.com.cn/uploads/20250219/4554df3bea7bd9cdbd75462ceedb8ea7.png',
      // backgroundImage: `url(@/static/index/beijing.png)`,
      // groupImage: 'https://testy.hschool.com.cn/uploads/20250219/5b09b1878ab6d7774540f0d1a8c6675a.png'
    };
  },
  onLoad() {
    uni.hideTabBar();
  },
  mounted() {
    this.videoContext = uni.createVideoContext("myVideo"); //创建视频实例指向video
  },
  onShow() {
    this.getinit();
    this.resetLists();
    this.getHotList();
    this.getBqList();
  },
  beforeDestroy() {
    this.autoplay = false;
  },
  computed: {
    // limitedList() {
    //   return this.items.slice(0, 3);
    // }
  },
  methods: {
    dateWeeks(e){
      return dateWeek(e);
    }, 
    closebq() {
      this.showPopbq = false
    },
    openBq() {
      this.showPopbq = true
    },
    // 获取胶囊高度
    // capsuleHeight() {
    //   if (uni?.getMenuButtonBoundingClientRect()) {
    //     return `${
    //       uni.getMenuButtonBoundingClientRect().height * 2 +
    //       uni.getMenuButtonBoundingClientRect().top * 2 +
    //       26
    //     }rpx`;
    //   } else {
    //     return `180rpx`; 
    //   }
    // },
    //底部翻页
    // onReachBottom() {
    //   if (this.hotList.length < this.count) {
		// 		this.page++;
		// 		this.getHotList();
		// 	}
		// },
    // 重置列表
    resetLists() {
      this.page = 1;
      this.hotList = [];
      this.loadStatus = "loading";
    },
    // 标签点击
    handleClick(index) {
      this.current = index;
      if (index == 0) {
        this.classes_type = "14,15,16,17";
      } else if (index == 1) {
        this.classes_type = "15";
      } else if (index == 2) {
        this.classes_type = "16";
      } else if (index == 3) {
        this.classes_type = "17";
      } else if (index == 3) {
        this.classes_type = "14";
      }
      this.hotList = [];
      this.getHotList();
    },
    // 搜索
    search() {
      if (this.keywords == "") {
        this.tjShow = true;
      } else {
        this.tjShow = false;
      }
      this.resetLists();
      this.getHotList();
    },

    //轮播图跳转
    click(e) {
      uni.navigateTo({
        url: e,
      });
    },

    // 获取首页信息
    getinit() {
      uni.$u.http
        .get("/api/index/init", {})
        .then((res) => {
          if (res.code == 1) {
            this.swiperList = res.data.home_data.top_images.list;
          } else {
            uni.showToast({
              title: res.msg,
              icon: "none",
              duration: 2000,
            });
          }
        })
        .catch((error) => {
          uni.showToast({
            title: "请求失败，请稍后再试",
            icon: "none",
            duration: 2000,
          });
        });
    },
 
    // 获取标签
    getBqList() {
      uni.$u.http
          .get("/api/school.new_activity/cate_list", {
          params: {
            page: 1,
            limit: 100
          },
        })
        .then((res) => {
          if (res.code == 1) {
						this.bqList = res.data.list;
          } else {
            uni.showToast({
              title: res.msg,
              icon: "none",
              duration: 2000,
            });
          }
        })
        .catch((error) => {
          uni.showToast({
            title: "请求失败，请稍后再试",
            icon: "none",
            duration: 2000,
          });
        });
    },
    // 获取热门活动
    getHotList() {
      let words = this.keywords
      uni.$u.http
          .get("/api/school.new_activity/activity_list", {
          params: {
            keywords:words,
            page: 1,
            limit: 6,
            order: "normal",
            status: "2,3,4" //5 已结束
          },
        })
        .then((res) => {
          if (res.code == 1) {
            // this.count = res.data.list.data.length
            // if(this.count){
            //   this.loadStatus = 'nomore';
            //   this.page++;
            // } else {
            //   this.loadStatus = 'loading';
            // }
            // this.hotList = [...this.hotList, ...res.data.list.data];
						this.hotList = res.data.list.data;
          } else {
            uni.showToast({
              title: res.msg,
              icon: "none",
              duration: 2000,
            });
          }
        })
        .catch((error) => {
          uni.showToast({
            title: "请求失败，请稍后再试",
            icon: "none",
            duration: 2000,
          });
        });
    },
    // 跳转详情
    detail(id) {
      uni.navigateTo({
        url: "/pages/center/detail?id=" + id,
      });
    },
    // 跳转往期详情
    Wqdetail(id) {
      uni.navigateTo({
        url: "/packageA/index/previousDetail?id=" + id,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.w-100 {
  width: 100%;
}

.flex {
  display: flex;
}

.justify-center {
  justify-content: center;
}

.space-between {
  justify-content: space-between;
}

.align-items {
  align-items: center;
}

.flex-column {
  flex-flow: column;
}

.justify-start {
  justify-content: start;
}

.mar-top-30 {
  margin-top: 30rpx;
}

.tab_all {
  margin-top: 30rpx;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;

  .allbq {
    width: 88rpx;
    height: 70rpx;
    background: #f7f7f7;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    right: 0;

    .imgs_all {
      width: 44rpx;
      height: 44rpx;
    }
  }

  .tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-right: 60rpx;

    /* 优化滚动效果 */
    .tab-item {
      display: flex;
      justify-content: center;
      align-items: center;
      flex: 0 0 auto;
      text-align: center;
      margin-right: 20rpx;
      position: relative;
      font-family: "YouSheBiaoTiHei";
      font-weight: 400;
      font-size: 34rpx;
      color: #9c9c9c;
      width: 180rpx;
      height: 70rpx;
      line-height: 70rpx;
      background: linear-gradient(180deg, #ffffff 44%, #f7f7f7 100%);
      border-radius: 48rpx 48rpx 48rpx 48rpx;

      .imgs_bq {
        width: 32rpx;
        height: 32rpx;
        margin-right: 10rpx;
      }
    }

    .tab-item.active {
      background: linear-gradient(
        360deg,
        rgba(196, 249, 119, 0) 0%,
        #bbfc5b 100%
      );
      font-size: 34rpx;
      color: #323232;
    }
  }
}

.recharge {
  width: 750rpx;
  background-color: #f7f7f7;
  background-image: url("https://naweigetetest2.hschool.com.cn/dyqc/bgx2.png");
  background-size: 750rpx 797rpx;

  .group {
    width: 690rpx;
    height: 152rpx;
    position: relative;

    .g-left {
      margin-left: 176rpx;

      span {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-size: 36rpx;
        color: #242623;
      }
    }

    .g-center {
      width: 176rpx;
      height: 64rpx;
      margin-left: 56rpx;
      background: #ffffff;
      border-radius: 40rpx 40rpx 40rpx 40rpx;
      font-family: Source Han Sans CN, Source Han Sans CN;
      font-weight: bold;
      font-size: 28rpx;
      color: #222222;
    }

    .g-right {
      position: absolute;
      width: 50rpx;
      height: 50rpx;
      top: 0;
      right: 0;
    }
  }

  .box {
    width: 690rpx;
    margin-top: 30rpx;

    .serch_top {
      margin-top: 10rpx;
      margin-bottom: 30rpx;
      position: relative;
      .searchBtn{
        position:absolute;
        width: 133rpx;
        height: 60rpx;
        background: #323232 ;
        border-radius: 30rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 26rpx;
        color: #FFFFFF;
        display: flex;
        justify-content: center;
        align-items: center;
        top: 0;
        right: 0;
		  }
    }

    .hot {
      //   margin-top: 30rpx;
      margin-bottom: 20rpx;

    }
  }

  .content {
    // height: 462rpx;
    // overflow-x: auto;
    /* 允许横向滚动 */
    // white-space: nowrap;

    width: 690rpx;

    .bbb {
      background: #ffffff;
      margin-top: 24rpx;
      border-radius: 36rpx;
    }

    .right {
      margin-left: 24rpx;
      width: 100%;

      .title {
        width: 95%;
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
        font-size: 30rpx;
        color: #323232;
      }
      .first-image {
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 24rpx;
        color: #9C9C9C ;

        span {
          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: 400;
          font-size: 26rpx;
          color: #222222;
        }
      }
      .row {
        margin: 10rpx 0 26rpx 0;

        .remen {
          // width: 136rpx;
          height: 40rpx;
          background: #ebfaf5;
          border-radius: 4rpx 4rpx 4rpx 4rpx;

          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: 400;
          font-size: 24rpx;
          color: #14bc84;
          line-height: 28rpx;
          padding: 2rpx 8rpx;
        }

        .line-colum {
          width: 1rpx;
          height: 32rpx;
          background: #7a7a7a;
          margin: 0 13rpx;
        }

        .name {
          width: 110rpx;
          height: 32rpx;
          font-family: PingFang SC, PingFang SC;
          font-weight: 500;
          font-size: 26rpx;
          color: #7a7a7a;
          line-height: 32rpx;
          margin-left: 12rpx;
        }
      }


      .jigou {
        width: 312rpx;
        // height: 32rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
        font-size: 26rpx;
        color: #7a7a7a;
        margin: 4rpx 0 14rpx 0;
      }

      .time {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 26rpx;
        color: #323232 ;
        line-height: 30rpx;
        
          .time_tex{
            width: 116rpx;
            height: 42rpx;
            background: #BBFC5B;
            border-radius: 159rpx;
            font-weight: 400;
            font-size: 24rpx;
            color: #323232;
            line-height: 42rpx;
            text-align: center;
          }
        
      }
      .imgs_con{
          width: 202rpx;
          height: 202rpx;
          margin-right: 20rpx;
          &:first-child{
            border-radius: 18rpx 0 0 18rpx;
         }
         &:last-child{
          border-radius: 0 18rpx 18rpx 0;
         }
      }

    }

    .bottom {
      margin: 32rpx 0 32rpx 24rpx;
      width: 626rpx;
      .toptext{
        width: 480rpx;
      }
      .number {
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: 400;
        font-size: 26rpx;
        color: #3D3D3D;
        line-height: 30rpx;
        width: 242rpx;
        margin-left: 20rpx;
      }

      .text {
        font-family: PingFang SC, PingFang SC;
        font-weight: 800;
        font-size: 26rpx;
        color: #7a7a7a;
      }

      .money {
        width: 150rpx;
        font-family: PingFang SC, PingFang SC;
        font-weight: 800;
        font-size: 36rpx;
        color: #ff2323;
        justify-content: flex-end;
      }
    }

    .ovr {
      width: 312rpx;
      background: #ffffff;
      border-radius: 20rpx 20rpx 20rpx 20rpx;
      margin-top: 18rpx;
      margin-right: 24rpx;
    }
  }

  .content-footer {
    width: 690rpx;
    justify-content: space-between;
    margin-top: 42rpx;

    .line-left,
    .line-right {
      width: 221rpx;
      height: 1rpx;
      background: #7a7a7a;
    }

    .line-text {
      font-family: PingFang SC, PingFang SC;
      font-weight: 800;
      font-size: 32rpx;
      color: #ff4023;
      margin-right: 8rpx;
    }
  }

  .con-center {
    width: 690rpx;
    height: 260rpx;
    background: #ffffff;
    border-radius: 16rpx;
    margin-top: 30rpx;

    .mask {
      margin: 32rpx;
    }

    .wq-right {
      margin-top: 32rpx;

      .title {
        width: 354rpx;
        height: 54rpx;
        font-family: Source Han Sans CN, Source Han Sans CN;
        font-weight: bold;
        font-size: 36rpx;
        color: #000000;
        line-height: 42rpx;
        text-align: left;
        font-style: normal;
        text-transform: none;
      }

      .hot {
        width: 230rpx;
        height: 48rpx;
        background: #fff1ed;
        border-radius: 4rpx 4rpx 4rpx 4rpx;
        margin-top: 8rpx;

        image {
          margin: 0 8rpx 0 16rpx;
        }

        span {
          min-width: 155rpx;
          height: 36rpx;
          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: 400;
          font-size: 24rpx;
          color: #ff4810;
        }
      }

      .length {
        width: 354rpx;
        height: 40rpx;
        margin-top: 24rpx;

        image {
          margin-right: 18rpx;
        }

        span {
          width: 318rpx;
          height: 40rpx;
          font-family: Source Han Sans CN, Source Han Sans CN;
          font-weight: 400;
          font-size: 26rpx;
          color: #a4a4a4;
          text-align: left;
          font-style: normal;
          text-transform: none;
        }
      }
    }
  }
}

.white-space {
  overflow: hidden;
  /* 确保超出容器的文本被隐藏 */
  white-space: nowrap;
  /* 确保文本在一行内显示 */
  text-overflow: ellipsis;
  /* 使用省略号表示被截断的文本 */
  width: 100%;
}










.pos {
  position: relative;

  .ab {
    position: absolute;
    right: 0%;
    bottom: 0%;
  }

  .m {
    width: 28rpx;
    height: 42rpx;
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: bold;
    font-size: 28rpx;
    color: #ff4810;
  }

  .money {
    width: 68rpx;
    font-family: D-DIN-PRO, D-DIN-PRO;
    font-weight: bold;
    font-size: 36rpx;
    color: #ff4810;
  }

  .no {
    width: 64rpx;
    height: 48rpx;
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: bold;
    font-size: 32rpx;
    color: #ff4810;
    line-height: 38rpx;
  }
}

.part {
  width: 180rpx;
  height: 70rpx;
  background: url(@/static/index/shangche.png);
  background-size: 168rpx 70rpx ;
  font-family: 'YouSheBiaoTiHei';
  font-weight: 400;
  font-size: 42rpx;
  color: #BBFC5B;
}
.part1{
  
  width: 180rpx;
  height: 70rpx;
  background: url(@/static/index/shangchew.png);
  background-size: 168rpx 70rpx ;
  font-family: 'YouSheBiaoTiHei';
  font-weight: 400;
  font-size: 42rpx;
  color: #9C9C9C;
}

.swiper-box {
  height: 580rpx;
  position: relative;
}
.popup_bq {
		display: flex;
		flex-direction: column;
		align-items: center;
    height: 1304rpx;
    position: relative;
		img {
      position: absolute;
			width: 750rpx;
			height: 1304rpx;
      top: -164rpx;
      z-index: 0;
		}
    .bqlist{
      margin-top: 160rpx;
      z-index: 1;
      margin-left: 80rpx;
      .allbqs{
        overflow: scroll;
          flex-wrap: wrap;
          height: 850rpx;
          width: 720rpx;
      }
      .bqpiece{
          width: 210rpx;
          height: 70rpx;
          background: #F7F7F7;
          border-radius: 12rpx 12rpx 12rpx 12rpx;
          display: flex;
          justify-content: space-around;
          align-items: center;
          margin: 20rpx 20rpx 20rpx 0;
          span{
            font-family: PingFang SC, PingFang SC;
            font-weight: 400;
            font-size: 26rpx;
            color: #323232;  
          }
        }
    }
   

	}
</style>
