index.vue 3.9 KB

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