index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <button size="mini" @click="toCommon('pages/login/index')">登录页面</button>
  6. <button size="mini" @click="toCommon('pages/home/index')">首页</button>
  7. <button size="mini" @click="toCommon('pages/store/index')">微店</button>
  8. <button size="mini" @click="toCommon('pages/week/index')">周边</button>
  9. <button size="mini" @click="toCommon('pages/market/index')">购物车</button>
  10. <button size="mini" @click="toCommon('pages/my/index')">我的1</button>
  11. </view>
  12. <view class="two">
  13. <tabs :tabs="tabs" @tabsChange="tabsChange">
  14. <view v-show="tabs.active=='a'">1</view>
  15. <view v-show="tabs.active=='b'">2</view>
  16. <view v-show="tabs.active=='c'">3</view>
  17. <view v-show="tabs.active=='d'">4</view>
  18. <view v-show="tabs.active=='e'">5</view>
  19. </tabs>
  20. </view>
  21. </view>
  22. </mobile-frame>
  23. </template>
  24. <script>
  25. import tabs from '@/components/tabs/index.vue';
  26. export default {
  27. components: {
  28. tabs
  29. },
  30. data() {
  31. return {
  32. tabs: {
  33. active: 'a',
  34. menu: [ //菜单列表
  35. {
  36. title: '选项卡一',
  37. active: 'a'
  38. },
  39. {
  40. title: '选项卡二',
  41. active: 'b'
  42. },
  43. {
  44. title: '选项卡三',
  45. active: 'c'
  46. },
  47. {
  48. title: '选项卡四',
  49. active: 'd'
  50. },
  51. {
  52. title: '选项卡五',
  53. active: 'e'
  54. }
  55. ]
  56. }
  57. };
  58. },
  59. onShow: function() {
  60. const that = this;
  61. // 监听用户是否登录
  62. that.watchLogin();
  63. },
  64. methods: {
  65. // 公共跳转
  66. toCommon(e) {
  67. uni.navigateTo({
  68. url: `/${e}`
  69. });
  70. },
  71. watchLogin() {
  72. uni.redirectTo({
  73. url: `/pages/home/index`
  74. })
  75. },
  76. tabsChange(e) {
  77. const that = this;
  78. that.$set(that.tabs, `active`, e.active)
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .main {
  85. .one {
  86. text-align: center;
  87. button {
  88. margin: 2vw;
  89. }
  90. }
  91. .two {
  92. padding: 2vw;
  93. .scrollView {
  94. display: flex;
  95. white-space: nowrap;
  96. text-align: center;
  97. }
  98. .list {
  99. display: inline-block;
  100. padding: 2vw;
  101. margin: 0 1.5vw;
  102. text-align: center;
  103. border-radius: 5px;
  104. text {
  105. font-weight: bold;
  106. font-size: var(--font14Size);
  107. }
  108. }
  109. }
  110. }
  111. </style>