xuxueyang
2024-09-12 73341eba8e313c2aead0476026bc362b8c4be4b1
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
<template>
    <view class="coupon-container">
        <view class="p10" v-if="source!=='shopping'">
            <top-tabs :tabs="tabs" :flg="flg" @change="changeTab" type="coupon">
 
            </top-tabs>
        </view>
        <no-data v-if="!list||list.length==0" style="width: 100%;"></no-data>
 
        <view class="p10">
 
            <view v-for="(item,index) of list" :key="index" class="good-item" :class="[query.status]">
                <view class="flex container img100" @click="selectItem(item)">
                    <view class="info-price">
                        <image :lazy-load="true" :src="item.cover" class="cover" mode="scaleToFill"></image>
                    </view>
                    <view class="info flex1">
                        <view class="title flex">
                            {{item.name||''}}
                            <!-- <radio :checked="isIngood(item)" @click.stop="updateSelectGood(item)" v-if="source==='shopping'" class="select-coupon"></radio> -->
 
                            <view :style="{ 'margin-right': '20rpx'}" class="component-radio m-l-a"
                                :class="[isIngood(item)?'cur':'']" v-if="source==='shopping'">
 
                            </view>
 
                        </view>
                        <view class="time word-e">
                            {{item.description||''}}
                        </view>
                        <view class="button m-l-a m-r-10" v-if="source!=='shopping'">
                            查看详情
                        </view>
                        <!--         <view class="button" @click="updateSelectGood(item)" v-if="source=='shopping'">
                            {{isIngood(item)?'移除':'添加'}}
                        </view> -->
                    </view>
                </view>
                <!--     <view class="tip">
                    <span class="t-red">*</span>此券每人限领1张。仅限用于花满芜鲜花交易平台鲜切花花款满额使用,不可与其他优惠同享、不可叠加使用
                </view> -->
            </view>
        </view>
        <view style="min-height: 140rpx;" v-if="source=='shopping'"></view>
        <view class="bottom-button" @click="backpage()" v-if="source=='shopping'">确定选择</view>
 
        <!-- <view class="bottom-button" @click="toGoodAll">前往兑换</view> -->
    </view>
</template>
 
<script>
    import {
        mapState
    } from 'vuex'
    export default {
        computed: {
            ...mapState({
                cache_goods: state => {
                    return state.cache.goods || []
                },
            }),
        },
 
        data() {
            return {
                flg: 0,
 
                tabs: [{
                        name: '未使用',
                        status: 'A',
                        // unused
                    },
                    {
                        name: '已使用',
                        status: 'U',
 
                        // used
                    },
                    {
                        name: '已过期',
                        status: 'E',
 
                        // expired
                    },
                ],
                query: {
                    status: 'A'
                },
                list: [],
                source: ''
 
            }
        },
        onReachBottom() {
            this.getMore()
        },
        async onLoad(options) {
            if (options.source) {
                this.source = options.source || ''
            }
            if (this.source === 'shopping') {
                //只展示可用的
                this.page.size = 100
                this.listApi = '/api/customer/point/goods/exchange/list'
            } else {
                this.listApi = '/api/customer/point/goods/exchange/list'
            }
 
            this.getList()
        },
 
        methods: {
            selectItem(item) {
                if (this.srouce === 'shopping') {
                    //选择
                    this.updateSelectGood(item)
                } else {
                    //详情
                    this.getPointGood(item)
                }
            },
            isIngood(item) {
                for (var tmp of this.cache_goods) {
                    if (tmp.id == item.id) {
                        return true
                    }
                }
 
                return false
            },
            async updateSelectGood(item) {
                var has = false
                for (var tmp of this.cache_goods) {
                    if (tmp.id == item.id) {
                        has = true
                        break
                    }
                }
                var arr = []
 
                if (has) {
                    //移除
                    var arr = []
                    for (var tmp of this.cache_goods) {
                        if (tmp.id == item.id) {} else {
                            arr.push(tmp)
                        }
                    }
                } else {
                    //添加
                    for (var tmp of this.cache_goods) {
                        arr.push(tmp)
                    }
                    arr.push(item)
                }
                await this.$store.dispatch('cache_goods_select', arr)
                this.$forceUpdate()
 
            },
            changeTab(flg) {
                this.flg = '' + flg
                this.query.status = this.tabs[flg].status
                this.refreshList()
            },
            getPointGood(item) {
                uni.navigateTo({
                    url: `/sub_pages/customer/coupon/good-detail?id=${item.goodsId}`
                })
            },
            toGoodAll() {
                uni.navigateTo({
                    url: `/sub_pages/customer/coupon/good-all`
                })
            }
        },
        // async onShow() {
        //     if (this.sign['coupon']) {
        //         this.$store.dispatch('sign_clear', 'coupon');
        //         this.refreshList()
        //     }
        // },
        async onPullDownRefresh() {
            await this.refreshList()
            uni.stopPullDownRefresh()
 
        },
    }
</script>
 
<style lang="scss" scoped>
    @import './coupon.scss';
 
    .coupon-container {
        .good-item {
            height: unset;
            padding: 20rpx;
            margin-top: 0rpx;
 
            .container {
                background-color: #fff;
 
                .info-price {
                    .cover {
                        width: 150rpx;
                        height: 150rpx;
                    }
                }
 
                .info {
                    margin-left: 20rpx;
                    position: relative;
 
                    .title {
                        font-weight: 600;
                        font-size: 36rpx;
                        color: #333333;
                        line-height: 50rpx;
                        text-align: left;
                        position: relative;
                        margin-top: 20rpx;
 
                        .select-coupon {
                            position: absolute;
                            right: 10rpx;
                            top: -6rpx;
                        }
                    }
 
                    .time {
                        font-weight: 400;
                        font-size: 28rpx;
                        color: #666666;
                        line-height: 40rpx;
                        text-align: left;
                        margin-top: 10rpx;
                        word-break: break-all;
                    }
 
 
 
                    .button {
                        width: 150rpx;
                        height: 46rpx;
                        // box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(0,0,0,0.14);
                        border-radius: 24rpx;
                        border: 2rpx solid rgba(68, 119, 90, 1);
                        font-weight: 400;
                        font-size: 24rpx;
                        color: rgba(68, 119, 90, 1);
                        line-height: 46rpx;
                        text-align: center;
                        // margin-top: 10rpx;
                        position: absolute;
                        right: 10rpx;
                        bottom: 20rpx;
                    }
                }
            }
        }
 
 
 
        .bottom-button {
            width: 690rpx;
            height: 90rpx;
            border-radius: 46rpx;
            border: 2rpx solid #20613D;
            position: fixed;
            bottom: 30rpx;
            left: 50%;
            transform: translateX(-50%);
            font-weight: 400;
            font-size: 32rpx;
            color: #20613D;
            text-align: center;
            line-height: 90rpx;
            background-color: #fff;
        }
    }
</style>