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
| import { fetchCouponList } from '../../../services/coupon/index';
|
| Page({
| data: {
| status: 0,
| list: [
| {
| text: '可使用',
| key: 0,
| },
| {
| text: '已使用',
| key: 1,
| },
| {
| text: '已失效',
| key: 2,
| },
| ],
|
| couponList: [],
| },
|
| onLoad() {
| this.init();
| },
|
| init() {
| this.fetchList();
| },
|
| fetchList(status = this.data.status) {
| let statusInFetch = '';
| switch (Number(status)) {
| case 0: {
| statusInFetch = 'default';
| break;
| }
| case 1: {
| statusInFetch = 'useless';
| break;
| }
| case 2: {
| statusInFetch = 'disabled';
| break;
| }
| default: {
| throw new Error(`unknown fetchStatus: ${statusInFetch}`);
| }
| }
| fetchCouponList(statusInFetch).then((couponList) => {
| this.setData({ couponList });
| });
| },
|
| tabChange(e) {
| const { value } = e.detail;
|
| this.setData({ status: value });
| this.fetchList(value);
| },
|
| goCouponCenterHandle() {
| wx.showToast({ title: '去领券中心', icon: 'none' });
| },
|
| onPullDownRefresh_() {
| this.setData(
| {
| couponList: [],
| },
| () => {
| this.fetchList();
| },
| );
| },
| });
|
|