shop-tabbar.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // pages/shop-tabbar/shop-tabbar.js
  2. // components/production/production.js
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. currentTab:{
  9. type:Number
  10. }
  11. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. list: [{
  17. text: "店铺首页",
  18. iconPath: "../../images/tabbar/shop-home.png",
  19. selectedIconPath: "../../images/tabbar/shop-home-sel.png"
  20. },
  21. {
  22. text: "全部商品",
  23. iconPath: "../../images/tabbar/shop-prods.png",
  24. selectedIconPath: "../../images/tabbar/shop-prods-sel.png"
  25. },
  26. {
  27. text: "商品分类",
  28. iconPath: "../../images/tabbar/shop-category.png",
  29. selectedIconPath: "../../images/tabbar/shop-category-sel.png"
  30. },
  31. {
  32. text: "店内搜索",
  33. iconPath: "../../images/tabbar/shop-search.png",
  34. selectedIconPath: "../../images/tabbar/shop-search-sel.png"
  35. }
  36. ],
  37. },
  38. /**
  39. * 组件的方法列表
  40. */
  41. methods: {
  42. toProdPage: function(e) {
  43. var prodid = e.currentTarget.dataset.prodid;
  44. wx.navigateTo({
  45. url: '/pages/prod/prod?prodid=' + prodid,
  46. })
  47. },
  48. // tabbar切换
  49. tabChange(e) {
  50. const {
  51. index
  52. } = e.currentTarget.dataset
  53. this.setData({
  54. currentTab: index
  55. })
  56. if (this.data.currentTab == 0) {
  57. wx.redirectTo({
  58. url: '/pages/shopPage/shopPage',
  59. })
  60. } else if (this.data.currentTab == 1) {
  61. wx.redirectTo({
  62. url: '/pages/shopProds/shopProds',
  63. })
  64. } else if (this.data.currentTab == 2) {
  65. wx.redirectTo({
  66. url: '/pages/shopCategory/shopCategory',
  67. })
  68. } else if (this.data.currentTab == 3) {
  69. wx.redirectTo({
  70. url: '/pages/shopSearch/shopSearch',
  71. })
  72. }
  73. },
  74. },
  75. /**
  76. * 组件生命周期
  77. */
  78. lifetimes: {
  79. attached: function () {
  80. // 在组件实例进入页面节点树时执行
  81. console.log(this.properties.currentTab)
  82. },
  83. detached: function () {
  84. // 在组件实例被从页面节点树移除时执行
  85. },
  86. },
  87. })