// pages/memberCenter/memberCenter.js var http = require('../../../utils/http') Page({ /** * 页面的初始数据 */ data: { interval: 2000, duration: 1000, showRights: false, memberInfo: {}, userInfo: {}, userLevels: [], percent:0, isSmallScreen: false, // 是否小屏幕(高度低于568: 如iphone5) }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { var ths = this // 获取设备信息, 调整背景头图高度 wx.getSystemInfo({ success: function (res) { console.log(res) if (res.screenHeight <= 568){ ths.setData({ isSmallScreen: true }) } }, fail: function (res) { }, complete: function (res) { }, }) // 获取用户信息 this.setData({ userInfo: wx.getStorageSync('loginResult') }) // 获取当前会员信息 this.getMemberInfo() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 跳转 */ routeTo(e) { const path = e.currentTarget.dataset.path if (path == 'scoreDet') { wx.navigateTo({ url: '/pages/integralDetail/integralDetail', }) } }, /** * 获取用户当前会员信息 */ getMemberInfo() { wx.showLoading() var params = { url: '/p/score/scoreLevel/page', method: 'GET', data: { levelType: 0, }, callBack: res => { wx.hideLoading() this.setData({ memberInfo: res, userLevels: res.userLevels, percent:res.growth / res.nextGrowth *100 }) } } http.request(params) }, /** * 显/隐更多权益 */ toogleShowRights() { this.setData({ showRights: !this.data.showRights }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })