memberCenter.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. imgList1:[],
  21. imgList2:[],
  22. },
  23. showRule() {
  24. this.setData({
  25. myqr_show: true,
  26. myqr_blur: 25
  27. })
  28. },
  29. hidePoster(){
  30. this.setData({
  31. myqr_show:false,
  32. myqr_blur:100,
  33. })
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad: function (options) {
  39. // let userInfo = wx.getStorageSync('userInfo');
  40. //console.info(userInfo);
  41. },
  42. getMemberInfo: function () {
  43. let that = this
  44. util.request(api.getMemberInfo, {
  45. userId: app.globalData.userInfo.id
  46. }, 'GET')
  47. .then(res => {
  48. console.info(res);
  49. if (res.errno === 0) {
  50. let date = null;
  51. if (res.data.userInfo.memberExpiration)
  52. date = res.data.userInfo.memberExpiration.substr(0, 10);
  53. let saveMoney = Number(res.data.saveMoney).toFixed(2);
  54. that.setData({
  55. userInfo: res.data.userInfo,
  56. date: date,
  57. saveMoneyYuan: saveMoney.split('.')[0],
  58. saveMoneyPoint: saveMoney.split('.')[1]
  59. });
  60. app.globalData.memberUserInfo=res.data.userInfo;
  61. if(that.data.userInfo.level==1){
  62. that.getMemberAd();
  63. }
  64. } else {
  65. util.showErrorToast(res.errmsg);
  66. console.info(that.data.userInfo)
  67. }
  68. });
  69. },
  70. goBuyList() {
  71. wx.navigateTo({
  72. url: '/pages/member/buyList/buyList',
  73. })
  74. },
  75. goBuyMember() {
  76. if (!app.globalData.hasLogin){
  77. wx.navigateTo({
  78. url: "/pages/auth/login/login"
  79. });
  80. return;
  81. }
  82. wx.navigateTo({
  83. url: "/pages/member/buyMember/buyMember"
  84. });
  85. },
  86. /**
  87. * 生命周期函数--监听页面初次渲染完成
  88. */
  89. onReady: function () {
  90. },
  91. /**
  92. * 生命周期函数--监听页面显示
  93. */
  94. onShow: function () {
  95. this.getMemberInfo();
  96. },
  97. /**
  98. * 生命周期函数--监听页面隐藏
  99. */
  100. onHide: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面卸载
  104. */
  105. onUnload: function () {
  106. },
  107. /**
  108. * 页面相关事件处理函数--监听用户下拉动作
  109. */
  110. onPullDownRefresh: function () {
  111. },
  112. /**
  113. * 页面上拉触底事件的处理函数
  114. */
  115. onReachBottom: function () {
  116. },
  117. getMemberAd(){
  118. util.request(api.GetMemberAd, {
  119. },'GET')
  120. .then(res=>{
  121. if (res.errno === 0) {
  122. this.setData({
  123. imgList1:res.data.firstPurchase,
  124. imgList2:res.data.memberActivity
  125. });
  126. }
  127. });
  128. },
  129. /**
  130. * 用户点击右上角分享
  131. */
  132. onShareAppMessage: function () {
  133. }
  134. })