index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view class="tabbar">
  3. <uv-tabbar :value="value" :fixed="true" @change="index=>value = index">
  4. <uv-tabbar-item text="网点" icon="home" @tap.stop="handleTabbarClick('index')"></uv-tabbar-item>
  5. <!-- <uv-tabbar-item text="优惠" icon="photo" @tap.stop="handleTabbarClick('coupon')"></uv-tabbar-item>-->
  6. <uv-tabbar-item text="" icon="scan" :iconSize="40" @tap.stop="handleTabbarClick('map')" style="margin-top: -125px">
  7. </uv-tabbar-item>
  8. <!-- <uv-tabbar-item text="订单" icon="play-right" @tap.stop="handleTabbarClick('order')"></uv-tabbar-item>-->
  9. <uv-tabbar-item text="我的" icon="account" @tap.stop="handleTabbarClick('user')"></uv-tabbar-item>
  10. </uv-tabbar>
  11. </view>
  12. </template>
  13. <script setup lang="ts" name="TabBar">
  14. import {onMounted, reactive, ref} from 'vue'
  15. import {onLoad, onShow, onTabItemTap} from "@dcloudio/uni-app";
  16. const props = defineProps({
  17. index: {
  18. type: Number,
  19. default: 0
  20. }
  21. })
  22. const value = ref(0)
  23. onLoad(() => {
  24. console.log("tabbar onLoad", props.index, value.value)
  25. value.value = props.index;
  26. })
  27. onShow(() => {
  28. console.log("tabbar onshow", props.index, value.value)
  29. value.value = props.index;
  30. })
  31. onMounted(()=>{
  32. console.log("tabbar onMounted", props.index, value.value)
  33. value.value = props.index;
  34. })
  35. const handleTabbarClick = (tab: string) => {
  36. uni.switchTab({
  37. url: `/pages/${tab}/index`,
  38. success: (e: any) => {
  39. console.log("tabbar switch>>>>", tab,e)
  40. },
  41. fail: (e: any) => {
  42. console.error("swtich error >>>>>", JSON.stringify(e))
  43. }
  44. })
  45. }
  46. </script>
  47. <style lang="scss" scoped>
  48. .tabbar {
  49. background-image: url("../../static/tabbar/bg.png");
  50. }
  51. </style>