memberCenter.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // pages/memberCenter/memberCenter.js
  2. var http = require('../../../utils/http')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. interval: 2000,
  9. duration: 1000,
  10. showRights: false,
  11. memberInfo: {},
  12. userInfo: {},
  13. userLevels: [],
  14. percent:0,
  15. isSmallScreen: false, // 是否小屏幕(高度低于568: 如iphone5)
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function(options) {
  21. var ths = this
  22. // 获取设备信息, 调整背景头图高度
  23. wx.getSystemInfo({
  24. success: function (res) {
  25. console.log(res)
  26. if (res.screenHeight <= 568){
  27. ths.setData({
  28. isSmallScreen: true
  29. })
  30. }
  31. },
  32. fail: function (res) { },
  33. complete: function (res) { },
  34. })
  35. // 获取用户信息
  36. this.setData({
  37. userInfo: wx.getStorageSync('loginResult')
  38. })
  39. // 获取当前会员信息
  40. this.getMemberInfo()
  41. },
  42. /**
  43. * 生命周期函数--监听页面初次渲染完成
  44. */
  45. onReady: function() {
  46. },
  47. /**
  48. * 生命周期函数--监听页面显示
  49. */
  50. onShow: function() {
  51. },
  52. /**
  53. * 跳转
  54. */
  55. routeTo(e) {
  56. const path = e.currentTarget.dataset.path
  57. if (path == 'scoreDet') {
  58. wx.navigateTo({
  59. url: '/pages/integralDetail/integralDetail',
  60. })
  61. }
  62. },
  63. /**
  64. * 获取用户当前会员信息
  65. */
  66. getMemberInfo() {
  67. wx.showLoading()
  68. var params = {
  69. url: '/p/score/scoreLevel/page',
  70. method: 'GET',
  71. data: {
  72. levelType: 0,
  73. },
  74. callBack: res => {
  75. wx.hideLoading()
  76. this.setData({
  77. memberInfo: res,
  78. userLevels: res.userLevels,
  79. percent:res.growth / res.nextGrowth *100
  80. })
  81. }
  82. }
  83. http.request(params)
  84. },
  85. /**
  86. * 显/隐更多权益
  87. */
  88. toogleShowRights() {
  89. this.setData({
  90. showRights: !this.data.showRights
  91. })
  92. },
  93. /**
  94. * 生命周期函数--监听页面隐藏
  95. */
  96. onHide: function() {
  97. },
  98. /**
  99. * 生命周期函数--监听页面卸载
  100. */
  101. onUnload: function() {
  102. },
  103. /**
  104. * 页面相关事件处理函数--监听用户下拉动作
  105. */
  106. onPullDownRefresh: function() {
  107. },
  108. /**
  109. * 页面上拉触底事件的处理函数
  110. */
  111. onReachBottom: function() {
  112. },
  113. /**
  114. * 用户点击右上角分享
  115. */
  116. onShareAppMessage: function() {
  117. }
  118. })