tabBar.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // components/tabBar/tabBar.js
  2. const app = getApp()
  3. Component({
  4. // 纯数据字段规则
  5. options: {
  6. pureDataPattern: /^_/
  7. },
  8. // 组件的属性列表
  9. properties: {
  10. _tabBarInd: {
  11. type: Number,
  12. value: 0
  13. }
  14. },
  15. /**
  16. * 组件的初始数据
  17. */
  18. data: {
  19. isFullscreen: false,
  20. navList: [{
  21. name: "悦所", //文本
  22. current: 0, //是否是当前页,0不是 1是
  23. style: 0, //样式
  24. typea: "https://api.zhumi.tech/MiniProgram/image/home.png", //不同图标
  25. typec: "https://api.zhumi.tech/MiniProgram/image/homec.png",
  26. fn: 'index'
  27. },
  28. {
  29. name: "服务",
  30. current: 0,
  31. style: 0,
  32. typea: "https://api.zhumi.tech/MiniProgram/image/packages.png", //不同图标
  33. typec: "https://api.zhumi.tech/MiniProgram/image/packagesc.png",
  34. fn: 'packages'
  35. },
  36. {
  37. name: "超人妈妈学院",
  38. current: 0,
  39. style: 2,
  40. ico: '',
  41. fn: 'supermama'
  42. },
  43. {
  44. name: "活动",
  45. current: 0,
  46. style: 0,
  47. typea: "https://api.zhumi.tech/MiniProgram/image/promotion.png", //不同图标
  48. typec: "https://api.zhumi.tech/MiniProgram/image/promotionc.png",
  49. fn: 'promotion'
  50. }, {
  51. name: "我的",
  52. current: 0,
  53. style: 0,
  54. typea: "https://api.zhumi.tech/MiniProgram/image/mine.png", //不同图标
  55. typec: "https://api.zhumi.tech/MiniProgram/image/minec.png",
  56. fn: 'mine'
  57. }
  58. ]
  59. },
  60. lifetimes: {
  61. attached: function() {
  62. this.SetNavList()
  63. }
  64. },
  65. // 旧式的定义方式,可以保持对 <2.2.3 版本基础库的兼容
  66. attached: function() {
  67. this.SetNavList()
  68. },
  69. ready:function() {
  70. let full = wx.getStorageSync('isFullscreen');
  71. // console.log(full)
  72. this.setData({
  73. isFullscreen: full
  74. })
  75. },
  76. methods: {
  77. // 设置tabbar数据
  78. SetNavList: function() {
  79. let index = this.data._tabBarInd
  80. let deletedtodo = 'navList[' + index + ']'
  81. this.setData({
  82. [deletedtodo + '.current']: 1,
  83. [deletedtodo + '.style']: index != 2 ? 1 : 2,
  84. [deletedtodo + '.fn']: ''
  85. })
  86. },
  87. // tabbar跳转页面
  88. gotoPage: function(event) {
  89. let str = event.currentTarget.dataset.fn
  90. let url = `/pages/${str}/${str}`
  91. app.gopage(url)
  92. }
  93. }
  94. })