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
| import { fetchCouponDetail } from '../../../services/coupon/index';
| import { fetchGoodsList } from '../../../services/good/fetchGoods';
| import Toast from 'tdesign-miniprogram/toast/index';
|
| Page({
| data: {
| goods: [],
| detail: {},
| couponTypeDesc: '',
| showStoreInfoList: false,
| cartNum: 2,
| },
|
| id: '',
|
| onLoad(query) {
| const id = parseInt(query.id);
| this.id = id;
|
| this.getCouponDetail(id);
| this.getGoodsList(id);
| },
|
| getCouponDetail(id) {
| fetchCouponDetail(id).then(({ detail }) => {
| this.setData({ detail });
| if (detail.type === 2) {
| if (detail.base > 0) {
| this.setData({
| couponTypeDesc: `满${detail.base / 100}元${detail.value}折`,
| });
| } else {
| this.setData({ couponTypeDesc: `${detail.value}折` });
| }
| } else if (detail.type === 1) {
| if (detail.base > 0) {
| this.setData({
| couponTypeDesc: `满${detail.base / 100}元减${detail.value / 100}元`,
| });
| } else {
| this.setData({ couponTypeDesc: `减${detail.value / 100}元` });
| }
| }
| });
| },
|
| getGoodsList(id) {
| fetchGoodsList(id).then((goods) => {
| this.setData({ goods });
| });
| },
|
| openStoreList() {
| this.setData({
| showStoreInfoList: true,
| });
| },
|
| closeStoreList() {
| this.setData({
| showStoreInfoList: false,
| });
| },
|
| goodClickHandle(e) {
| const { index } = e.detail;
| const { spuId } = this.data.goods[index];
| wx.navigateTo({ url: `/pages/goods/details/index?spuId=${spuId}` });
| },
|
| cartClickHandle() {
| Toast({
| context: this,
| selector: '#t-toast',
| message: '点击加入购物车',
| });
| },
| });
|
|