memberInfo.js 1.9 KB

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