diff --git a/components/discountCoupon/index.js b/components/discountCoupon/index.js
index 6ff50f7..4eae670 100644
--- a/components/discountCoupon/index.js
+++ b/components/discountCoupon/index.js
@@ -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 })
}
}
})
\ No newline at end of file
diff --git a/components/discountCoupon/index.wxml b/components/discountCoupon/index.wxml
index c1b1018..8db85d7 100644
--- a/components/discountCoupon/index.wxml
+++ b/components/discountCoupon/index.wxml
@@ -32,6 +32,7 @@
去领取
去兑换
+ 去使用
\ No newline at end of file
diff --git a/pages/discountCoupon/index.js b/pages/discountCoupon/index.js
index e74c84c..fee8d76 100644
--- a/pages/discountCoupon/index.js
+++ b/pages/discountCoupon/index.js
@@ -13,6 +13,7 @@ Page({
data: {
currentList: [],
canGetList: [],
+ active: 0,
},
/**
@@ -21,7 +22,17 @@ 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() => {
diff --git a/pages/discountCoupon/index.json b/pages/discountCoupon/index.json
index 06c8be8..f448c1b 100644
--- a/pages/discountCoupon/index.json
+++ b/pages/discountCoupon/index.json
@@ -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"
}
\ No newline at end of file
diff --git a/pages/discountCoupon/index.wxml b/pages/discountCoupon/index.wxml
index db106bb..6c4ca6f 100644
--- a/pages/discountCoupon/index.wxml
+++ b/pages/discountCoupon/index.wxml
@@ -3,13 +3,17 @@
-
+
+
+
-
+
+
+
diff --git a/service/system.js b/service/system.js
index fbf4cf9..94a2d5f 100644
--- a/service/system.js
+++ b/service/system.js
@@ -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 });
}