// pages/admin/admin.js
const app=getApp();

Page({

 /**
  * 页面的初始数据
  */
 data: {
  page:0,
  datalist:[],
  pageNum:10,
 },
getdatalist(){
 let that=this;
 let head={
  'XX-Token':wx.getStorageSync('token')
 }
 let url ='index/member_center/admin';
 let params={
  page: that.data.page,
  pageNum: that.data.pageNum
 }
 app.post(url, params, head).then((res)=>{
  let datalist = that.data.datalist;
  let datadatalist = datalist.concat(res.volunteer);
  that.setData({
   datalist: datadatalist,
   page: res.page
  })
 }).catch((err)=>{
 })

},
 update_status(e){
 let that=this;
  let index = e.currentTarget.dataset.index;
  let url ='index/member_center/update_status';
  let head = {
   'XX-Token': wx.getStorageSync('token')
  }
  let params={
   id: e.currentTarget.id,
   status: e.currentTarget.dataset.status
  }
  app.post(url, params,head).then((res)=>{
   wx.showToast({
    title: '更新成功',
    icon: 'success',
    duration: 2000
   })
   let datalist = that.data.datalist;
   datalist[index].status = e.currentTarget.dataset.status;
   that.setData({
    datalist: datalist
   })
  
  }).catch((err)=>{
  })
 },
 /**
  * 生命周期函数--监听页面加载
  */
 onLoad: function (options) {
  let windowHeight = wx.getSystemInfoSync().windowHeight;// 屏幕的高度
  let windowWidth = wx.getSystemInfoSync().windowWidth // 屏幕的宽度
  this.setData({
   scroll_height: windowHeight * 750 / windowWidth
  })
 },

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

 },

 /**
  * 生命周期函数--监听页面显示
  */
 onShow: function () {
  let that=this;
  that.setData({
   page: 0,
   datalist: []
  })
  that.getdatalist();
 },

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

 },

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

 },

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

 },

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

 },

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

 }
})