index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // components/My_navBar/index.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. options: {
  7. addGlobalClass: true
  8. },
  9. properties: {
  10. },
  11. lifetimes: {
  12. ready: function () {
  13. // 在组件实例进入页面节点树时执行
  14. //获取当前登录用户名
  15. const that = this;
  16. setTimeout(() => {
  17. let data = wx.getStorageSync('account_list')[[wx.getStorageSync('userData').index]]
  18. let userName = '';
  19. (data.fbrand != null && data.fbrand != undefined) ? userName = data.fbrand + '-': userName = data.fname + '-';
  20. userName += (data.frole ? data.frole : '未知');
  21. that.setData({
  22. userName
  23. })
  24. }, 500)
  25. },
  26. detached: function () {
  27. // 在组件实例被从页面节点树移除时执行
  28. },
  29. },
  30. /**
  31. * 组件的初始数据
  32. */
  33. data: {
  34. userName: "", //用户名
  35. NavHeight: getApp().globalData.myNavBorHeight, //头部导航高度
  36. capsule: wx.getMenuButtonBoundingClientRect(), //胶囊位置
  37. },
  38. /**
  39. * 组件的方法列表
  40. */
  41. methods: {
  42. a1212() {
  43. //跳转到选择账号
  44. wx.navigateTo({
  45. url: '/pages/login/index?type=changeUser&inherit=1',
  46. })
  47. }
  48. }
  49. })