const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
const util = require("../../utils/util.js");
const Http = require("../../utils/HttpBasics");
const config = require("../../config/config");
let app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    navigationBarHeight,
    showPage: false,
    showPage1:false,
    message:'',
    goHomeUrl: "",
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      goHomeUrl: app.globalData.goHomeUrl
    })
    let that = this;
    if(options&&options.id){
      that.signIn(options.id);
      that.setData({
        id:options.id
      })
    }
  },
  signIn(id){
    let that = this;
    Http.post({
      url: config.api.activitySign,
      data: {
        activityId:id
      }
    }).then(res => {
      console.log(res)
      that.setData({
        showPage:true
      })
    }).catch(err=>{
      console.log(err);
      that.setData({
        showPage1: true,
        message: err.message
      })
    })
  },
  //跳转到报名详情页
  goSignUp(e) {
    let activityId = e.currentTarget.dataset.id;
    if (activityId){
      wx.navigateTo({
        url: `/pages/radetail/index?id=${activityId}`,
      })
    }else{
      wx.showToast({
        title: '此活动报名已结束',
      })
    }
  },
  goback: function () {
    let this_=this
    wx.switchTab({
      url: this_.data.goHomeUrl,
    })
  }
})