index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import Toast from 'tdesign-miniprogram/toast/index';
  2. import { fetchPromotion } from '../../../services/promotion/detail';
  3. Page({
  4. data: {
  5. list: [],
  6. banner: '',
  7. time: 0,
  8. showBannerDesc: false,
  9. statusTag: '',
  10. },
  11. onLoad(query) {
  12. const promotionID = parseInt(query.promotion_id);
  13. this.getGoodsList(promotionID);
  14. },
  15. getGoodsList(promotionID) {
  16. fetchPromotion(promotionID).then(({ list, banner, time, showBannerDesc, statusTag }) => {
  17. const goods = list.map((item) => ({
  18. ...item,
  19. tags: item.tags.map((v) => v.title),
  20. }));
  21. this.setData({
  22. list: goods,
  23. banner,
  24. time,
  25. showBannerDesc,
  26. statusTag,
  27. });
  28. });
  29. },
  30. goodClickHandle(e) {
  31. const { index } = e.detail;
  32. const { spuId } = this.data.list[index];
  33. wx.navigateTo({ url: `/pages/goods/details/index?spuId=${spuId}` });
  34. },
  35. cardClickHandle() {
  36. Toast({
  37. context: this,
  38. selector: '#t-toast',
  39. message: '点击加购',
  40. });
  41. },
  42. bannerClickHandle() {
  43. Toast({
  44. context: this,
  45. selector: '#t-toast',
  46. message: '点击规则详情',
  47. });
  48. },
  49. });