111
liyaozhi
2025-11-09 c13b8914228e6a404bd60ee36bf2479383da8f23
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
<template>
    <view class="bargain-container" :data-theme='theme()' :class="theme() || ''">
        <!--内容-->
        <view class="bargain-list" v-if="!loading">
            <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50">
                <view class="goods-list">
                    <view class="goods-item" v-for="(item, index) in listData" :key="index">
                        <view class="goods-content">
                            <!-- 商品图片 -->
                            <view class="goods-image-wrapper">
                                <image class="goods-image" :src="item.product_image" mode="aspectFill"></image>
                            </view>
 
                            <!-- 右侧内容 -->
                            <view class="goods-info">
                                <!-- 商品标题 -->
                                <view class="goods-title">{{ item.product_name }}</view>
 
                                <!-- 价格行 -->
                                <view class="price-row">
                                    <text class="theme-price f28 fb mr10">¥{{ item.product_sku.product_price }}</text>
                                    <text class="original-price">¥{{ item.product_sku.line_price }}</text>
                                </view>
 
                                <!-- 购物车操作 -->
                                <view class="action-row">
                                    <view class="cart-btn" @click="openPopup(item,'cart')">加购物车</view>
                                    <view class="buy-btn" @click="openPopup(item,'buy')">立即购买</view>
                                </view>
                            </view>
                        </view>
 
                        
                    </view>
                </view>
 
                <!-- 没有记录 -->
                <view class="none-data-box" v-if="listData.length == 0 && !loading">
                    <image src="/static/none.png" mode="widthFix"></image>
                    <text>暂无数据</text>
                </view>
            </scroll-view>
        </view>
        <!--购物确定-->
        
        <spec :isPopup="isPopup" :activity_id="activity_id" :longitude="longitude" :latitude="latitude" :productModel="productModel"  @handelPreviewing="handelPreviewing" @close="closePopup"></spec>
    
     <view class="float-button" @click="handleFloatButtonClick">
          <image class="button-icon" src="/static/cart_active.png" mode="aspectFit"></image>
           <view class="cart-badge" v-if="cart_total_num > 0">{{cart_total_num}}</view>
    </view>
    </view>
</template>
 
<script>
import utils from '@/common/utils.js';
import spec from './popup/spec.vue';
export default {
    components: {
        spec
    },
    data() {
        return {
            /*手机高度*/
            phoneHeight: 0,
            /*可滚动视图区域高度*/
            scrollviewHigh: 0,
            /*商品列表*/
            listData: [],
            /*是否正在加载*/
            loading: true,
            activity_id: '',
            //多规格弹窗
            detail: null,
            /*商品属性*/
            specData: null,
            /*子级页面传参*/
            productModel: {},
            isPopup: false,
            cart_total_num:0,
            longitude:'',
            latitude:'',
            is_previewing:false,
            activityDetail: [],
        };
    },
    computed: {},
    onLoad(e) {
        let scene = utils.getSceneData(e);
        if (typeof e.activity_id != 'undefined') {
            this.activity_id = e.activity_id;
        } else {
            this.activity_id = scene.activity_id;
        }
    },
    onShow() {
        if(!this.is_previewing){
            /*获取列表*/
            this.getlist();
        }
    },
    mounted() {
        this.init();
    },
    onReachBottom() {},
    methods: {
        handleFloatButtonClick(){
            this.gotoPage('/pages/branch/activity/product/cart?activity_id=' + this.activity_id);
        },
        /*初始化*/
        init() {
            let _this = this;
            uni.getSystemInfo({
                success(res) {
                    _this.scrollviewHigh = res.windowHeight;
                }
            });
        },
 
        /*获取活动列表*/
        getlist() {
            let self = this;
            uni.showLoading({
                title: '加载中'
            });
            self.loading = true;
            self._get(
                'branch.activityProduct/lists',
                {
                    activity_id: self.activity_id,
                },
                function (res) {
                    self.listData = res.data.list;
                    self.cart_total_num = res.data.cart_total_num;
                    self.activityDetail = res.data.activityDetail;
                    uni.hideLoading();
                    self.loading = false;
                }
            );
        },
        
        /*选规格*/
        openPopup(e,type) {
            const self = this;
            const detail = e;
            let specData = e.specData;
            if (e.spec_type == 20) {
                for (let i in specData.spec_attr) {
                    for (let j in specData.spec_attr[i].spec_items) {
                        specData.spec_attr[i].spec_items[j].checked = false;
                    }
                }
            }
            let obj = {
                specData: specData,
                detail: detail,
                productSpecArr: specData != null ? new Array(specData.spec_attr.length) : [],
                show_sku: {
                    sku_image: '',
                    price: 0,
                    product_sku_id: 0,
                    line_price: 0,
                    stock: 0,
                    product_sku_id: 0,
                    sum: 1,
                },
                plus_sku: null,
                type: type,
                plus_name: ''
            };
            self.productModel = obj;
            self.isPopup = true;
            
        },
 
        /*关闭弹窗*/
        closePopup(e, cart_total_num) {
            const self = this;
            self.isPopup = false;
            if(cart_total_num!=null){
                self.cart_total_num = cart_total_num;
            }
            
            console.log('触发返回',self.cart_total_num);
        },
        /*处理关闭预览*/
        handelPreviewing(option){
            this.is_previewing = option;
        },
    }
};
</script>
 
