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
<template>
<div class="full-page">
<div class="container">
<div class="p-title">
<span class="label">我的健康券</span>
</div>
<ul>
<li v-for="(item, index) in voucherData" :key="index" @click="goToDetail(item.voucherId, item.makeId, item.voucherType)">
<CardItem :data="item"></CardItem>
</li>
</ul>
<div class="pagination">
<ul class="nav-pills">
<li class="text-right">
<a @click="filter(2)" :class="params.states[0]==2?'active':''">查看已使用的券</a>
</li>
<li class="text-left">
<a @click="filter(4)" :class="params.states[0]==4?'active':''">查看已失效的券</a>
</li>
</ul>
</div>
</div>
</div>
</template>
<script>
import { getStore } from '@/util/store'
import { getUserCard } from '@/api/apply/apply'
import CardItem from '@/components/cardItem'
export default {
name: 'vouchers',
data () {
return {
voucherData: [],
size: 10,
params: {
states: [1],
userId: getStore({ name: 'user_id' })
}
}
},
created () {
this.getUserCardByIdFn() // 获取当前用户待使用健康券(每页显示10条)
},
mounted: function () {
},
computed: {
},
components: {
CardItem
},
methods: {
getUserCardByIdFn () {
getUserCard(this.size, this.params).then(res => {
if (res.code === 0) {
this.voucherData = res.data
}
}).catch((error) => {
this.$toast({
message: error.message,
position: 'center',
duration: 3000
})
})
},
filter (state) {
console.log(state)
if (state === this.params.states[0]) {
this.params.states = [1]
} else {
this.params.states = [ state ]
}
this.getUserCardByIdFn()
},
goToDetail (voucherId, makeId, voucherType) {
this.$router.push({
path: '/voucherDetail',
query: {
voucherId: voucherId,
makeId: makeId,
voucherType: voucherType
}
})
}
}
}
</script>
<style scoped>
.full-page {
background-color: #f5f6f7;
}
.pagination {
padding: 1em 0;
width: 100%;
}
.pagination ul li {
width: 50%;
margin: 0;
padding: 0 1em;
}
.pagination ul li + li {
border-left:1px solid #949595;
}
.pagination ul li > a {
color: #949595;
}
.pagination ul li > a.active {
text-decoration:underline;
}
</style>