index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="content" :style="{paddingBottom:isIphoneX?'140rpx':'98rpx',marginTop:CustomBar+'px'}">
  3. <cu-custom :navbar-data='nvabarData'></cu-custom>
  4. <!-- 采美采购商城 -->
  5. <view :style="{'display':show_index == 0 ?'block':'none'}">
  6. <seller-home ref="home" v-if="isHomeData"></seller-home>
  7. </view>
  8. <!-- 商品分类 -->
  9. <view :style="{'display':show_index == 1? 'block':'none'}">
  10. <seller-category ref="category" v-if="isCategory"></seller-category>
  11. </view>
  12. <!-- 账户中心 -->
  13. <view :style="{'display':show_index == 2 ?'flex':'none'}">
  14. <seller-user ref="user" v-if="isUserData"></seller-user>
  15. </view>
  16. <!-- isIphoneX判断是否为刘海屏在main.js里,好像uniapp有一个css变量获取刘海屏的安全区域 -->
  17. <view class="tabBar" :style="{height:isIphoneX?'140rpx':'98rpx'}">
  18. <!-- 导航的中间圆圈 -->
  19. <view class="tabBar_list" :style="{paddingBottom:isIphoneX?'40rpx':''}">
  20. <view v-for="(item) in tab_nav_list" :key="item.id" class="tabBar_item" @tap="cut_index(item.id)">
  21. <image v-if="show_index == item.id" :src="item.iconAc"></image>
  22. <image v-else :src="item.icon"></image>
  23. <view :class="{'tabBar_name':true,'nav_active':show_index == item.id}">{{item.name}}</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import sellerHome from '@/components/seller/home.vue'
  31. import sellerUser from '@/components/seller/user.vue'
  32. import sellerCategory from '@/components/seller/category.vue'
  33. export default {
  34. components: {
  35. sellerHome,//采美采购商城 0
  36. sellerUser,//账户中心 1
  37. sellerCategory,//商品分类 2
  38. },
  39. data() {
  40. return {
  41. show_index:2,//控制显示那个组件
  42. isUserData: false,
  43. isCategory: false,
  44. isHomeData: false,
  45. tab_nav_list :[//菜单列表
  46. {'id':0,'name':'首页',icon:'../../../static/icon-home@3x.png',iconAc:'../../../static/icon-home-active@3x.png'},
  47. {'id':1,'name':'分类',icon:'../../../static/icon-sort@3x.png',iconAc:'../../../static/icon-sort-active@3x.png'},
  48. {'id':2,'name':'我的',icon:'../../../static/icon-user@3x.png',iconAc:'../../../static/icon-user-active@3x.png'}
  49. ],
  50. nvabarData: { //顶部自定义导航
  51. showCapsule: 0, // 是否显示左上角图标 1表示显示 0表示不显示,
  52. showSearch: 0,
  53. title: '账户中心', // 导航栏 中间的标题
  54. },
  55. isIphoneX:this.$store.state.isIphoneX,
  56. CustomBar:this.CustomBar,// 顶部导航栏高度
  57. }
  58. },
  59. onLoad() {
  60. this.$nextTick(()=>{// 一定要等视图更新完再调用方法
  61. setTimeout(()=>{
  62. this.isUserData = true
  63. },100)
  64. })
  65. },
  66. methods: {
  67. // 切换组件
  68. cut_index(type){
  69. this.show_index = type
  70. if(this.show_index == 0){
  71. this.isHomeData = true
  72. this.isUserData = false
  73. this.isCategory = false
  74. // this.$refs.home.getCheekeyCode()
  75. this.nvabarData.title = '采美采购商城'
  76. }else if(this.show_index == 1){
  77. this.isHomeData = false
  78. this.isUserData = false
  79. this.isCategory = true
  80. // this.$refs.category.getProductCate()
  81. this.nvabarData.title = '商品分类'
  82. }else if(this.show_index == 2){
  83. this.isHomeData = false
  84. this.isUserData = true
  85. this.isCategory = false
  86. // this.$refs.user.initData()
  87. this.nvabarData.title = '账户中心'
  88. }
  89. },
  90. onPullDownRefresh(){
  91. if(this.show_index == 0){
  92. this.$refs.home.getCheekeyCode()
  93. }else if(this.show_index == 2){
  94. this.$refs.user.initData()
  95. }
  96. uni.stopPullDownRefresh()
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. .content{
  103. background: #FFFFFF;
  104. }
  105. .tabBar{
  106. width:100%;
  107. height: 98rpx;
  108. background: #fff;
  109. border-top:1px solid #E5E5E5;
  110. position: fixed;
  111. bottom:0px;
  112. left:0px;
  113. right:0px;
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. .tabBar_list{
  118. width:86%;
  119. display: flex;
  120. justify-content: space-between;
  121. image{
  122. width:48rpx;
  123. height: 48rpx;
  124. margin-bottom:2rpx
  125. }
  126. .tabBar_item{
  127. width:150rpx;
  128. display: flex;
  129. justify-content: center;
  130. align-items: center;
  131. flex-direction: column;
  132. font-size: 20rpx;
  133. color: #999999;
  134. }
  135. }
  136. }
  137. .nav_active{
  138. color: $color-system;
  139. }
  140. </style>