// pages/member/more.js
import api from '../../utils/api'
import util from '../../utils/util'
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    memberInfo: {},
    sharePath: 'pages/share/share',
    shareInfo: {},
    more: true,
    moreAnimation: {},
    top: true,
    mpType: app.globalData.mpType
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    api.getUserInfo().then(res => {
      this.setData({
        userInfo: res.data
      })
    }, err => {
      console.log(err)
    })

    api.getMemberList({
      offset: 9999
    }).then(res => {
      this.setData({
        memberInfo: res.data
      })
    }, err => {
      console.log(err)
    })

    this.getShareInfo()

    let animation = wx.createAnimation({})
    setInterval(() => {
      let top = this.data.top ? '-145rpx' : '-125rpx'
      animation.top(top).step()
      this.setData({
        moreAnimation: animation.export(),
        top: !this.data.top
      })
    }, 500)
  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

  getShareInfo: function () {
    api.getShareInfo({
      data: {
        path: this.data.sharePath
      }
    }).then(res => {
      this.setData({
        shareInfo: res.data
      })
    }).catch(err => {
      console.log('getShare', err)
    })
  },

  shareTo: function () {
    this.setData({
      more: false
    })
  }
})