index.vue 4.4 KB

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