| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 |
- <template>
- <view class="tab_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
- <up-navbar title=" " bgColor="transparent">
- <template #left>
- <view class="u-nav-slot" slot="left" style="display: flex;background-color: transparent;">
- <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/a5ad7f10-d625-4c9a-89f3-59f98c56dee8.png" style="width: 370rpx;height: 40rpx;"></image>
- </view>
- </template>
- </up-navbar>
- <image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/a7f990ec-1bff-4bd6-8b7f-fa61c0170d3b.png" class="top_bg_img" mode="widthFix"></image>
- <view class="c-box adffc">
- <view class="c-box-lunbo">
- <up-swiper
- :list="bannarList"
- @change="e => current = e.current"
- :autoplay="false"
- height="326rpx"
- >
- <template #indicator>
- <view class="indicator adf">
- <view class="indicator__dot" v-for="(item, index) in bannarList" :key="index"
- :class="[index === current && 'indicator__dot--active']">
- </view>
- </view>
- </template>
- </up-swiper>
- </view>
- <view class="c-box-title adfacjb">
- <view class="c-box-title-left">公益活动</view>
- <view class="c-box-title-right adfac" @tap="toTurnPage('/pagesHome/allActivity',false)">更多 <up-icon name="arrow-right" size="30rpx" style="margin-left: 10rpx;"></up-icon></view>
- </view>
- <view class="c-box-type">
- <scroll-view class="scroll-view_H" scroll-x="true" scroll-with-animation="true" :scroll-left="scrollLeft">
- <view class="scroll-view-item_H" :id="'svih_'+index" v-for="(item,index) in typeList" :key="index" @tap="changeType(item,index)">
- <view class="cl_item" :class="{'active':tlIndex===index}">
- <text>{{item.name}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="c-box-list" v-if="activityList.length">
- <template v-for="item in activityList" :key="item.id">
- <NonprofitActivety :item="item"></NonprofitActivety>
- </template>
- </view>
- <view class="dataEmpty" v-else>
- <page-empty text="暂无公益活动"></page-empty>
- </view>
- </view>
- <login-register></login-register>
- <CusTabbar :tabbarIndex="0"></CusTabbar>
- </view>
- </template>
- <script setup name="">
- import CusTabbar from '@/components/CusTabbar/index.vue'
- import NonprofitActivety from '@/components/pages/nonprofitActivety/index.vue'
- import PageEmpty from '@/components/pageEmpty/index.vue'
- import { ref, getCurrentInstance, onMounted } from 'vue'
- const { proxy } = getCurrentInstance()
-
- const bannarList = ref([])
- const bannarOrigin = ref([])
- const current = ref(0)
- const typeList = ref([])
- const tlIndex = ref(0)
- const scrollLeft = ref(0)
- const activityList = ref([])
-
- const changeType = (item,index) => {
- tlIndex.value = index;
- if(typeList.value.length>4){
- if(index<3) scrollLeft.value = 0
- else{
- scrollLeft.value = (index-2)*172/2;
- }
- }
- getActivityList(item.id)
- }
-
- const toTurnPage = (url,needLogin) => {
- if(!needLogin){
- uni.navigateTo({ url })
- }
- }
-
- const getSwiperList = () => {
- proxy.$api.get('/core/advertisement/manage/page',{page:1,limit:-1}).then(({data:res})=>{
- if(res.code!==0) return proxy.$showToast(res.msg)
- bannarOrigin.value = res.data.list;
- bannarList.value = res.data.list.map(l=>l.fileUrl);
- })
- }
-
- const getTypeList = () => {
- proxy.$api.get('/core/activity/category/list').then(({data:res})=>{
- if(res.code!==0) return proxy.$showToast(res.msg)
- typeList.value = [{id:'',name:'全部'},...res.data.map(d=>({id:d.id,name:d.categoryName}))];
- })
- }
-
- const getActivityList = (categoryId) => {
- proxy.$api.get('/core/activity/page',{page:1,limit:2,categoryId}).then(({data:res})=>{
- if(res.code!==0) return proxy.$showToast(res.msg)
- activityList.value = res.data.list;
- activityList.value.forEach(a=>{
- let cc = calculateCountdown(a?.signupEndTime);
- a.endTimeText = cc===-1?a?.signupEndTime:(`还有${cc.days}天${cc.hours}小时${cc.minutes}分钟`)
- })
- })
- }
-
- const calculateCountdown = (datetime) => {
- if(!datetime) return -1;
-
- const targetDate = new Date(datetime);
- const now = new Date();
- const difference = targetDate.getTime() - now.getTime();
- if (difference <= 0) return -1;
-
- const days = Math.floor(difference / (1000 * 60 * 60 * 24));
- const hours = Math.floor((difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
- const minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60));
- return {
- days,
- hours,
- minutes
- };
- }
-
- onMounted(()=>{
- getSwiperList()
- getTypeList()
- getActivityList('')
- })
- </script>
- <style scoped lang="scss">
- ::v-deep .indicator__dot{
- width: 48rpx;
- height: 4rpx;
- background: #E2E5E9;
- border-radius: 2rpx;
- margin: 0 8rpx;
- }
- ::v-deep .indicator__dot--active{
- width: 48rpx;
- height: 4rpx;
- background: #00AE57;
- border-radius: 2rpx;
- }
-
- .scroll-view_H {
- white-space: nowrap;
- width: 100%;
- }
-
- .scroll-view-item_H {
- display: inline-block;
- width: 152rpx;
- height: 100%;
- margin-left: 20rpx;
- &:first-child{
- margin-left: 0;
- }
- }
-
- .tab_page{
- .c-box{
- width: 100%;
- height: 100%;
- overflow-y: auto;
- position: relative;
- &-lunbo{
- width: 100%;
- height: 326rpx;
- margin-top: 20rpx;
- }
- &-title{
- margin-top: 58rpx;
- &-left{
- width: 170rpx;
- height: 44rpx;
- padding-left: 2rpx;
- font-family: PingFang-SC, PingFang-SC;
- font-weight: 800;
- font-size: 36rpx;
- color: #151B29;
- line-height: 36rpx;
- background-image: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/11/6ec1f999-fcbb-4a0b-a1a5-d0b5e1374bb1.png');
- background-size: 170rpx 31rpx;
- background-position: 0 20rpx;
- background-repeat: no-repeat;
- }
- &-right{
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 28rpx;
- color: #676775;
- line-height: 33rpx;
- }
- }
- &-type{
- width: 100%;
- height: 68rpx;
- margin-top: 31rpx;
- .cl_item{
- width: 152rpx;
- height: 68rpx;
- background: #FFFFFF;
- border-radius: 34rpx;
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 28rpx;
- color: #676775;
- line-height: 68rpx;
- text-align: center;
- &.active{
- background: #B7F358;
- font-weight: bold;
- font-size: 30rpx;
- color: #151B29;
- }
- }
- }
- &-list{
- width: 100%;
- flex: 1;
- overflow-y: auto;
- }
- }
- }
- </style>
|