<template class="content">
    <view  class="fixed-header"> 
        
        <!-- 顶部导航栏 -->
        <up-navbar leftText="" title="" :placeholder="true" :safeAreaInsetTop="true" :bgColor="bgColor">
            <template class="img1BOX" #left>
                <view class="leftinfo">
                    <span class="lefttext">时间</span>
                    <image
                        style=" margin-left: 10rpx;  transform: rotate(-45deg); /* 旋转45度 */ width: 15rpx; height: 15rpx;"
                        :src="tu21"></image>
                </view>
            </template>
            <template #center>
                <div class="navbarcenter"><span>热门活动</span></div>
            </template>
        </up-navbar>
        <view class="bgc"></view>
        <!-- 搜索栏 -->
        <view class="sousuoBox1 flex alignCenter justifyBetween">
            <view class="sousuoBox flex alignCenter justifyBetween" @click="toEarch">
                <view class="souBOx flex alignCenter">
                    <image :src="tu22" class="img3"></image>
                    <span class="shuruText">电音节节日活动</span>
                </view>
            </view>
        </view>
        <!-- tabs标签 -->
        <view class="tabsinfo flex alignCenter justifyCenter">
            <up-tabs :list="list4" lineWidth="24" lineHeight="4" lineColor="#B3D7FF" :activeStyle="{
            color: '#000000',
            fontSize: '30rpx',
            transform: 'scale(1.05)'
        }" :inactiveStyle="{
            color: '#999999',
            fontSize: '28rpx',
            transform: 'scale(1.05)'
        }" itemStyle="  width: 200rpx; padding-bottom:18rpx;">
            </up-tabs>
        </view>
    </view>
        <!-- 列表信息 -->
        <view class="scrollable-list">
            <up-list @scrolltolower="scrolltolower" :showScrollbar="false" :pagingEnabled="true">
                <up-list-item v-for="(item, index) in actiInfoList" :key="index">
                    <view class="listInfo">
                        <span class="titile">
                            {{ item.title }}
                        </span>
                        <view class="startTime">开始时间：{{ item.startTime }}</view>
                        <view class="endTime">结束时间：{{ item.endTime }}</view>
                        <view class="addrs">活动地点：{{ item.addrs }}</view>
                        <view class="statsInfo">
                            <view :class="getDictLabelByValue(item.state).cssClass"  >
                            <span class="text">{{ getDictLabelByValue(item.state).dictLabel }}</span>
                        </view>
                        </view>

                    </view>

                </up-list-item>
            </up-list>
        </view>

    
    <view>
    </view>
</template>
<script setup>
import { onShow, onLoad } from '@dcloudio/uni-app'


import {getDicts} from "@/api/system/dict/data"
import { ref, reactive, getCurrentInstance } from 'vue'
import { useStore } from 'vuex';
const { proxy } = getCurrentInstance();
const iconConfig =  proxy.iconConfig;
const tu21 = iconConfig.tu21;
const tu22 = iconConfig.tu22;
const activityState = ref([])//字典
const imgInfo = ref("")
// 创建响应式数据  ref('#001f3f')
const bgColor = ref('');
bgColor.value = 'rgba(170, 0, 0, 0)'
const store = useStore()
const list4 = reactive([  
    { name: '全部' },  
    { name: '未开始'},  
    { name: '进行中' },  
    { name: '已结束' } 
]); 
const actiInfoList = ref([
   {title:'怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法？',
   startTime:'2023-05-01 15:00',
   endTime:'2023-05-01 16:00',
   state:'1',
   addrs:'天津电子信息职业技术学院操场东面'
   },
   {title:'怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法？',
   startTime:'2023-05-01 15:00',
   endTime:'2023-05-01 16:00',
   state:'2',
   addrs:'天津电子信息职业技术学院操场东面'
   },
   {title:'怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法？',
   startTime:'2023-05-01 15:00',
   endTime:'2023-05-01 16:00',
   state:'0',
   addrs:'天津电子信息职业技术学院操场东面'
   }
   ,
   {title:'怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法？',
   startTime:'2023-05-01 15:00',
   endTime:'2023-05-01 16:00',
   state:'0',
   addrs:'天津电子信息职业技术学院操场东面'
   }

]); 

onLoad((options) => {
    getDicts('activity_state').then( e=> {
        activityState.value=e.data
        console.log(activityState.value);
    })
})

onShow(() => {
  console.log('Page onShow')
})

