xuxueyang
2024-09-09 8478015e961b93963e0a269d92c281d84da44f63
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
<template>
    <view class="good-list-container">
        <view class="top-bg img100 relative" :style="{'padding-top':(StatusBar)+'px','line-height':CustomBar+'rpx' }">
            <!-- ../../../static/images/customer/coupon/good-top-bg.png -->
            <image class="component-bg" src="https://hmy-flower.oss-cn-shanghai.aliyuncs.com/a9/a9731b0037924324a3d3318dfa7d10c5LZk6JsSC33ua754767bf8c714154f06bbd5b4d905174.png"
                mode="scaleToFill" />
 
            <view class="title">
                <uni-icons class="icon" type="left" size="24" @click="backpage()"></uni-icons>
                积分兑换
            </view>
            <view class="flex point-info">
                <view class="point-record m-r-a">
                    <view class="text-center title">我的积分</view>
                    <view class="flex" @click="goto('/sub_pages/customer/coupon/point-history',true)">
                        <image src="../../../static/images/customer/coupon/icon-point.png" class="point-icon">
                        </image>
                        {{currentInfo.currentPoint || 0}}
                        <uni-icons class="icon" type="right" size="32"></uni-icons>
                    </view>
                </view>
                <view class="m-l-a m-r-0 rule"  @click="goto('/pages/help/content?id=积分规则',false)">
                    <view class="flex w-fit m-l-a m-r-15">
                        <view class="m-r-10">规则</view>
                        <image src="../../../static/images/customer/coupon/icon-rule.png" class="rule-icon">
                        </image>
                    </view>
                    <image class="good-point-icon" src="../../../static/images/customer/coupon/good-point-icon.png"
                        mode="scaleToFill" />
                </view>
            </view>
        </view>
        <view class="p10">
            <top-tabs :tabs="tabs" :flg="flg" @change="changeTab" type="coupon">
 
            </top-tabs>
        </view>
        <!-- 商品 -->
        <view v-if="flg==0">
            <view class="query-scores flex flex-wrap-normal p15">
                <view class="item" v-for="(item,index) of scores" :key="index" @click="changeScore(item)"
                    :class="[(!item.min||query.pointLower==item.min)&&(!item.max || query.pointUpper==item.max)?'active':'']">
                    {{item.max?(item.min?`${item.min}~${item.max}`:`${item.max}以下`):`${item.min}以上`}}
                </view>
            </view>
            <no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
 
            <view class="good-container p15 flex">
                <view v-for="(item,index) of list" :key="index" class="good-item" @click="toDetail(item)">
                    <image class="cover" :src="item.cover" :lazy-load="true" mode="scaleToFill">
 
                    </image>
                    <view class="title">
                        {{item.name}}
                    </view>
                    <view class="flex score-info">
                        <view><span class="score">{{item.point||'-'}}</span>积分</view>
                        <view class="button m-l-a m-r-0" @click.stop="exchange('good',item)">兑换</view>
                    </view>
                </view>
            </view>
        </view>
        <!-- 优惠券 -->
        <view v-if="flg==1" class="coupon-container">
            <no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
            <view v-for="(item,index) of list" :key="index" class="coupont-item all exchange">
                <view class="flex container img100">
                    <view class="info-price">
                        <!-- 优惠券类型(COUPON_TYPE)满减和无门槛 -->
                        <view class="price1">
                            {{item.maxDiscountAmount?(`${item.maxDiscountAmount}折`):(`¥${item.couponDiscountValue}`)}}
                        </view>
                        <view class="price2">{{item.minOrderAmount?(`满¥${item.minOrderAmount}可用`):'无门槛'}}</view>
                    </view>
                    <view class="info flex1">
                        <view class="title">
                            {{item.couponName||'-'}}
                        </view>
                        <view class="time">
                            领取后{{item.usageTimeNum||''}}{{item.usageTimeTypeName||''}}有效
                        </view>
                        <view class="flex">
                            <view class="t-red">
                                {{item.point||'0'}}积分
                            </view>
                            <view class="button m-l-a m-r-0" @click="exchange('coupon',item)">
                                兑换
                            </view>
                        </view>
                    </view>
                </view>
 
            </view>
        </view>
 
    </view>
</template>
 
