user.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. parameter: {
  8. 'navbar': '1',
  9. 'return': '0',
  10. 'title': '个人中心',
  11. 'color': true,
  12. 'class': '0'
  13. },
  14. userInfo:{},
  15. MyMenus:[],
  16. },
  17. /**
  18. * 授权回调
  19. */
  20. onLoadFun:function(){
  21. this.getUserInfo();
  22. if (!this.data.MyMenus.length) this.getMyMenus();
  23. },
  24. /**
  25. *
  26. * 获取个人中心图标
  27. */
  28. getMyMenus: function () {
  29. var that = this;
  30. app.baseGet(app.U({ c: 'public_api', a: 'get_my_naviga' }), function (res) {
  31. that.setData({MyMenus:res.data.routine_my_menus});
  32. });
  33. },
  34. /**
  35. * 小程序设置
  36. */
  37. Setting:function(){
  38. wx.openSetting({
  39. success:function(res){
  40. console.log(res.authSetting)
  41. }
  42. });
  43. },
  44. /**
  45. * 跳转到用户资料
  46. */
  47. goUserInfo:function(){
  48. wx.navigateTo({
  49. url: '/pages/user_info/index',
  50. })
  51. },
  52. /**
  53. * 获取个人用户信息
  54. */
  55. getUserInfo:function(){
  56. var that=this;
  57. app.baseGet(app.U({c:'user_api',a:'my'}),function(res){
  58. that.setData({userInfo:res.data});
  59. });
  60. },
  61. /**
  62. * 页面跳转
  63. */
  64. goPages:function(e){
  65. console.log();
  66. if (e.currentTarget.dataset.url == '/pages/user_spread_user/index' && this.data.userInfo.statu==1) {
  67. if (!this.data.userInfo.is_promoter) return app.Tips({ title: '您还没有推广权限!!' });
  68. }
  69. wx.navigateTo({
  70. url: e.currentTarget.dataset.url
  71. })
  72. },
  73. /**
  74. * 生命周期函数--监听页面加载
  75. */
  76. onLoad: function (options) {
  77. this.setData({ MyMenus:app.globalData.MyMenus});
  78. },
  79. /**
  80. * 生命周期函数--监听页面隐藏
  81. */
  82. onHide: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面卸载
  86. */
  87. onUnload: function () {
  88. },
  89. onShow:function(){
  90. if (app.globalData.isLog) this.getUserInfo();
  91. },
  92. /**
  93. * 生命周期函数--监听页面卸载
  94. */
  95. onUnload: function () {
  96. },
  97. })