129 lines
2.1 KiB
JavaScript
129 lines
2.1 KiB
JavaScript
import commonApi from '../../../../api/common';
|
|
import userApi from '../../../../api/user';
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
detail:{},
|
|
activityId:'',
|
|
detailLoading:false,
|
|
getting:true,
|
|
|
|
isShowModal:false,
|
|
errorMsg:''
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.setData({
|
|
activityId:options.id||2
|
|
});
|
|
this.getActivityDetail();
|
|
userApi.coupon.check(options.id||2).then((data)=>{
|
|
if(!data.can_receive){
|
|
this.setData({
|
|
isShowModal:true,
|
|
errorMsg:data.message
|
|
})
|
|
}
|
|
})
|
|
},
|
|
getActivityDetail(){
|
|
this.setData({
|
|
detailLoading:true
|
|
})
|
|
commonApi.activities.detail(this.data.activityId).then((data)=>{
|
|
this.setData({
|
|
detailLoading:false,
|
|
getting:false
|
|
})
|
|
this.setData({
|
|
detail:data
|
|
})
|
|
}).catch(()=>{
|
|
this.setData({
|
|
detailLoading:false
|
|
})
|
|
})
|
|
},
|
|
getActivity(){
|
|
this.setData({
|
|
getting:true
|
|
})
|
|
commonApi.activities.receive(this.data.activityId).then((data)=>{
|
|
wx.showToast({
|
|
title: '领取成功',
|
|
});
|
|
this.setData({
|
|
isShowModal:true,
|
|
errorMsg:'恭喜您已领取成功!'
|
|
})
|
|
}).catch((e)=>{
|
|
this.setData({
|
|
isShowModal:true,
|
|
errorMsg:e.message||'领取错误'
|
|
})
|
|
this.setData({
|
|
getting:false
|
|
})
|
|
})
|
|
},
|
|
navToIndex(){
|
|
wx.reLaunch({
|
|
url: '/pages/help/index/index',
|
|
})
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |