123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <template>
- <view class="seckill-section m-t" v-if="show">
- <view class="s-header">
- <view class="f-left-icon"></view>
- <view class="tit-box"><text class="tit">限时秒杀</text></view>
- <view class="tip-box">
- <text class="tip" v-if="status == 1">{{ showTime }}点场结束</text>
- <text class="tip" v-if="status == 2">距离下场开始</text>
- <text class="tip" v-if="status == 0">当天活动已结束</text>
- <uni-countdown v-if="status == 1 || status == 2" :show-day="false" :hour="stopTimeH" :minute="stopTimeM" :second="stopTimeS"></uni-countdown>
- </view>
- <view class="textNav iconfont iconenter" @click="navTo('/pages/product/seckill')">更多</view>
- </view>
- <scroll-view class="floor-list" scroll-x>
- <view class="scoll-wrapper position-relative" @click="navTo('/pages/product/seckill')">
- <view v-for="(item, index) in list" :key="index" class="floor-item">
- <image class="list-image" :src="item.image" mode="aspectFill"></image>
- <text class="title clamp">{{ item.title }}</text>
- <text class="price">¥{{ item.price }}</text>
- </view>
- <view v-if="list.length == 0" class="floor-item ">
- <image class="list-image" mode="aspectFill"></image>
- <text class="title clamp"></text>
- <text class="price"></text>
- </view>
- <view v-if="list.length == 0" class="noGoodsBg"><view>敬请期待</view></view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
- import { getSeckillList, getSeckillClass } from '@/api/product.js';
- import { timeComputed } from '@/utils/rocessor.js';
- export default {
- components: {
- uniCountdown
- },
- data() {
- return {
- list: [],
- page: 1,
- limit: 10,
- showTime: '',
- showTImeId: '',
- stopTimeH: 0,
- stopTimeM: 0,
- stopTimeS: 0,
-
- stop: false,
- show: false,
- status: 0
- };
- },
- created: function(e) {
-
- this.getClass();
- },
- methods: {
- navTo(url) {
- uni.navigateTo({
- url
- });
- },
- getList() {
- getSeckillList(
- {
- page: this.page,
- limit: this.limit
- },
- this.showTImeId
- )
- .then(e => {
- this.list = e.data;
- })
- .catch(e => {
- console.log(e);
- });
- },
- getClass() {
- let obj = this;
- getSeckillClass({})
- .then(({ data }) => {
- let arr = data.seckillTime;
-
- let showDate = false;
- for (var i = 0; i < arr.length; i++) {
- let ar = arr[i];
- if (ar.status === 1 || ar.status === 2) {
- obj.status = ar.status;
-
- obj.showTime = ar.time;
-
- obj.showTImeId = ar.id;
-
-
- if (ar.status === 1) {
- obj.timeComputed(ar.stop * 1000);
- } else {
-
- let arTime = ar.time.split(':');
- let h = arTime[0];
- let m = arTime[1];
- let time = new Date();
-
- time.setHours(h, m, 0);
- obj.timeComputed(time.getTime());
- }
-
- obj.getList();
-
- showDate = true;
-
- break;
- }
- }
-
- if (arr.length > 0) {
- obj.show = true;
- }
-
- if (!showDate) {
-
- obj.showTImeId = arr[arr.length - 1].id;
-
- obj.status = 0;
-
- obj.getList();
- console.log(obj.status);
- }
-
- })
- .catch(e => {
- uni.showModal({
- title: JSON.stringify(e)
- });
- });
- },
-
- timeComputed(da) {
- let obj = this;
- let stopTime = timeComputed(da)
- obj.stopTimeH =stopTime.hours;
- obj.stopTimeM = stopTime.minutes;
- obj.stopTimeS =stopTime.seconds;
- }
- }
- };
- </script>
- <style lang="scss">
- /* 秒杀专区 */
- .seckill-section {
- padding: 4rpx 30rpx 24rpx;
- .s-header {
- display: flex;
- align-items: center;
- height: 92rpx;
- line-height: 1;
- .tit-box {
- flex-shrink: 0;
- }
- .tit {
- @extend %font-title;
- }
- .f-left-icon {
- @extend %f-left-icon;
- }
- .textNav {
- line-height: 1;
- padding: 15rpx 0;
- flex-shrink: 0;
- flex-grow: 1;
- min-width: 100rpx;
- }
- .tip-box {
- flex-grow: 1;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- }
- .tip {
- font-size: $font-sm;
- color: $font-color-light;
- padding-left: 10rpx;
- padding-right: 10rpx;
- }
- .timer {
- display: inline-block;
- width: 40rpx;
- height: 36rpx;
- text-align: center;
- line-height: 36rpx;
- margin-right: 14rpx;
- font-size: $font-sm + 2rpx;
- color: #fff;
- border-radius: 2px;
- background: rgba(0, 0, 0, 0.8);
- }
- .iconenter {
- font-size: $font-sm;
- color: $font-color-light;
- flex: 1;
- text-align: right;
- }
- }
- .floor-list {
- white-space: nowrap;
- background-color: white;
- padding: 20rpx;
- border-radius: 5rpx;
- box-shadow: $box-shadow;
- }
- .scoll-wrapper {
- display: flex;
- align-items: flex-start;
- .noGoodsBg {
- display: flex;
- align-items: center;
- justify-content: center;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- color: $font-color-light;
- }
- .floor-item {
- width: 150rpx;
- margin-right: 20rpx;
- font-size: $font-sm + 2rpx;
- color: $font-color-dark;
- line-height: 1.8;
- .list-image {
- width: 150rpx;
- height: 150rpx;
- border-radius: 6rpx;
- }
- .price {
- color: $color-red;
- }
- }
- }
- }
- </style>
|