zhaojs
2023-07-26 1cc2a702ff0338cfe2fc32f840c32209cbdc3e37
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
<template>
    <view class="coupon">
        <view v-for="(item,index) in couponList" class="couponCard" :key="item.id">
            <view>
                <view class="title">{{item.title}}</view>
                <view class="condition">{{item.conditon}}</view>
                <view class="date">{{item.date}}</view>
            </view>
            <view>
                <view class="btn1" v-if="!item.isGet" @click="getCoupon(item.id)">立即领取</view>
                <view class="btn2" v-if="item.isGet">已领取</view>
            </view>
        </view>
    </view>
 
</template>
 
<script>
    export default {
        data() {
            return {
                couponList: [{
                        id: 'e2',
                        title: "5元优惠券",
                        conditon: '满100元使用',
                        date: '2023/03/25 - 2023/04/20',
                        isGet: false,
                    },
                    {
                        id: 'e3',
                        title: "10元优惠券",
                        conditon: '满200元使用',
                        date: '2023/03/25 - 2023/04/20',
                        isGet: false,
                    },
                    {
                        id: 'e4',
                        title: "15元优惠券",
                        conditon: '满200元使用,(仅限于生鲜类)',
                        date: '2023/03/25 - 2023/04/20',
                        isGet: false,
                    },
                    {
                        id: 'e1',
                        title: "2元优惠券",
                        conditon: '满50元使用',
                        date: '2023/03/25 - 2023/04/20',
                        isGet: true,
                    },
                ]
            }
        },
        onLoad(option) {
            // console.log(option)
            // debugger
            uni.setNavigationBarTitle({
                title: option.title
            });
        },
 
        methods: {
            getCoupon(id) {
                let data = this.couponList
                this.couponList.map((item, index) => {
                    if (item.id == id) {
                        // debugger
                        let row={
                            id:item.id,
                            title: item.title,
                            conditon: item.conditon,
                            date: item.date,
                            isGet: true,
                        }
                        data.splice(index,1)
                        data=data.concat(row)
                    }
                })
                this.couponList = data
            }
        }
    }
</script>
 
<style>
    .coupon {
        padding: 12px;
    }
 
    .couponCard {
        height: 80px;
        width: 100%;
        background: url(https://img.alicdn.com/imgextra/i4/751308485/O1CN01VMZg4N2CYBLp6CpYX_!!751308485.png) no-repeat 50%;
        background-size: 100% 100%;
        margin-bottom: 12px;
        padding: 12px 0 0 12px;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        color: #e7591a;
    }
 
    .title {
 
        font-size: 32rpx;
        font-weight: 600;
    }
 
    .condition {
        font-size: 24rpx;
    }
 
    .date {
        font-size: 24rpx;
    }
 
    .btn1 {
        background-color: #ec5f2a;
        color: white;
        border-radius: 30rpx;
        margin-right: 30rpx;
        font-size: 26rpx;
        padding: 4px 6px;
        width: 106rpx;
        text-align: center;
    }
 
    .btn2 {
        background-color: #ecae9a;
        color: #ec5f2a;
        border-radius: 30rpx;
        margin-right: 30rpx;
        font-size: 26rpx;
        padding: 4px 6px;
        width: 106rpx;
        text-align: center;
    }
</style>