index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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. <supplier-home ref="home" v-if="isHomeData" />
  6. </view>
  7. <!-- 商品分类 -->
  8. <view class="content-main" :style="{ display: show_index == 1 ? 'block' : 'none' }">
  9. <supplier-category ref="category" v-if="isCategory" />
  10. </view>
  11. <!-- 通知消息 -->
  12. <view class="content-main" :style="{ display: show_index == 2 ? 'block' : 'none' }">
  13. <supplier-notice ref="notice" v-if="isNotice" />
  14. </view>
  15. <!-- 账户中心 -->
  16. <view class="content-main" :style="{ display: show_index == 3 ? 'flex' : 'none' }">
  17. <supplier-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
  27. v-if="item.id == 2 && upNum > 0"
  28. class="uni-badge uni-badge-error uni-small uni-badge--small icon-num "
  29. >
  30. {{ upNum | BadgeType }}
  31. </view>
  32. <view :class="{ tabBar_name: true, nav_active: show_index == item.id }">{{ item.name }}</view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. import supplierHome from '../components/home.vue'
  40. import supplierUser from '../components/user.vue'
  41. import supplierNotice from '../components/notice.vue'
  42. import supplierCategory from '../components/category.vue'
  43. export default {
  44. components: {
  45. supplierHome, //采美采购商城 0
  46. supplierUser, //账户中心 1
  47. supplierNotice, //通知消息 2
  48. supplierCategory //商品分类 3
  49. },
  50. data() {
  51. return {
  52. show_index: 3, //控制显示那个组件
  53. isUserData: false,
  54. isCategory: false,
  55. isNotice: false,
  56. isHomeData: false,
  57. isIphoneX: this.$store.state.isIphone,
  58. tab_nav_list: [
  59. //菜单列表
  60. {
  61. id: 0,
  62. name: '首页',
  63. icon: 'https://static.caimei365.com/app/img/icon/icon-home@3x.png',
  64. iconAc: 'https://static.caimei365.com/app/img/icon/icon-home-active@3x.png'
  65. },
  66. {
  67. id: 1,
  68. name: '分类',
  69. icon: 'https://static.caimei365.com/app/img/icon/icon-sort@3x.png',
  70. iconAc: 'https://static.caimei365.com/app/img/icon/icon-sort-active@3x.png'
  71. },
  72. {
  73. id: 2,
  74. name: '消息',
  75. icon: 'https://static.caimei365.com/app/img/icon/icon-news@3x.png',
  76. iconAc: 'https://static.caimei365.com/app/img/icon/icon-news-active@3x.png'
  77. },
  78. {
  79. id: 3,
  80. name: '我的',
  81. icon: 'https://static.caimei365.com/app/img/icon/icon-user@3x.png',
  82. iconAc: 'https://static.caimei365.com/app/img/icon/icon-user-active@3x.png'
  83. }
  84. ],
  85. nvabarData: {
  86. //顶部自定义导航
  87. showCapsule: 0, // 是否显示左上角图标 1表示显示 0表示不显示,
  88. showSearch: 0,
  89. title: '账户中心', // 导航栏 中间的标题
  90. textLeft: false
  91. },
  92. upNum:0,
  93. isIphoneX: this.$store.state.isIphoneX,
  94. CustomBar: this.CustomBar // 顶部导航栏高度
  95. }
  96. },
  97. filters: {
  98. BadgeType(value) {
  99. if(value){return value > 99 ? '99+' : value}
  100. }
  101. },
  102. onLoad() {
  103. this.$nextTick(() => {
  104. // 一定要等视图更新完再调用方法
  105. setTimeout(() => {
  106. this.isUserData = true
  107. this.initData();
  108. }, 100)
  109. })
  110. },
  111. methods: {
  112. async initData() {
  113. const userInfo = await this.$api.getStorage()
  114. this.ShopService.getAuthShopCount({ commonId: userInfo.shopId })
  115. .then(response => {
  116. this.upNum = response.data.count
  117. })
  118. .catch(error => {
  119. console.log('获取供应商未读通知消息数量')
  120. })
  121. },
  122. // 切换组件
  123. cut_index(type) {
  124. this.show_index = type
  125. if (this.show_index == 0) {
  126. this.isHomeData = true
  127. this.isUserData = false
  128. this.isNotice = false
  129. this.isCategory = false
  130. } else if (this.show_index == 1) {
  131. this.isHomeData = false
  132. this.isUserData = false
  133. this.isNotice = false
  134. this.isCategory = true
  135. } else if(this.show_index == 2){
  136. this.isHomeData = false
  137. this.isUserData = false
  138. this.isNotice = true
  139. this.isCategory = false
  140. }else if (this.show_index == 3) {
  141. this.isHomeData = false
  142. this.isNotice = false
  143. this.isUserData = true
  144. this.isCategory = false
  145. }
  146. },
  147. onPullDownRefresh() {
  148. if (this.show_index == 0) {
  149. this.$refs.home.getHomeInformation()
  150. } else if(this.show_index == 2){
  151. this.$refs.notice.getUserAuthShopMessageCount()
  152. }else if (this.show_index == 3) {
  153. this.$refs.user.initData()
  154. }
  155. uni.stopPullDownRefresh()
  156. }
  157. },
  158. onShareAppMessage(res) {
  159. //分享转发
  160. if (res.from === 'button') {
  161. // 来自页面内转发按钮
  162. }
  163. return {
  164. title: '生美医美正品采购服务平台',
  165. path: 'pages/tabBar/home/index',
  166. imageUrl: 'https://static.caimei365.com/app/img/bg/min-banner.jpg'
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. .seller-content{
  173. height: 100%;
  174. box-sizing: border-box;
  175. .content-main{
  176. height: 100%;
  177. }
  178. }
  179. .tabBar {
  180. width: 100%;
  181. height: 98rpx;
  182. background: #fff;
  183. border-top: 1px solid #e5e5e5;
  184. position: fixed;
  185. bottom: 0px;
  186. left: 0px;
  187. right: 0px;
  188. display: flex;
  189. align-items: center;
  190. justify-content: center;
  191. z-index: 999;
  192. .tabBar_list {
  193. width: 86%;
  194. display: flex;
  195. justify-content: space-between;
  196. image {
  197. width: 48rpx;
  198. height: 48rpx;
  199. margin-bottom: 2rpx;
  200. }
  201. .tabBar_item {
  202. width: 150rpx;
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. flex-direction: column;
  207. font-size: 20rpx;
  208. color: #999999;
  209. position: relative;
  210. .icon-num {
  211. position: absolute;
  212. right: 10rpx;
  213. top: -9rpx;
  214. }
  215. }
  216. }
  217. }
  218. .nav_active {
  219. color: $color-system;
  220. }
  221. </style>