<script>
    export default {
        methods: {
            changeTab(flg) {
                this.flg = '' + flg
                this.listApi = this.tabs[flg].api
                this.refreshList()
            },
            async exchange(type, item) {
                var api = ''
                if (type == 'good') {
                    api = '/api/customer/point/goods/exchange'
                }
                if (type == 'coupon') {
                    api = '/api/v2/coupon/point/exchange'
                }
                await this.$message.confirm('确定兑换吗')
                this.$message.showLoading()
                const {
                    code,
                    data
                } = await this.$http.request('post', api, {
                    data: {
                        couponId: item.id,
                        goodsId: item.id, //兼容2个
                        num:1
                    }
                })
                this.$message.hideLoading()
                if (code == 0) {
                    this.$message.showToast('兑换成功')
                }
            },
            toDetail(item) {
                uni.navigateTo({
                    url: '/sub_pages/customer/coupon/good-detail?id=' + item.id
                })
            },
            changeScore(item){
                this.query.pointLower = item.min || 0
                this.query.pointUpper = item.max || 990000
                this.refreshList()
            }
        },
        data() {
            return {
                CustomBar: uni.getStorageSync('CustomBar'),
                StatusBar: uni.getStorageSync('StatusBar'),
                flg: 0,
 
                tabs: [{
                        name: '商品',
                        api: '/api/customer/point/goods/list',
 
                    },
                    {
                        name: '优惠券',
                        api: '/api/v2/coupon/app/activy/list',
 
                    },
                ],
                query: {
                    pointLower: 0,
                    pointUpper: 1000
                },
                scores: [{
                        min: 0,
                        max: 1000
                    },
                    {
                        min: 1001,
                        max: 3000
                    },
                    {
                        min: 3001,
                        max: 5000
                    },
                    {
                        min: 5001,
                        max: 10000
                    },
                    {
                        min: 10001,
                        max: 0
                    },
                ]
            }
        },
        onLoad() {
            this.listApi = '/api/customer/point/goods/list'
        },
 
        onReachBottom() {
            this.getMore()
        },
    }
</script>
 
<style lang="scss" scoped>
    .good-list-container {
        .good-container {
            .good-item {
                background: #FFFFFF;
                border-radius: 12rpx;
                width: 330rpx;
                margin-bottom: 30rpx;
 
                .cover {
                    width: 330rpx;
                    height: 330rpx;
                    background-size: 100% 100%;
                }
 
                .title {
                    padding:18rpx 18rpx 0rpx 18rpx;
                    font-weight: 600;
                    font-size: 32rpx;
                    color: #000000;
                    line-height: 44rpx;
                    text-align: left;
                }
 
                .score-info {
 
                    line-height: 50rpx;
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #44775A;
                    padding:18rpx;
                    padding-bottom: 28rpx;
 
                    .score {
                        font-weight: 600;
                        font-size: 36rpx;
                        color: #44775A;
                    }
                }
 
                .button {
                    width: 106rpx;
                    height: 46rpx;
                    border-radius: 24rpx;
                    border: 2rpx solid #44775A;
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #44775A;
                    text-align: center;
                    line-height: 46rpx;
                }
            }
 
            .good-item:nth-child(2n+1) {
                margin-left: 0rpx;
                margin-right: auto;
            }
 
            .good-item:nth-child(2n) {
                margin-right: 0rpx;
                margin-left: auto;
            }
        }
 
        .query-scores {
            overflow-x: scroll;
            // width: max-content;
            .item {
                min-width: fit-content;
                padding-left: 16rpx;
                padding-right: 16rpx;
                text-align: center;
                font-weight: 400;
                font-size: 28rpx;
                color: #333333;
                line-height: 50rpx;
                height: 50rpx;
                border-radius: 26rpx;
                // width: fit-content;
                
            }
 
            .item.active {
                background: #E1F0E7;
                font-weight: 600;
                color: #1A8B4C;
            }
        }
 
        .top-bg {
            padding: 32rpx;
            padding-top: 40rpx;
            height: 320rpx;
            max-height: 320rpx;
 
            .point-info {
 
                .point-record {
                    // margin-left: 40rpx;
                    font-weight: 600;
                    font-size: 60rpx;
                    color: #44775A;
                    line-height: 84rpx;
 
                    .title {
                        font-weight: 400;
                        font-size: 32rpx;
                        color: #000000;
                        line-height: 44rpx;
                        margin-top: 40rpx;
                        margin-bottom: 20rpx;
                    }
 
                    .point-icon {
                        width: 42rpx;
                        height: 42rpx;
                        margin-top: 20rpx;
                        margin-right: 10rpx;
                        display: inline-block;
                        vertical-align: middle;
                    }
                }
 
                .rule {
                    font-weight: 400;
                    font-size: 24rpx;
                    color: #44775A;
                    line-height: 30rpx;
 
                    .good-point-icon {
                        width: 192rpx;
                        height: 162rpx;
                        margin-right: 120rpx;
                        margin-top: 10rpx;
                    }
 
                    .rule-icon {
                        width: 30rpx;
                        height: 30rpx;
 
                        display: inline-block;
                        vertical-align: middle;
                    }
                }
 
 
            }
 
            .title {
                text-align: center;
                font-weight: 600;
                font-size: 32rpx;
                position: relative;
 
                .icon {
                    position: absolute;
                    left: 0rpx;
                    z-index: 1;
                }
            }
 
        }
    }
</style>