index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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/home.vue'
  30. import sellerUser from '../components/user.vue'
  31. import sellerCategory from '../components/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. //菜单列表
  47. {
  48. id: 0,
  49. name: '首页',
  50. icon: 'https://static.caimei365.com/app/img/icon/icon-home@3x.png',
  51. iconAc: 'https://static.caimei365.com/app/img/icon/icon-home-active@3x.png'
  52. },
  53. {
  54. id: 1,
  55. name: '分类',
  56. icon: 'https://static.caimei365.com/app/img/icon/icon-sort@3x.png',
  57. iconAc: 'https://static.caimei365.com/app/img/icon/icon-sort-active@3x.png'
  58. },
  59. {
  60. id: 2,
  61. name: '我的',
  62. icon: 'https://static.caimei365.com/app/img/icon/icon-user@3x.png',
  63. iconAc: 'https://static.caimei365.com/app/img/icon/icon-user-active@3x.png'
  64. }
  65. ],
  66. nvabarData: {
  67. //顶部自定义导航
  68. showCapsule: 0, // 是否显示左上角图标 1表示显示 0表示不显示,
  69. showSearch: 0,
  70. title: '账户中心', // 导航栏 中间的标题
  71. textLeft: false
  72. },
  73. isIphoneX: this.$store.state.isIphoneX,
  74. CustomBar: this.CustomBar // 顶部导航栏高度
  75. }
  76. },
  77. onLoad() {
  78. this.$nextTick(() => {
  79. // 一定要等视图更新完再调用方法
  80. setTimeout(() => {
  81. this.isUserData = true
  82. }, 100)
  83. })
  84. },
  85. methods: {
  86. // 切换组件
  87. cut_index(type) {
  88. this.show_index = type
  89. if (this.show_index == 0) {
  90. this.isHomeData = true
  91. this.isUserData = false
  92. this.isCategory = false
  93. } else if (this.show_index == 1) {
  94. this.isHomeData = false
  95. this.isUserData = false
  96. this.isCategory = true
  97. } else if (this.show_index == 2) {
  98. this.isHomeData = false
  99. this.isUserData = true
  100. this.isCategory = false
  101. }
  102. },
  103. onPullDownRefresh() {
  104. if (this.show_index == 0) {
  105. this.$refs.home.getHomeInformation()
  106. } else if (this.show_index == 2) {
  107. this.$refs.user.initData()
  108. }
  109. uni.stopPullDownRefresh()
  110. }
  111. },
  112. onShareAppMessage(res) {
  113. //分享转发
  114. if (res.from === 'button') {
  115. // 来自页面内转发按钮
  116. }
  117. return {
  118. title: '生美医美正品采购服务平台',
  119. path: 'pages/tabBar/home/index',
  120. imageUrl: 'https://static.caimei365.com/app/img/bg/min-banner.jpg'
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. .tabBar {
  127. width: 100%;
  128. height: 98rpx;
  129. background: #fff;
  130. border-top: 1px solid #e5e5e5;
  131. position: fixed;
  132. bottom: 0px;
  133. left: 0px;
  134. right: 0px;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. z-index: 999;
  139. .tabBar_list {
  140. width: 86%;
  141. display: flex;
  142. justify-content: space-between;
  143. image {
  144. width: 48rpx;
  145. height: 48rpx;
  146. margin-bottom: 2rpx;
  147. }
  148. .tabBar_item {
  149. width: 150rpx;
  150. display: flex;
  151. justify-content: center;
  152. align-items: center;
  153. flex-direction: column;
  154. font-size: 20rpx;
  155. color: #999999;
  156. }
  157. }
  158. }
  159. .nav_active {
  160. color: $color-system;
  161. }
  162. </style>