const scrolltolower = () => {
    console.log("scrolltolower");
    actiInfoList.value.push( {title:'怎么评论爱德华·艾尔加这位音乐家及其他的作品,欢迎大家发表自己的看法？',
   startTime:'2023-05-01 15:00',
   endTime:'2023-05-01 16:00',
   state:'2',
   addrs:'天津电子信息职业技术学院操场东面'
   })
};
const getDictLabelByValue = (state) => {
  const dict = activityState.value.find((dict) => dict.dictValue === state);
  return dict ? dict : '未知状态';
};

</script>
<style lang="scss">
  .fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: -1; /* 足够高以确保它在上层 */
  }
  .scrollable-list {
    margin-top:22vh; /* fixed-header 的高度 */
    height:78vh ;/* 根据屏幕高度和fixed-header的高度计算 */
    overflow: auto; /* 允许这个容器内部滚动 */
  }

    .leftinfo{
        display: flex;
    align-items: flex-end;
    }
.content {
    position: relative;

    .img1BOX {
        padding-left: 32rpx;
        display: flex;
        align-content: center;
            .lefttext {
            font-weight: 400;
            width: 58rpx;
            height: 30rpx;
            font-size: 30rpx;
            text-align: left;
            color: #000000 100%;
        }

    }

}
.img2BOX{
    display: flex;
    align-items: center;

}
.navbarcenter {
    font-weight: 400;
width: 146rpx;
height: 36rpx;
font-size: 36rpx;
text-align: left;
color: #000000 100%;
display: flex;
align-items: center;
}
.bgc {
    width: 750rpx;
    height: 500rpx;
    background: linear-gradient(180deg, rgb(201, 246, 245), rgb(248, 248, 226));
    position: fixed;
    top: 0rpx;
    left: 0rpx;
    z-index: -1;
}

.sousuoBox1 {
    margin: 10rpx 32rpx;
    width: auto;
}

.sousuoBox {
    width: 684rpx;
    height: 68rpx;
    border: #B3D7FF solid 2rpx;
    border-radius: 30rpx 30rpx 30rpx 30rpx;
    background: #ffffff80;
}

.souBOx {
    margin-left: 32rpx;
}
.sousuoBox .souBOx .shuruText {
    font-weight: 400;
    font-size: 28rpx;
    text-align: center;
    color: #999999 100%;
    margin-left: 20rpx;
}
.img3 {
    width: 38rpx;
    height: 38rpx;
}
.tabsinfo {
    width: 686rpx;
    height: 80rpx;
    margin: 0 auto;
}
.listInfo {
    position: relative;
    width: 686rpx;
    height: 328rpx;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    background: #ffffff;
    margin: 0 auto;
    margin-top: 12rpx;
    margin-bottom: 12rpx;
    padding-top: 24rpx;
    padding-left: 24rpx;
    .titile {
            font-weight: 400;
            width: 614rpx;
            height: 80rpx;
            font-size: 32rpx;
            color: #000000 100%;
        }
        .startTime {
            margin-top: 34rpx;
            font-weight: 400;
            width: 350rpx;
            height: 24rpx;
            font-size: 24rpx;
            color: #000000 100%;
        }
        .endTime {
            margin-top: 12rpx;
            font-weight: 400;
            width: 350rpx;
            height: 24rpx;
            font-size: 24rpx;
            color: #000000 100%;
        }
        .addrs {
            margin-top: 24rpx;
            font-weight: 400;
            width: 504rpx;
            height: 24rpx;
            font-size: 24rpx;
            color: #000000 100%;
        }
}
.statsInfo{
    position: absolute;
    right: 24rpx;
    bottom: 24rpx;
}

.state0 {
    width: 84rpx;
    height: 28rpx;
    border-radius: 14rpx 14rpx 14rpx 14rpx;
    background: #f1f1f1;
    display: flex;
    justify-content: center;
    align-content: center;

    .text {
        font-weight: 400;
        width: 60rpx;
        height: 20rpx;
        font-size: 20rpx;
        text-align: center;
        color: #7E7E7E;
    }
}

.state1 {
    width: 84rpx;
    height: 28rpx;
    border-radius: 14rpx 14rpx 14rpx 14rpx;
    background: #c0f0ec;
    display: flex;
    justify-content: center;
    align-content: center;

    .text {
        font-weight: 400;
        width: 60rpx;
        height: 20rpx;
        font-size: 20rpx;
        text-align: center;
        color: #00CCBE;
    }
}
.state2 {
    width: 84rpx;
    height: 28rpx;
    border-radius: 14rpx 14rpx 14rpx 14rpx;
    background: #fde2e2;
    display: flex;
    justify-content: center;
    align-content: center;

    .text {
        font-weight: 400;
        width: 60rpx;
        height: 20rpx;
        font-size: 20rpx;
        text-align: center;
        color: #FFABAB;
    }
}
</style>