移动系统liao
2024-11-12 1cb49b04ae6709e6054c328f5ed12bff9ca014c8
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
<template>
    <view class="pageBox">
        <u-navbar title="团购" safeAreaInsetTop fixed placeholder>
            <view class="coreshop-navbar-left-slot" slot="left">
                <u-icon name="arrow-left" size="19" @click="goNavigateBack"></u-icon>
                <u-line direction="column" :hairline="false" length="16" margin="0 8px"></u-line>
                <u-icon name="home" size="22" @click="goHome"></u-icon>
            </view>
            <view slot="right">
            </view>
        </u-navbar>
 
        <view class="coreshop-flex-direction coreshop-padding-10 coreshop-margin-10 coreshop-bg-white coreshop-text-black" v-for="(item, key) in goodsList" :key="key" v-if="goodsList.length>0">
            <view class="coreshop-flex">
                <view>
                    <u--image :src="item.goodThumbnail" mode="widthFix" width="96px" height="96px"></u--image>
                </view>
                <view class="coreshop-flex coreshop-flex-direction coreshop-padding-left-10 coreshop-percent-100">
                    <view class="coreshop-font-15 u-line-2 coreshop-text-black">{{ item.name }}</view>
                    <view class="coreshop-font-11 coreshop-padding-top-5 coreshop-padding-bottom-3 u-line-2 coreshop-text-brown">{{ item.goodName }}</view>
                    <view class="coreshop-flex coreshop-align-center coreshop-padding-top-10  coreshop-padding-bottom-5">
                        <view class="coreshop-font-11 coreshop-bg-orange coreshop-padding-2 coreshop-border-radius-4 coreshop-margin-right-10" v-if="item.maxNums>0">限购{{item.maxNums}}{{item.goodUnit}}</view>
                        <view class="coreshop-font-11 coreshop-bg-green coreshop-padding-2 coreshop-border-radius-4 coreshop-margin-right-10" v-if="item.maxNums==0">不限购</view>
                        <view class="coreshop-font-11 coreshop-bg-orange coreshop-padding-2 coreshop-border-radius-4 coreshop-margin-right-10" v-if="item.maxGoodsNums>0">总量{{item.maxGoodsNums}}{{item.goodUnit}}</view>
                        <view class="coreshop-font-11 coreshop-bg-green coreshop-padding-2 coreshop-border-radius-4 coreshop-margin-right-10" v-if="item.maxGoodsNums==0">不限总量</view>
 
                        <view class="coreshop-font-11 coreshop-bg-olive coreshop-padding-2 coreshop-border-radius-4">{{item.goodViewCount}}人浏览</view>
                    </view>
                    <view class="coreshop-flex coreshop-justify-between coreshop-flex-direction-row coreshop-align-center" v-if="item.timestamp">
                        <view class="coreshop-text-right coreshop-time-right coreshop-margin-top-10" v-if="(item.startStatus == 1) && item.timestamp">
                            <u-count-down :time="item.timestamp*1000" :autoStart="true" format="DD天HH时mm分ss秒" @change="onChange($event,key)">
                                <view class="time coreshop-font-11">
                                    <view class="coreshop-font-12">仅剩:</view>
                                    <view class="time__custom">
                                        <text class="time__custom__item">{{ item.timeData.days }}</text>
                                    </view>
                                    <text class="time__doc">天</text>
                                    <view class="time__custom">
                                        <text class="time__custom__item">{{ item.timeData.hours >= 10 ? item.timeData.hours :'0' +item.timeData.hours}}</text>
                                    </view>
                                    <text class="time__doc">:</text>
                                    <view class="time__custom">
                                        <text class="time__custom__item">{{ item.timeData.minutes }}</text>
                                    </view>
                                    <text class="time__doc">:</text>
                                    <view class="time__custom">
                                        <text class="time__custom__item">{{ item.timeData.seconds }}</text>
                                    </view>
                                </view>
                            </u-count-down>
                        </view>
                        <view class="coreshop-text-right coreshop-time-right coreshop-margin-top-10" v-if="(item.startStatus == 0) && item.timestamp">
                            <u-count-down :time="item.timestamp*1000" :autoStart="true" format="DD天HH时mm分ss秒" @change="onChange($event,key)">
                                <view class="time">
                                    <view class="coreshop-font-12">即将开始:</view>
                                    <view class="time__custom">
                                        <text class="time__custom__item">{{ item.timeData.days }}</text>
                                    </view>
                                    <text class="time__doc">天</text>
                                    <view class="time__custom">
                                        <text class="time__custom__item">{{ item.timeData.hours>=10?item.timeData.hours:'0'+item.timeData.hours}}</text>
                                    </view>
                                    <text class="time__doc">:</text>
                                    <view class="time__custom">
                                        <text class="time__custom__item">{{ item.timeData.minutes }}</text>
                                    </view>
                                    <text class="time__doc">:</text>
                                    <view class="time__custom">
                                        <text class="time__custom__item">{{ item.timeData.seconds }}</text>
                                    </view>
                                </view>
                            </u-count-down>
                        </view>
                    </view>
                    <view class="coreshop-flex coreshop-justify-between coreshop-flex-direction-row coreshop-align-center coreshop-margin-top-10">
                        <view class="coreshop-flex coreshop-align-center">
                            <view class="coreshop-font-14 coreshop-text-red">¥{{item.price}}</view>
                            <view class="coreshop-font-xs coreshop-text-through coreshop-margin-left-5">{{item.mktPrice}}元</view>
                        </view>
                        <view class="coreshop-groupPurchase-btn" v-if="item.startStatus == 1" @click="goGroupBuyingDetail(item.id)">立即团</view>
                        <view class="coreshop-groupPurchase-btn" v-if="item.startStatus == 0">即将开始</view>
                        <view class="coreshop-buy-btn-disabled" v-if="item.startStatus == 2">已结束</view>
                    </view>
                </view>
            </view>
            <view v-if="key+1 < goodsList.length">
                <view class="coreshop-divider">
                    <view class="seckill"></view>
                    <view class="dot">●</view>
                    <view class="seckill"></view>
                </view>
            </view>
        </view>
 
        <!-- 无数据时默认显示 -->
        <view class="coreshop-emptybox" v-else>
            <u-empty :icon="$globalConstVars.apiFilesUrl+'/static/images/empty/data.png'" icon-size="150" text="暂无团购信息" mode="list"></u-empty>
        </view>
        <!-- 加载更多 -->
        <u-loadmore :status="loadStatus" :icon-type="iconType" :load-text="loadText" margin-top="20" margin-bottom="20" />
        <!-- 登录提示 -->
        <coreshop-login-modal></coreshop-login-modal>
    </view>
