index.vue 5.8 KB

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