dm-wechat-mini/pages/my/promation/activities/index.js
2025-03-04 20:38:05 +08:00

125 lines
2.0 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
})
})
},
getActivity(){
this.setData({
getting:true
})
commonApi.activities.receive(this.data.activityId).then((data)=>{
wx.showToast({
title: '领取成功',
});
const pages = getCurrentPages();
if(pages.length>1){
wx.navigateBack();
}else{
wx.reLaunch({
url: '/pages/help/index/index',
})
}
}).catch((e)=>{
this.setData({
getting:false
})
})
},
navToIndex(){
wx.reLaunch({
url: '/pages/help/index/index',
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})