123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- // 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() {
- }
- })
|