index.vue 3.7 KB

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