</template>
 
<script>
 
    export default {
 
        data() {
            return {
                loadStatus: 'loadmore',
                iconType: 'flower',
                loadText: {
                    loadmore: '轻轻上拉',
                    loading: '努力加载中',
                    nomore: '实在没有了'
                },
                loading: false,
                page: 1,
                limit: 10,
                lastPage: 1,
                status: 1,
                tabCurrent: 'ing',
                goodsList: [],
                btnType: {
                    ing: {
                        name: '立即抢购',
                    },
                    nostart: {
                        name: '尚未开始',
                    },
                    ended: {
                        name: '已结束',
                    },
                },
            };
        },
        onLoad() {
            this.loading = true;
            this.getGoodsList();
        },
        onReachBottom() {
            if (this.loadStatus === 'loadmore') {
                this.getGoodsList()
            }
        },
        methods: {
            // 百分比
            getProgress(sales, stock) {
                let unit = '';
                if (stock + sales > 0) {
                    let num = (sales / (sales + stock)) * 100;
                    unit = num.toFixed(2) + '%';
                } else {
                    unit = '0%';
                }
                return unit;
            },
            // 进度数
            getPercent(sales, stock) {
                let unit = 0;
                if (stock + sales > 0) {
                    let num = (sales / (sales + stock)) * 100;
                } else {
                    unit = 30;
                }
                return unit;
            },
            // 秒杀列表
            getGoodsList() {
                let _this = this;
                let data = {
                    page: this.page,
                    limit: this.limit,
                    type: 3, //团购
                    status: this.status
                }
                this.loadStatus = 'loading';
                this.$u.api.getGroup(data).then(res => {
                    if (res.status) {
                        if (res.data) {
                            let _goodsList = res.data.list;
                            _this.goodsList = [..._this.goodsList, ..._goodsList]
                        }
                        _this.lastPage = res.data.totalPages;
                        if (_this.page < res.data.totalPages) {
                            _this.page++
                            _this.loadStatus = 'loadmore'
                        } else {
                            _this.loadStatus = 'nomore'
                        }
                    } else {
                        _this.$u.toast(res.msg)
                    }
                });
 
            },
            onChange(e, key) {
                this.$set(this.goodsList[key], 'timeData', e)
            },
        }
    }
</script>
 
<style lang="scss" scoped>
    @import "list.scss";
</style>