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

  /**
   * 页面的初始数据
   */
  data: {
    circleId:0,
    isOwner:false,
    circleDat:null,
    noticeDat:null
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      circleId: options.circleId,
    })
    
    //获取圈子信息
    this.circleinfo()
  },

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

  },

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

  },

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

  },

  //跳转到圈子成员
  circleMembers(){
    wx.navigateTo({
      url: '../circleMembers/circleMembers?circleId=' + this.data.circleId,
    });
  },

  //圈子公告
  circleNews(){
    wx.navigateTo({
      url: '../circleNotice/circleNotice' + this.data.circleId,
    })
  },

  //获取圈子信息
  circleinfo() {
    var that = this;
    var config = wx.getStorageSync('config');
    wx: wx.request({
      url: app.url + 'ajax_get_circle_info.php',
      data: {
        unionId: config.unionId,
        circleId:that.data.circleId
      },
      header: { 'content-type': 'application/json' },
      method: 'GET',
      dataType: 'json',
      success: function (res) {
        console.log(res)
        if (res.statusCode == 200) {
          if (res.data.status == "OK") {
            that.setData({
              isOwner: res.data.result.isOwner,
              circleDat: res.data.result.circleDat,
              noticeDat: res.data.result.noticeDat
            })
          }
        }
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  },

  //发布活动
  newCircleEvent(){
    wx.navigateTo({
      url: '../newCircleEvent/newCircleEvent' + this.data.circleId,
    })
  },

  //活动管理
  circleEvents(){
    wx.navigateTo({
      url: '../circleEvents/circleEvents' + this.data.circleId,
    })
  }
})