通过微信开发者工具 商城模板 创建新小程序
This commit is contained in:
57
mini-program/pages/promotion-detail/index.js
Normal file
57
mini-program/pages/promotion-detail/index.js
Normal file
@@ -0,0 +1,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: '点击规则详情',
|
||||
});
|
||||
},
|
||||
});
|
Reference in New Issue
Block a user