memberInfo.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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/distributionCenter/pages/member',
  24. })
  25. }, 1000)
  26. return;
  27. }
  28. this.member_id = member_id;
  29. },
  30. /**
  31. * 生命周期函数--监听页面显示
  32. */
  33. onShow: function () {
  34. let that = this;
  35. util.check_login_new().then((res) => {
  36. if (!res) {
  37. wx.showModal({
  38. title: '提示',
  39. content: '您还未登录',
  40. showCancel: false,
  41. success(res) {
  42. if (res.confirm) {
  43. wx.switchTab({
  44. url: '/lionfish_comshop/pages/user/me',
  45. })
  46. }
  47. }
  48. })
  49. } else {
  50. that.getData();
  51. }
  52. })
  53. },
  54. /**
  55. * 授权成功回调
  56. */
  57. authSuccess: function () {
  58. let that = this;
  59. this.setData({
  60. needAuth: false
  61. }, () => {
  62. that.getData();
  63. })
  64. },
  65. getData: function(){
  66. wx.showLoading();
  67. var token = wx.getStorageSync('token');
  68. let that = this;
  69. app.util.request({
  70. url: 'entry/wxapp/user',
  71. data: {
  72. controller: 'distribution.get_parent_agent_info_bymemberid',
  73. token: token,
  74. member_id: that.member_id
  75. },
  76. dataType: 'json',
  77. success: function (res) {
  78. wx.hideLoading();
  79. if (res.data.code == 0) {
  80. console.log(res.data.data)
  81. that.setData({
  82. info: res.data.data
  83. })
  84. }else{
  85. wx.showModal({
  86. title: '提示',
  87. content: res.data.msg,
  88. showCancel: false,
  89. success(res) {
  90. if (res.confirm) {
  91. console.log('用户点击确定')
  92. wx.reLaunch({
  93. url: '/lionfish_comshop/pages/user/me',
  94. })
  95. }
  96. }
  97. })
  98. }
  99. }
  100. })
  101. }
  102. })