me.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var app = getApp();
  2. var util = require('../../utils/util.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. info: [],
  9. member_info: {}
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. var that = this;
  16. if (!util.check_login()) {
  17. this.setData({
  18. needAuth: true
  19. })
  20. } else {
  21. this.getUser();
  22. this.getData();
  23. }
  24. },
  25. /**
  26. * 授权成功回调
  27. */
  28. authSuccess: function () {
  29. let that = this;
  30. this.setData({
  31. needAuth: false
  32. }, () => {
  33. that.getData();
  34. })
  35. },
  36. getData: function () {
  37. wx.showLoading();
  38. var token = wx.getStorageSync('token');
  39. let that = this;
  40. app.util.request({
  41. url: 'entry/wxapp/user',
  42. data: {
  43. controller: 'distribution.get_commission_info',
  44. token: token
  45. },
  46. dataType: 'json',
  47. success: function (res) {
  48. wx.hideLoading();
  49. if (res.data.code == 0) {
  50. that.setData({ info: res.data.data })
  51. } else {
  52. wx.showModal({
  53. title: '提示',
  54. content: res.data.msg,
  55. showCancel: false,
  56. success(res) {
  57. if (res.confirm) {
  58. console.log('用户点击确定')
  59. wx.reLaunch({
  60. url: '/lionfish_comshop/pages/user/me',
  61. })
  62. }
  63. }
  64. })
  65. }
  66. }
  67. })
  68. },
  69. getUser: function(){
  70. var token = wx.getStorageSync('token');
  71. let that = this;
  72. app.util.request({
  73. url: 'entry/wxapp/user',
  74. data: {
  75. controller: 'user.get_user_info',
  76. token: token
  77. },
  78. dataType: 'json',
  79. success: function (res) {
  80. wx.hideLoading();
  81. if (res.data.code == 0) {
  82. let commiss_diy_name = res.data.commiss_diy_name || '分销';
  83. wx.setNavigationBarTitle({
  84. title: `会员${commiss_diy_name}`,
  85. })
  86. that.setData({ member_info: res.data.data })
  87. } else {
  88. //is_login
  89. that.setData({ needAuth: true })
  90. wx.setStorage({
  91. key: "member_id",
  92. data: null
  93. })
  94. }
  95. }
  96. })
  97. },
  98. /**
  99. * 生命周期函数--监听页面显示
  100. */
  101. onShow: function () {
  102. }
  103. })