You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
git/scr/miniprogram-2/pages/coupon/coupon-activity-goods/index.js

79 lines
1.7 KiB

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: '点击加入购物车',
});
},
});