usecenter.js 3.3 KB
// pages/usecenter/usecenter.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userinfo: '',
    token: '',
    footersel:2,
    selected: 2,
  },
  footersel(e) {
    console.log(e)
    let id = e.currentTarget.dataset.id;
    if(id==1){
      wx.redirectTo({
        url: '/pages/homepage/homepage',
      })
    }else if(id==2){
      wx.redirectTo({
        url: '/pages/usecenter/usecenter',
      })
    }
  },
  // 获取用户信息
  getuserinfo() {
    let that = this;
    var url = 'member/index';
    var params = {


    }
    app.post(url, params).then((res) => {
      console.log(res);
      that.setData({
        userinfo: res
      })





    }).catch((err) => {

    })
  },
  userlogin() {
    let token = wx.getStorageSync("token");
    if (token == '') {
      wx.showToast({
        title: '请先登录',
        icon: "none"
      })
      setTimeout(function() {
        wx.navigateTo({
          url: '/pages/index/index',
        })
      }, 1500)
    } else {
      wx.navigateTo({
        url: '/pages/index/index',
      })
    }

  },

  rankstar() {

    wx.navigateTo({
      url: '/pages/rank/rankpage',
    })


  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      token: wx.getStorageSync("token")
    })

  },
  // mycollect(){
  //   wx.navigateTo({
  //     url: '/pages/collectlsit/collectlist',
  //   })
  // },
  mycollect(e) {
    let token = wx.getStorageSync("token");
    if (token == '') {
      wx.showToast({
        title: '请先登录',
        icon: "none"
      })
      setTimeout(function() {
        wx.navigateTo({
          url: '/pages/index/index',
        })
      }, 1500)
    } else {
      let id = e.currentTarget.dataset.id;
      if (id == 1) {
        wx.navigateTo({
          url: '/pages/collectlist/collectlist',
        })
      } else if (id == 2) {
        wx.navigateTo({
          url: '/pages/canting/canting',
        })
      } else if (id == 3) {
        wx.navigateTo({
          url: '/pages/morephoto/morephoto',
        })
      } else if (id == 4) {
        wx.navigateTo({
          url: '/pages/mycomment/mycomment',
        })
      } else if (id == 5) {
        wx.navigateTo({
          url: '/pages/recommond/recommond',
        })
      }
    }



  },
  ziliao() {
    let token = wx.getStorageSync("token");
    if (token == '') {
      wx.showToast({
        title: '请先登录',
        icon: "none"
      })
      setTimeout(function() {
        wx.navigateTo({
          url: '/pages/index/index',
        })
      }, 1500)
    } else {
      wx.navigateTo({
        url: '/pages/personziliao/personziliao',
      })
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

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

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

  },

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

  },

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

  },

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

  },

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

  }
})