quanwei
2025-10-31 f226d5fe6327e31bb471a96b7370cf94689c6608
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<template>
    <view class="seckill-product-wrap"  :data-theme='theme()' :class="theme() || ''">
        <!--活动广告-->
        <view class="top-box">
            <!--活动类别-->
            <view class="active-top-tab">
                <scroll-view scroll-X="true" show-scrollbar="false" class="scroll-X  mb30">
                    <view class="tab-list d-s-c">
                        <view class="tab-item" :class="{ active: type_active == index }" v-for="(item, index) in activeList" :key="index" @click="tabTypeFunc(index)">
                            {{ item.title }}
                        </view>
                    </view>
                </scroll-view>
                <view class="ad-activity" v-if="listData.detail"><image :src="listData.detail.file_path" mode=""></image></view>
                <!--活动时间-->
                <view class="ad-datetime ww100 pt40 pb10 d-c-c" v-if="listData.detail">
                    <Countdown ref="countdown" :config="countdownConfig" @returnVal="returnValFunc"></Countdown>
                </view>
                <view class="every-day-time d-c-c mb20" v-if="listData.list.length > 0">
                    <text>每日活动时间:{{ currActive.day_start_time }}至{{ currActive.day_end_time }}</text>
                </view>
                <view v-else class="p30 pt200 d-c-c d-c gray6 f26">
                    <image style="width: 532rpx;margin-bottom: 80rpx;" src="/static/active-null.png" mode="widthFix"></image>
                    <view class="tc gray9">暂无活动~~</view>
                </view>
            </view>
        </view>
        <view class="seckill-list-wrap" v-if="!loading">
            <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50">
                <!--列表-->
                <view class="list p-0-20">
                    <view class="item d-stretch" v-for="(item, index) in listData.list" :key="index">
                        <view class="product-cover"><image :src="item.product.file_path" mode="aspectFit"></image></view>
                        <view class="d-b-c d-c flex-1 ml26">
                            <view class="product-title ww100">{{ item.product.product_name }}</view>
                            <view class="price ww100 red">
                                <text class="f24">秒杀价:¥</text>
                                <text class="num f36 fb">{{ item.seckill_price }}</text>
                                <text class="ml20 text-d-line gray9 f24">¥{{ item.product_price }}</text>
                            </view>
                            <view class="slider-box ww100 d-b-c">
                                <view class="left flex-1">
                                    <text class="already-sale">已抢购{{ item.product_sales }}件</text>
                                    <view class="slider">
                                        <view class="slider-inner" :style="'width:' + (item.product_sales / (item.product_sales + item.stock)) * 100 + '%;'"></view>
                                    </view>
                                </view>
                                <view class="right-btn ml30">
                                    <button v-if="status == 0 && item.stock > 0" type="primary" @click="gotoDetail(item.product_id)">马上抢</button>
                                    <button v-if="status == 1 && item.stock > 0" type="default" class="btn-gray">未开始</button>
                                    <button v-if="status == 2 && item.stock > 0" type="default" class="btn-gray">已结束</button>
                                    <button v-if="item.stock == 0" type="default" class="btn-gray">已抢光</button>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
                <!-- 没有记录 -->
                <view class="d-c-c p30" v-if="listData.list.length == 0 && !loading">
                    <text class="iconfont icon-wushuju"></text>
                    <text class="cont">亲,暂无相关记录哦</text>
                </view>
            </scroll-view>
        </view>
    </view>
</template>
 
<script>
    import Countdown from '@/components/countdown/countdown.vue';
    export default {
        components: {
            Countdown
        },
        data() {
            return {
                /*手机高度*/
                phoneHeight: 0,
                /*可滚动视图区域高度*/
                scrollviewHigh: 0,
                /*活动列表*/
                activeList: [],
                /*当前活动角标*/
                type_active: 0,
                /*类别选中*/
                currActive: {},
                /*产品列表*/
                listData: {
                    list:[],
                detail: null
                },
                /*活动详情*/
                detailData: {},
                /*是否正在加载*/
                loading: true,
                /*倒计时配置*/
                countdownConfig: {
                    /*开始时间*/
                    startstamp: 0,
                    /*结束时间*/
                    endstamp: 0
                },
                status: -1, //1未开始 2已过期 0进行中
            };
        },
        computed: {},
        onShow() {
            this.type_active = 0;
            this.getActive();
        },
        mounted() {
            this.init();
 
        },
        onPullDownRefresh() {},
        methods: {
            /*初始化*/
            init() {
                let _this = this;
                uni.getSystemInfo({
                    success(res) {
                        _this.phoneHeight = res.windowHeight;
                        // 计算组件的高度
                        let view = uni.createSelectorQuery().select('.top-box');
                        view.boundingClientRect(data => {
                            let h = _this.phoneHeight - data.height + 43;
                            _this.scrollviewHigh = h;
                        }).exec();
                    }
                });
            },
 
            /*类别切换*/
            tabTypeFunc(e) {
                this.type_active = e;
                this.currActive = this.activeList[e];
                this.listData = [];
                this.status = -1;
                this.getData();
            },
            goback() {
                uni.navigateBack({
 
                })
            },
            /*获取活动类别*/
            getActive() {
                let self = this;
                let param = {};
                self.loading = true;
                self._get(
                    'plus.seckill.product/active', {
                        param
                    },
                    function(res) {
                        self.activeList = res.data.list;
                        if (self.activeList && self.activeList.length > 0) {
                            self.currActive = self.activeList[0];
                            self.getData();
                        }
                    }
                );
            },
 
            /*获取数据*/
            getData() {
                let self = this;
                self.loading = true;
                self._get(
                    'plus.seckill.product/product', {
                        seckill_activity_id: self.currActive.seckill_activity_id
                    },
                    function(res) {
                        self.listData = res.data;
                        self.countdownConfig.endstamp = res.data.detail.end_time;
                        self.countdownConfig.startstamp = res.data.detail.start_time;
                        uni.hideLoading();
                        self.loading = false;
                    }
                );
            },
 
        /*跳转产品详情*/
        gotoDetail(e) {
            this.$refs.countdown.clear();
            this.gotoPage('/pages/product/detail/detail?product_id=' + e);
        },
 
            /*跳转搜索页面*/
            gotoSearch() {
                this.getData();
            },
 
        /*倒计时返回值*/
        returnValFunc(e) {
            console.log(e);
            this.status = e;
            // 如果原来未开始变成已开始
            if (this.listData.detail.status_text == '未开始' && e == 0) {
                this.countdownConfig.endstamp = this.listData.detail.end_time;
                this.countdownConfig.startstamp = this.listData.detail.start_time;
            }
        }
    }
};
</script>
 
