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

  /**
   * 页面的初始数据
   */
  data: {
    value:'',
    fileList:[],
    fileList1: [],
    headerImg:'',
    frontImage:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // var that = this;
    // var config = wx.getStorageSync('config');
    // // var location = wx.getStorageSync('location');
    // wx: wx.request({
    //   url: app.url + 'ajax_get_circle_info.php',
    //   data: {
    //     unionId: config.unionId,
    //     circleId:7,
    //     userId:7
    //   },
    //   header: { 'content-type': 'application/json' },
    //   method: 'GET',
    //   dataType: 'json',
    //   success: function (res) {
    //     console.log(res)
    //   },
    //   fail: function (res) { },
    //   complete: function (res) { },
    // })
    
  },

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

  },

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

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

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

  },

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

  },
  delete(event) {
    const { index, name } = event.detail;
    const fileList = this.data[`fileList`];
    fileList.splice(index, 1);
    this.setData({ [`fileList`]: fileList });
  },
  afterRead(event) {
    const { file, name } = event.detail;
    const fileList = this.data[`fileList`];
    this.setData({
      [`fileList`]: fileList.concat(file),
      headerImg: file[0].path
    });
  },
  delete1(event) {
    const { index, name } = event.detail;
    const fileList1 = this.data[`fileList1`];
    fileList1.splice(index, 1);
    this.setData({ [`fileList1`]: fileList1 });
  },
  afterRead1(event) {
    const { file, name } = event.detail;
    const fileList1 = this.data[`fileList1`];

    this.setData({ 
      [`fileList1`]: fileList1.concat(file),
      frontImage: file[0].path
       });
  },
  onChange(event){
    this.setData({
      value: event.detail.value
    })
  },
  btnCircle(){
    console.log(this.data.headerImg,this.data.frontImage)
    this.circleNew2();
  },
  circleNew2(){
    var that = this;
    var config = wx.getStorageSync('config');
    var jingweidu = wx.getStorageSync('jingweidu');
    wx: wx.request({
      url: app.url + 'ajax_circle_new1.php',
      data: {
        unionId: config.unionId,
        circleId:1,
        comment:that.data.value,
        frontImage:that.data.frontImage
      },
      header: { 'content-type': 'application/json' },
      method: 'GET',
      dataType: 'json',
      success: function (res) {
        console.log(res)
        // if (res.statusCode == 200) {
        //   that.setData({
        //     familyEventList: res.data.result.familyEventList
        //   })
        // }
      },
      fail: function (res) { },
      complete: function (res) { },
    })
  }
})