<style lang="scss" scoped>
page {
    background: #f2f2f2;
}
.bargain-list{
    padding-bottom: 100rpx;
}
 
/* 商品列表 */
.goods-list {
    display: flex;
    flex-direction: column;
}
 
/* 商品项 */
.goods-item {
    margin: 20rpx 20rpx 0rpx 20rpx;
    background-color: #fff;
    border-radius: 24rpx;
    overflow: hidden;
}
 
/* 商品内容 */
.goods-content {
    display: flex;
    padding: 20rpx;
}
 
/* 商品图片 */
.goods-image-wrapper {
    width: 180rpx;
    height: 180rpx;
    flex-shrink: 0;
    border-radius: 16rpx;
    overflow: hidden;
}
 
.goods-image {
    width: 100%;
    height: 100%;
}
 
/* 商品信息 */
.goods-info {
    flex: 1;
    margin-left: 20rpx;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
 
/* 商品标题 */
.goods-title {
    font-size: 28rpx;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
}
 
/* 价格行 */
.price-row {
    display: flex;
    align-items: center;
    margin-top: 10rpx;
}
 
.current-price {
    font-size: 32rpx;
    color: #f44;
    font-weight: bold;
    margin-right: 10rpx;
}
 
.original-price {
    font-size: 24rpx;
    color: #999;
    text-decoration: line-through;
}
 
/* 操作行 */
.action-row {
    display: flex;
    align-items: center;
    margin-top: 15rpx;
}
 
.cart-btn {
    padding: 8rpx 20rpx;
    border-radius: 30rpx;
    font-size: 24rpx;
    margin-right: 30rpx;
    @include font_color('text_color2');
    @include background_linearmore('cart_left1', 'cart_left2', 'left_deg', 0%, 100%);
}
.buy-btn{
    padding: 8rpx 20rpx;
    border-radius: 30rpx;
    font-size: 24rpx;
    @include font_color('text_color1');
    @include background_linearmore('cart_right1', 'cart_right2', 'right_deg', 0%, 100%);
}
 
.selected-count {
    font-size: 24rpx;
    color: #666;
    margin-left: 15rpx;
}
 
.float-button {
  position: fixed;
  right: 30rpx;
  bottom: 140rpx;
  width: 100rpx;
  height: 100rpx;
  border-radius: 50%;
  background-color: #ffffff;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  transition: transform 0.1s ease;
}
 
.float-button:active {
  transform: scale(0.95);
}
 
.button-icon {
  width: 60rpx;
  height: 60rpx;
}
 
/* 购物车数量徽标 */
.cart-badge {
  position: absolute;
  top: -20rpx;
  right: 10rpx;
  min-width: 36rpx;
  height: 36rpx;
  line-height: 36rpx;
  text-align: center;
  border-radius: 18rpx;
  background-color: #ffffff;
  color: #ff5a5f;
  font-size: 36rpx;
  font-weight: bold;
  padding: 0 6rpx;
  box-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
}
 
 
 
/* 适配iPhone X系列 */
@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3),
    only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3),
    only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) {
    .container {
        padding-bottom: 68rpx; /* 增加底部安全区域 */
    }
}
</style>