index.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // custom-tab-bar/index.js
  2. let app = getApp();
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. },
  9. /**
  10. * 组件的初始数据
  11. */
  12. data: {
  13. selectIndex: 0,
  14. tabbar: app.globalData.tabbar || {
  15. custom: true,
  16. color: "#000000",
  17. selectedColor: "#004445",
  18. backgroundColor: "#ffffff",
  19. position: "bottom",
  20. borderStyle: "white",
  21. list: [{
  22. "pagePath": "/pages/index/index",
  23. "text": "首页",
  24. iconfont: 'icon-shouye',
  25. show: true
  26. },
  27. {
  28. "pagePath": "/pages/shenhe/shenhe",
  29. "text": "审核",
  30. iconfont: 'icon-shenhe',
  31. show: false
  32. },
  33. {
  34. "pagePath": "/pages/cart/cart",
  35. "text": "购物袋",
  36. iconfont: 'icon-gouwudai2',
  37. show: true
  38. },
  39. {
  40. "pagePath": "/pages/user/index/index",
  41. "text": "我的",
  42. iconfont: 'icon-wode',
  43. show: true
  44. }
  45. ]
  46. }
  47. },
  48. observers: {
  49. selectIndex: function (selectIndex) {
  50. //console.log(selectIndex);
  51. }
  52. },
  53. onReady() {
  54. //console.log(111)
  55. },
  56. onShow() {
  57. //console.log("tabbar...")
  58. },
  59. /**
  60. * 组件的方法列表
  61. */
  62. methods: {
  63. goBar(e) {
  64. //console.log(e.currentTarget.dataset);
  65. let item = e.currentTarget.dataset.item;
  66. // this.setData({
  67. // selectIndex: e.currentTarget.dataset.index
  68. // });
  69. //console.log(this.data.selectIndex)
  70. wx.switchTab({
  71. url: item.pagePath,
  72. fail(e) {
  73. //console.log(e)
  74. }
  75. })
  76. }
  77. }
  78. })