user.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. if (e.currentTarget.dataset.url == '/pages/user_spread_user/index' && this.data.userInfo.statu==1) {
  66. if (!this.data.userInfo.is_promoter) return app.Tips({ title: '您还没有推广权限!!' });
  67. }
  68. wx.navigateTo({
  69. url: e.currentTarget.dataset.url
  70. })
  71. },
  72. /**
  73. * 生命周期函数--监听页面加载
  74. */
  75. onLoad: function (options) {
  76. this.setData({ MyMenus:app.globalData.MyMenus});
  77. },
  78. /**
  79. * 生命周期函数--监听页面隐藏
  80. */
  81. onHide: function () {
  82. },
  83. /**
  84. * 生命周期函数--监听页面卸载
  85. */
  86. onUnload: function () {
  87. },
  88. onShow:function(){
  89. if (app.globalData.isLog) this.getUserInfo();
  90. },
  91. /**
  92. * 生命周期函数--监听页面卸载
  93. */
  94. onUnload: function () {
  95. },
  96. })