Files

118 lines
3.0 KiB
Vue
Raw Normal View History

2023-11-14 17:21:03 +08:00
<template>
<layout>
<uv-sticky customNavHeight="0">
<uv-navbar
:fixed="false"
:safeAreaInsetTop="true"
autoBack
title="折扣专区"
/>
</uv-sticky>
2023-11-14 17:21:03 +08:00
<view class="swiper">
<image class="image" :src="discountBg" mode="widthFix" />
2023-11-14 17:21:03 +08:00
</view>
<view class="time-bar">
<div class="time-bar-item" v-for="(item,index) in timesList" :key="index" :class="activeIndex === index && 'on'" @tap="timeChange(item,index)">
<div class="time">{{item.time}}</div>
<div class="status">
<text v-if="item.status === 0">已结束</text>
<text v-if="item.status === 1">抢购中</text>
<text v-if="item.status === 2">未开始</text>
</div>
<div
class="countdown"
v-if="item.status === 1"
>
<text>已结束</text>
<uv-count-down :time="item.countdown" format="HH:mm:ss" @finish="countDownFinish"></uv-count-down>
</div>
</div>
</view>
<view
class="product-box"
v-if="!listEmpty"
>
<template
v-for="(item,index) in dataList"
:key="item.id"
>
<view class="product-item" :class="index === 0 && 'isFirst'">
2023-11-14 17:21:03 +08:00
<goods
link
:hasFirst="index === 0"
:data="item"
:price="item.price"
:buyProgress="index === 0"
:original="true"
:total="index !== 0"
2023-11-14 17:21:03 +08:00
>
</goods>
</view>
</template>
</view>
<Empty
v-else
:iconSrc="emptyCollectIcon"
>
这里空空如也~
</Empty>
<!-- 加载中 -->
<ListLoadLoading v-if="loading" />
<!-- 加载完毕-->
<ListLoadOver v-if="loadend" />
2023-11-14 17:21:03 +08:00
</layout>
</template>
2023-11-14 17:21:03 +08:00
<script setup>
import { computed, ref } from 'vue'
import {getActivityProList, getProductList} from '@/api/product'
import { onLoad } from '@dcloudio/uni-app'
import { useActivity } from '@/hooks/useActivity'
import ListLoadOver from "@/components/ListLoadOver/index.vue";
import ListLoadLoading from "@/components/ListLoadLoading/index.vue";
import {emptyCollectIcon} from "@/utils/images";
import Empty from "@/components/Empty/index.vue";
2023-11-22 18:55:55 +08:00
import { discountBg } from "@/utils/images";
import LazyImage from '@/components/LazyImage/index.vue'
2023-11-14 17:21:03 +08:00
const { refresh, dataList, loading, loadend, listEmpty, otherQuery, activeIndex, timesList, timeChange, countDownFinish, handleGetTimeList} = useActivity(getActivityProList)
onLoad(async (option) => {
otherQuery.value = {
type:3
}
await handleGetTimeList()
})
2023-11-14 17:21:03 +08:00
</script>
<style lang="scss">
.swiper {
width: 100%;
.image {
width: 100%;
display: block;
}
}
.product-box {
width: 100%;
padding: 30rpx;
box-sizing: border-box;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.product-item {
background: #FFFFFF;
width: calc((100% - 20rpx) / 2);
margin-bottom: 20rpx;
border-radius: 15rpx;
&.isFirst{
width: 100%;
}
}
2023-11-14 17:21:03 +08:00
}
</style>