index.vue 7.2 KB

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