yiming
2024-03-13 f9d4b09377c5471e1202be2fef2c89de27b6654d
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
import Toast from 'tdesign-miniprogram/toast/index';
import { fetchPromotion } from '../../services/promotion/detail';
 
Page({
  data: {
    list: [],
    banner: '',
    time: 0,
    showBannerDesc: false,
    statusTag: '',
  },
 
  onLoad(query) {
    const promotionID = parseInt(query.promotion_id);
    this.getGoodsList(promotionID);
  },
 
  getGoodsList(promotionID) {
    fetchPromotion(promotionID).then(
      ({ list, banner, time, showBannerDesc, statusTag }) => {
        const goods = list.map((item) => ({
          ...item,
          tags: item.tags.map((v) => v.title),
        }));
        this.setData({
          list: goods,
          banner,
          time,
          showBannerDesc,
          statusTag,
        });
      },
    );
  },
 
  goodClickHandle(e) {
    const { index } = e.detail;
    const { spuId } = this.data.list[index];
    wx.navigateTo({ url: `/pages/goods/details/index?spuId=${spuId}` });
  },
 
  cardClickHandle() {
    Toast({
      context: this,
      selector: '#t-toast',
      message: '点击加购',
    });
  },
 
  bannerClickHandle() {
    Toast({
      context: this,
      selector: '#t-toast',
      message: '点击规则详情',
    });
  },
});