This repository has been archived on 2024-07-11. You can view files and clone it, but cannot push or open issues or pull requests.
yoshop-wechat/pages/coupon/coupon.js

63 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2020-04-25 22:59:04 +08:00
const App = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
// 优惠券列表
list: [],
// show
notcont: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
// 当前页面参数
this.data.options = options;
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
// 获取优惠券列表
this.getCouponList();
},
/**
* 获取优惠券列表
*/
getCouponList: function() {
let _this = this;
App._get('coupon/lists', {}, function(result) {
_this.setData({
list: result.data.list,
notcont: !result.data.list.length
});
});
},
/**
* 立即领取
*/
receive: function(e) {
let _this = this,
couponId = e.currentTarget.dataset.couponId;
App._post_form('user.coupon/receive', {
coupon_id: couponId
}, function(result) {
App.showSuccess(result.msg);
// 获取优惠券列表
_this.getCouponList();
});
},
});