index.js 1.3 KB

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