memberCenter.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api');
  3. var user = require('../../../utils/user.js');
  4. var app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. userInfo: {
  11. nickName: '期待加入',
  12. avatarUrl: '/static/images/new/icon-user.png'
  13. },
  14. saveMoney: '0',
  15. date: '',
  16. saveMoneyYuan: '0',
  17. saveMoneyPoint: '0',
  18. myqr_show: false, //我的分享二维码
  19. myqr_blur: 100, //背景模糊值
  20. },
  21. showRule() {
  22. this.setData({
  23. myqr_show: true,
  24. myqr_blur: 25
  25. })
  26. },
  27. hidePoster(){
  28. this.setData({
  29. myqr_show:false,
  30. myqr_blur:100,
  31. })
  32. },
  33. /**
  34. * 生命周期函数--监听页面加载
  35. */
  36. onLoad: function (options) {
  37. // let userInfo = wx.getStorageSync('userInfo');
  38. //console.info(userInfo);
  39. },
  40. getMemberInfo: function () {
  41. let that = this
  42. util.request(api.getMemberInfo, {
  43. userId: app.globalData.userInfo.id
  44. }, 'GET')
  45. .then(res => {
  46. console.info(res);
  47. if (res.errno === 0) {
  48. let date = null;
  49. if (res.data.userInfo.memberExpiration)
  50. date = res.data.userInfo.memberExpiration.substr(0, 10);
  51. let saveMoney = Number(res.data.saveMoney).toFixed(2);
  52. that.setData({
  53. userInfo: res.data.userInfo,
  54. date: date,
  55. saveMoneyYuan: saveMoney.split('.')[0],
  56. saveMoneyPoint: saveMoney.split('.')[1]
  57. });
  58. } else {
  59. util.showErrorToast(res.errmsg);
  60. console.info(that.data.userInfo)
  61. }
  62. });
  63. },
  64. goBuyList() {
  65. wx.navigateTo({
  66. url: '/pages/member/buyList/buyList',
  67. })
  68. },
  69. goBuyMember() {
  70. if (!app.globalData.hasLogin){
  71. wx.navigateTo({
  72. url: "/pages/auth/login/login"
  73. });
  74. return;
  75. }
  76. wx.navigateTo({
  77. url: "/pages/member/buyMember/buyMember"
  78. });
  79. },
  80. /**
  81. * 生命周期函数--监听页面初次渲染完成
  82. */
  83. onReady: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面显示
  87. */
  88. onShow: function () {
  89. this.getMemberInfo();
  90. },
  91. /**
  92. * 生命周期函数--监听页面隐藏
  93. */
  94. onHide: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面卸载
  98. */
  99. onUnload: function () {
  100. },
  101. /**
  102. * 页面相关事件处理函数--监听用户下拉动作
  103. */
  104. onPullDownRefresh: function () {
  105. },
  106. /**
  107. * 页面上拉触底事件的处理函数
  108. */
  109. onReachBottom: function () {
  110. },
  111. /**
  112. * 用户点击右上角分享
  113. */
  114. onShareAppMessage: function () {
  115. }
  116. })