// pages/schoolDetails/schoolDetails.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    schoolNo: '',
    originalSource: '',

    //数据部分
    schoolTitle:'',
    memberCount: '0',
    abilityPoint: '0',
    volunteerEventList:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      schoolNo: options.schoolNo,
      originalSource: options.originalSource
    })
    
    //检索学校详情
    wx.request({
      url: app.url + 'ajax_get_school_detail.php',
      data: {
        schoolNo: options.schoolNo,
        originalSource: options.originalSource
      },
      header: { 'content-type': 'application/json' },
      method: 'GET',
      dataType: 'json',
      success: function (res) {
        console.log(res)
        if (res.statusCode == 200) {
          that.setData({
            schoolTitle: res.data.result.schoolTitle,
            memberCount: res.data.result.memberCount,
            abilityPoint: res.data.result.abilityPoint,
            volunteerEventList: res.data.result.volunteerEventList,
          })
        }
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  //志愿者活动详情
  volunteersEventDetail(e) {
    let eventId = e.currentTarget.dataset['index']
    wx.navigateTo({
      url: '../volunteersEventDetail/volunteersEventDetail?eventId=' + eventId,
    });
  },
})