index.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 = getApp().globalData.account_list[wx.getStorageSync('userData').index];
  18. let data = wx.getStorageSync('account_list')[[wx.getStorageSync('userData').index]]
  19. let userName = '';
  20. (data.fbrand != null && data.fbrand != undefined) ? userName = data.fbrand + '-': userName = data.fname + '-';
  21. userName += (data.frole ? data.frole : '未知');
  22. that.setData({
  23. userName
  24. })
  25. }, 300)
  26. },
  27. detached: function () {
  28. // 在组件实例被从页面节点树移除时执行
  29. },
  30. },
  31. /**
  32. * 组件的初始数据
  33. */
  34. data: {
  35. userName: "", //用户名
  36. NavHeight: getApp().globalData.myNavBorHeight, //头部导航高度
  37. capsule: wx.getMenuButtonBoundingClientRect(), //胶囊位置
  38. },
  39. /**
  40. * 组件的方法列表
  41. */
  42. methods: {
  43. a1212() {
  44. //跳转到选择账号
  45. wx.navigateTo({
  46. url: '/pages/login/index?type=changeUser',
  47. })
  48. }
  49. }
  50. })