quanwei
2025-11-11 0d04d60f456b1902c1e27b9586652649df3963d4
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
<template>
    <view>
        <block v-if="total==1">
            <Card :card_id="card_id"></Card>
        </block>
        <block v-else>
            <!--列表-->
            <scroll-view scroll-y="true" class="scroll-Y" :style="'height:' + scrollviewHigh + 'px;'" lower-threshold="50"
                @scrolltoupper="scrolltoupperFunc" @scrolltolower="scrolltolowerFunc">
                <view class="p30 bg-white">
                    <view class="item-wrap" v-for="(item, index) in listData" :key="index" @click="gotoDetail(item)"
                        :style="'background: url('+item.card_style_url+') left top / 100% 100% no-repeat;'">
                        <view class="item-wrap-box">
                            <view class="f24 mb48 d-s-c">
                                <image src="/static/icon/log-vip.png" class="vip-image" mode="aspectFill"></image>
                                {{item.card_name||item.card.card_name}}
                            </view>
                            <view class="tc f60 fb mb16">{{item.money}}元</view>
                            <view class="tc f26">{{item.expire_time_text}}</view>
                            <view class="tc f24 mt40"><text v-if="item.open_coupon">开卡送券 · </text><text
                                    v-if="item.open_points">开卡送积分 ·</text><text class="ml10">更多特权 ></text></view>
                        </view>
                    </view>
                </view>
                <view class="d-c-c p30" v-if="listData.length == 0 && !loading">
                    <text class="iconfont icon-wushuju"></text>
                    <text class="cont">亲,暂无相关记录哦</text>
                </view>
                <uni-load-more v-else :loadingType="loadingType"></uni-load-more>
            </scroll-view>
        </block>
    </view>
</template>
<script>
    import uniLoadMore from '@/components/uni-load-more.vue';
    import Card from './card.vue';
    export default {
        components: {
            uniLoadMore,
            Card
        },
        data() {
            return {
                /*手机高度*/
                phoneHeight: 0,
                /*可滚动视图区域高度*/
                scrollviewHigh: 0,
                /*状态选中*/
                state_active: 0,
                /*列表*/
                /*当前第几页*/
                page: 1,
                /*一页多少条*/
                last_page: 0,
                list_rows: 15,
                listData: [],
                no_more: false,
                loading: false,
                data_type: 'not_use',
                cardCount: {
                    cardCount: 0,
                    myCount: 0
                },
                total: 0,
                card_id: 0
            };
        },
        mounted() {
            /*初始化*/
            this.init();
        },
        onShow() {
            this.initData()
            /*获取数据*/
            this.getData();
        },
        computed: {
            /*加载中状态*/
            loadingType() {
                if (this.loading) {
                    return 1;
                } else {
                    if (this.listData.length != 0 && this.no_more) {
                        return 2;
                    } else {
                        return 0;
                    }
                }
            }
        },
        methods: {
            /*初始化*/
            init() {
                let self = this;
                uni.getSystemInfo({
                    success(res) {
                        self.phoneHeight = res.windowHeight;
                        self.scrollviewHigh = res.windowHeight;
                    }
                });
            },
            initData() {
                this.listData = [];
                this.page = 1;
                this.no_more = false;
            },
            /*获取数据*/
            getData() {
                let self = this;
                self.loading = true;
                let url = '';
                url = 'user.UserCard/index';
                self._get(url, {
                    page: self.page,
                    list_rows: self.list_rows
                }, function(res) {
                    self.loading = false;
                    self.cardCount = res.data.cardCount;
                    self.listData = self.listData.concat(res.data.list.data);
                    self.last_page = res.data.list.last_page;
                    self.total = res.data.list.total;
                    // 如果只有一张卡,直接显示详情 by lyzflash
                    if (res.data.list.total == 1) {
                        self.card_id = res.data.list.data[0].card_id;
                    }
                    if (res.data.list.last_page <= 1) {
                        self.no_more = true;
                        return false;
                    }
                });
            },
 
            /*可滚动视图区域到底触发*/
            scrolltolowerFunc() {
                let self = this;
                if (self.no_more) {
                    return;
                }
                self.page++;
                if (self.page <= self.last_page) {
                    self.getData();
                } else {
                    self.no_more = true;
                }
            },
            /*状态切换*/
            stateFunc(e) {
                let self = this;
                if (self.loading) {
                    return
                }
                if (self.state_active != e) {
                    if (e == 0) {
                        self.data_type = 'not_use';
                    }
                    if (e == 1) {
                        self.data_type = 'is_use';
                    }
                    if (e == 2) {
                        self.data_type = 'is_expire';
                    }
                    self.state_active = e;
                    self.initData();
                    self.getData();
                }
            },
 
            /*可滚动视图区域到顶触发*/
            scrolltoupperFunc() {
                console.log('滚动视图区域到顶');
            },
            /*查看规则*/
            lookRule(item) {
                item.rule = true;
            },
 
            /*关闭规则*/
            closeRule(item) {
                item.rule = false;
            },
            gotoDetail(item) {
                this.gotoPage('/pages/user/card/card?state_active=0&card_id=' + item.card_id);
            }
        }
    };
</script>
 
<style lang="scss">
    page {
        background-color: #FFFFFF;
    }
 
    .item-wrap {
        padding: 22rpx;
        box-sizing: border-box;
        height: 380rpx;
        transform: scale(0.95);
        border-radius: 30rpx;
    }
 
    .item-wrap-box {
        // border: 1rpx solid #99999980;
        padding: 35rpx 20rpx;
        height: 100%;
        color: rgba($color: #ffffff, $alpha: 0.7);
    }
 
    .vip-image {
        width: 30rpx;
        height: 30rpx;
        opacity: 0.8;
        margin-right: 10rpx;
    }
</style>