调整优惠券部分

This commit is contained in:
qiaomu 2024-12-09 10:36:16 +08:00
parent 9bc3cb5584
commit fd7777e4f4
6 changed files with 48 additions and 10 deletions

View File

@ -25,9 +25,6 @@ Component({
* 组件的方法列表
*/
methods: {
handleUse() {
alertInfo("敬请期待")
},
handleChange() {
const { data } = this.data;
const that = this;
@ -42,6 +39,18 @@ Component({
alertSuccess("兑换成功")
this.triggerEvent("change", { id, type: 2 })
})
},
handleUseIt() {
alertInfo("敬请期待")
},
async handleUse(e) {
const { data } = this.data;
const { code, message } = await redeemCoupons({ id: data.id, type: 2 })
if (code !== OK) {
alertInfo(message)
return;
}
this.triggerEvent("get", { id, type: 1 })
}
}
})

View File

@ -32,6 +32,7 @@
<view class="right">
<van-button wx:if="{{type === 1}}" type="info" size="small" bind:tap="handleUse">去领取</van-button>
<van-button wx:if="{{type === 2}}" type="info" size="small" bind:tap="handleChange">去兑换</van-button>
<van-button wx:if="{{type === 3}}" type="info" size="small" bind:tap="handleUseIt">去使用</van-button>
</view>
</view>
</view>

View File

@ -13,6 +13,7 @@ Page({
data: {
currentList: [],
canGetList: [],
active: 0,
},
/**
@ -20,6 +21,16 @@ Page({
*/
onLoad(options) {
},
onChange(e) {
console.log('e', e)
this.setData({
active: e.detail.index,
}, () => {
const { active } = this.data;
this.init(active);
})
},
/**
@ -33,8 +44,20 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
const { active } = this.data;
this.init(active);
},
init(active) {
switch(active) {
case 0:
this.getCurrent()
break;
case 1:
this.getCanGet();
break;
}
},
async getCurrent() {
const that = this;
loadingFunc(async() => {

View File

@ -2,7 +2,8 @@
"usingComponents": {
"navigator": "/components/navigator/index",
"van-tab": "@vant/weapp/tab/index",
"van-tabs": "@vant/weapp/tabs/index"
"van-tabs": "@vant/weapp/tabs/index",
"discount-coupon": "/components/discountCoupon/index"
},
"navigationStyle": "custom"
}

View File

@ -3,13 +3,17 @@
<van-tabs active="{{ active }}" bind:change="onChange">
<van-tab title="我的优惠券">
<view wx:if="{{currentList.length}}">
<view wx:for="{{currentList}}" wx:key="id">
<discount-coupon data="{{item}}" type="{{3}}" />
</view>
</view>
<empty bind:refresh="getCurrent" />
</van-tab>
<van-tab title="领券中心">
<view wx:if="{{canGetList.length}}">
<view wx:for="{{canGetList}}" wx:key="id">
<discount-coupon data="{{item}}" type="{{1}}" bind:get="getCanGet" />
</view>
</view>
<empty bind:refresh="getCanGet" />
</van-tab>

View File

@ -82,11 +82,11 @@ export const getIntegralRecord = async function({ page, size }) {
}
// 获取优惠券列表
export const getRedeemableCoupons = async function({ page, size, type }) {
export const getRedeemableCoupons = async function({ page = '', size = '', type }) {
return await GET(`/wx/getRedeemableCoupons?page=${page}&size=${size}&type=${type}`);
}
// 获取优惠券列表
// 兑换/领取优惠券
export const redeemCoupons = async function({ id, type }) {
return await POST(`/wx/redeemCoupons`, { id, type });
}