| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <template>
- <view
- class="seckill u-skeleton-fillet"
- v-if="(currSeckill && currSeckill.length > 0) || skeletonShow"
- >
- <view class="seckill-item">
- <view
- class="seckill-top"
- @click="goDetail('/pages/seckill/list')"
- >
- <view class="left">限时秒杀</view>
- <view class="line" v-if="currTime"></view>
- <view class="time" v-if="currTime">{{ currTime }}点场 剩余</view>
- <view class="reciprocal" v-if="currTime">
- <!-- <uni-countdown
- :time="finishTime"
- :backgroundColor="'none'"
- :color="'#fff'"
- :splitorColor="'#fff'"
- :show-day="time2[0] > 0"
- :day="time2[0]"
- :hour="time2[1]"
- :minute="time2[2]"
- :second="time2[3]"
- >
- </uni-countdown> -->
- <uv-count-down :time="finishTime" format="HH:mm:ss"></uv-count-down>
- </view>
- </view>
- <view
- class="option"
- v-if="(currSeckill && currSeckill.length > 0) || skeletonShow"
- >
- <swiper
- :indicator-dots="false"
- :autoplay="false"
- :display-multiple-items="itemsDis2"
- @change="imgActiveFun2"
- style="height: 220rpx"
- circular="true"
- >
- <swiper-item v-for="(item, key) in currSeckill" :key="key">
- <div class="fa-item">
- <view
- class="option-item"
- v-for="itemSon in item"
- @click="
- goProductDetails(
- '/pages/seckill/seckillGoods?id=' + itemSon.id
- )
- "
- :key="itemSon.id"
- >
- <!-- ?x-oss-process=style/w_350 -->
- <image
- v-if="itemSon && itemSon.coverImage"
- :src="`${itemSon.coverImage}`"
- mode="aspectFill"
- >
- </image>
- <view class="number">
- <rich-text
- :nodes="$mUtil.priceBigSmall(itemSon.minPrice)"
- ></rich-text>
- </view>
- </view>
- </div>
- </swiper-item>
- </swiper>
- <view class="slide-box">
- <view class="dotBox" v-if="currSeckill.length > 1">
- <view
- class="dotBox_item"
- v-for="(v, i) in currSeckill"
- :key="i"
- :class="{ active_dotBox: activeBannerIndex2 == i }"
- ></view>
- </view>
- </view>
- </view>
- <noData v-else :config="{ top: 1, content: '暂无商品~' }"></noData>
- </view>
- </view>
- </template>
- <script setup>
- import { ref } from "vue";
- import { seckillActivityProductFlash_Api } from "@/api/seckill.js";
- const props = defineProps({
- skeletonShow: {
- type: Boolean,
- default: false
- }
- });
- const emit = defineEmits(['goDetail', 'overDown2', 'imgActiveFun2', 'goProductDetails']);
- const currSeckill = ref([]); //秒杀
- const currTime = ref(null);
- const finishTime = ref(null);
- const itemsDis2 = ref(1);
- const activeBannerIndex2 = ref(0);
- const goDetail = (url) => {
- emit('goDetail', url);
- };
- const imgActiveFun2 = (e) => {
- activeBannerIndex2.value = e.detail.current;
- };
- const goProductDetails = (url) => {
- emit('goProductDetails', url);
- };
- const oneArrToTwoArr = (data) => {
- let newData = [];
- let zyf = 4; //一维数组转二维数组长度(此处是二维数组每一个长度控制)
- for (var i = 0; i < Math.ceil(data.length / zyf); i++) {
- newData[i] = [];
- newData[i].push(data[i * zyf]);
- for (var j = 1; j < zyf; j++) {
- if (data[i * zyf + j] == undefined) {
- //超出长度控住
- return newData;
- } else {
- newData[i].push(data[i * zyf + j]);
- }
- }
- }
- return newData;
- };
- /**限时秒杀 */
- const getSeckillList = () => {
- seckillActivityProductFlash_Api({ limit: 10 }).then((res) => {
- if (res && res.code == 200) {
- currTime.value = res.data.startHour;
- if (res.data.list) {
- currSeckill.value = oneArrToTwoArr(res.data.list);
- }
- if (res.data.finishTime) {
- finishTime.value = res.data.finishTime - new Date().getTime();
- }
- }
- });
- };
- getSeckillList();
- defineExpose({
- getSeckillList
- });
- </script>
- <style scoped lang="scss">
- .seckill {
- margin: 30rpx 30rpx 50rpx;
- border-radius: 10rpx;
- overflow: hidden;
- .seckill-item {
- border-radius: 16rpx;
- background-color: #ffffff;
- padding-bottom: 26rpx;
- .option {
- position: relative;
- margin-top: 20rpx;
- padding: 0 29rpx;
- .fa-item {
- display: flex;
- }
- .option-item:first-child {
- margin-left: 0;
- }
- .option-item {
- margin-left: 24rpx;
- image {
- width: 140rpx;
- height: 140rpx;
- }
- .number {
- margin-top: 4rpx;
- text-align: center;
- font-size: 36rpx;
- font-weight: Bold;
- line-height: 24rpx;
- color: #333333;
- width: 140rpx;
- }
- }
- }
- .seckill-top {
- padding: 24rpx 26rpx;
- display: flex;
- align-items: center;
- border-bottom: 1rpx solid #f7f7f7;
- background: linear-gradient(180deg, #d4ecdf, rgba(204, 235, 217, 0));
- .left {
- font-size: 36rpx;
- font-weight: Bold;
- color: #1a1a1a;
- margin-right: 14rpx;
- }
- .line {
- width: 1rpx;
- height: 32rpx;
- background-color: #707070;
- }
- .time {
- margin-left: 16rpx;
- color: #666666;
- font-size: 24rpx;
- font-weight: Regular;
- }
- .reciprocal {
- color: #ffffff;
- padding: 0rpx 14rpx;
- background-color: #ff0000;
- font-size: 24rpx;
- font-weight: Bold;
- border-radius: 30rpx;
- margin-left: 30rpx;
- &:deep(.uv-count-down__text) {
- color: #ffffff;
- font-size: 24rpx;
- }
- }
- }
- }
- }
- .slide-box {
- display: flex;
- justify-content: center;
- }
- .dotBox {
- height: 14rpx;
- overflow: hidden;
- border-radius: 14rpx;
- background-color: #ededed;
- display: flex;
- justify-content: center;
- .dotBox_item {
- width: 45rpx;
- height: 14rpx;
- border-radius: 2rpx;
- background-color: #ededed;
- transition: all 0.5s;
- }
- .active_dotBox {
- width: 45rpx;
- background: linear-gradient(109deg, #fb6b3e 20%, #feaf6b 85%);
- transition: all 0.5s;
- }
- }
- </style>
|