<style lang="scss">
    page {
        background-color: #F2F2F2;
    }
 
    .top-box {
        position: relative;
    }
 
    .seckill-product-wrap .tab-item {
        flex: 0;
        padding: 0 30rpx;
        font-size: 33rpx;
        height: 86rpx;
        line-height: 86rpx;
        white-space: nowrap;
        color: #333333;
    }
 
    .seckill-product-wrap .tab-item.active {
        color: #F6220C;
        font-size: 33rpx;
        opacity: 1;
        position: relative;
    }
 
    .seckill-product-wrap .tab-item.active::after {
        content: "";
        width: 120rpx;
        height: 4rpx;
        background: #F6220C;
        border-radius: 2rpx;
        position: absolute;
        border: 30rpx;
 
    }
 
    .seckill-product-wrap .every-day-time text {
        padding: 8rpx 16rpx;
        font-size: 26rpx;
        color: #333;
        opacity: 0.5;
    }
 
    .seckill-product-wrap .ad-activity {
        position: relative;
        overflow: hidden;
    }
 
    .seckill-product-wrap .ad-activity image {
        width: 750rpx;
        height: 367rpx;
    }
 
.seckill-list-wrap {
}
 
    .seckill-list-wrap .list .item {
        padding: 30rpx;
        display: flex;
        border-radius: 16rpx;
        margin-bottom: 20rpx;
        background: #ffffff;
    }
 
    .seckill-list-wrap .product-cover,
    .seckill-list-wrap .product-cover image {
        width: 200rpx;
        height: 200rpx;
    }
 
    .active-top-tab .ad-datetime::v-deep .box {
        height: 40rpx;
        padding: 4rpx;
        line-height: 40rpx;
        text-align: center;
        border-radius: 8rpx;
        font-size: 28rpx;
        background: #F6220C;
        color: #FFFFFF;
    }
 
    .active-top-tab .ad-datetime::v-deep text {
        color: #333;
        font-size: 28rpx;
    }
 
    .seckill-list-wrap .product-title {
        display: -webkit-box;
        overflow: hidden;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        font-size: 32rpx;
    }
 
    .seckill-list-wrap .already-sale {
        padding: 4rpx 0;
        color: #8228EB;
        font-size: 22rpx;
    }
 
    .seckill-list-wrap .slider-box .slider {
        margin-top: 11rpx;
        height: 8rpx;
        background: #F2F2F2;
        border-radius: 5rpx;
    }
 
    .seckill-list-wrap .slider-box .slider-inner {
        height: 8rpx;
        background: linear-gradient(-90deg, #CB2BFF 0%, #7727E7 100%);
        border-radius: 4rpx;
    }
 
    .seckill-list-wrap .right-btn button {
        background: linear-gradient(90deg, #FF6B6B 4%, #F6220C 100%);
        color: #ffffff;
        height: 60rpx;
        border-radius: 30rpx;
        line-height: 60rpx;
    }
    
    .seckill-list-wrap .right-btn button.btn-gray{
        background: #CCCCCC;
        color: #FFFFFF;
    }
 
    .reg180 {
        padding-right: 20rpx;
        text-align: right;
        transform: rotateY(180deg);
        position: absolute;
        bottom: 0;
    }
 
    .icon-jiantou {
        color: #FFFFFF;
        font-size: 30rpx;
    }
 
    .head_top {
        position: absolute;
        top: 0;
        z-index: 20;
        padding-top: var(--status-bar-height);
        height: 30px;
        line-height: 30px;
        color: #FFFFFF;
        font-size: 28rpx;
    }
 
    .tab-item.active::after {
        content: '';
        width: 60%;
        height: 4rpx;
        background: #F2F2F2;
        border-radius: 2rpx;
        position: absolute;
        bottom: 5rpx;
    }
</style>