index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="w-all h-all flex flex-column bg-F5F7FA">
  3. <image src="/static/images/yuexuan_home_top_bg.png" class="absolute top-0 left-0 zi-1 w-all h-266"></image>
  4. <uni-nav-bar fixed :statusBar="true" left-icon="back" backgroundColor="" :border="false" rightWidth="0"
  5. leftWidth="0">
  6. <template v-slot:default>
  7. <view class="scs-headr-default flex items-center h-44">
  8. <view class="flex-1">
  9. <view class="fw-500 fs-18 text-000000">芳华悦选</view>
  10. <view class="fw-400 fs-12 text-999999">让家人放心吃健康安全的食品</view>
  11. </view>
  12. <view class="img-car flex items-center justify-center w-32 h-32 bg-white rounded-32">
  13. <image class="w-20 h-20" src="/static/images/shopping_car_icon.png"></image>
  14. </view>
  15. </view>
  16. </template>
  17. </uni-nav-bar>
  18. <!-- 搜索栏 -->
  19. <HomeSearch @onSearch="onSearch" />
  20. <!-- tab栏 -->
  21. <view class="scs-nav-bar px-12 mt-11 rounded-8 zi-10">
  22. <view class="flex items-center relative ">
  23. <scsScrollNavbar :tabsData="tabsData" :tabCurrentIndex="tabCurrentIndex" nameKey="name"
  24. key="tabCurrentIndex" @tabChange="tabChange" />
  25. <image class="w-32 h-32 absolute bottom-2.5 right-40 zi-10" src="/static/images/white_gradient_bg.png">
  26. </image>
  27. <view class="flex items-center justify-center">
  28. <image class="w-16 h-16 ml-5 mr-12" src="/static/images/product_section_icon.png"></image>
  29. <image class="w-16 h-16 mr-7" src="/static/images/home_filter_icon.png"></image>
  30. </view>
  31. </view>
  32. <homeMenu :autoplay="false" :swiperList="menusData" />
  33. </view>
  34. <!-- 商品栏 -->
  35. <homeProduct />
  36. <!-- tab栏 -->
  37. <view class="bg-white w-all flex-1 mt-10 rounded-t-8 px-28">
  38. <scsScrollIconbar :tabsData="tabsProduct" :tabCurrentIndex="tabsProductIndex" nameKey="name"
  39. key="tabsProductIndex" @tabChange="tabProductChange" />
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import scsScrollNavbar from '@/components/public/scs-scroll-navbar.vue'
  45. import scsScrollIconbar from '@/components/public/scs-scroll-iconbar.vue'
  46. import homeMenu from './components/home-menu.vue'
  47. import homeProduct from './components/home-product.vue'
  48. import HomeSearch from './components/home-search.vue'
  49. import {
  50. getMenu,
  51. getCanvas,
  52. getIndexData,
  53. getTuiDoctor,
  54. getTuiArticle,
  55. getTuiDoctorOrder,
  56. getCartCount
  57. } from '@/api/index'
  58. export default {
  59. components: {
  60. scsScrollNavbar,
  61. homeMenu,
  62. homeProduct,
  63. HomeSearch,
  64. scsScrollIconbar,
  65. },
  66. data() {
  67. return {
  68. statusBarHeight: 0,
  69. tabsData: [
  70. { name: '精选' },
  71. { name: '健康新品' },
  72. { name: '营养保健' },
  73. { name: '健康滋补' },
  74. ],
  75. tabCurrentIndex: 0,
  76. menusData: [],
  77. tabsProduct: [
  78. { name: '今日主推' },
  79. { name: '健康新品' },
  80. { name: '营养保健' },
  81. ],
  82. tabsProductIndex: 0,
  83. }
  84. },
  85. onLoad() {
  86. },
  87. onShow() {
  88. this.getMenuData();
  89. },
  90. methods: {
  91. // 搜索
  92. onSearch(keyword) {
  93. },
  94. // 分类tab切换
  95. tabChange(index) {
  96. this.tabCurrentIndex = index;
  97. },
  98. // 商品tab切换
  99. tabProductChange(index) {
  100. this.tabsProductIndex = index;
  101. },
  102. // 获取分类数据
  103. async getMenuData() {
  104. const { code, data, msg } = await getMenu();
  105. if (code == 200) {
  106. this.menusData = this.$scsUtils.splitArrayIntoSubarrays(data, 5) || []
  107. console.log("---------11111111-------", this.menusData)
  108. } else {
  109. uni.showToast({
  110. title: msg,
  111. icon: 'none'
  112. })
  113. }
  114. },
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. ::v-deep .scs-scroll-navbar {
  120. width: calc(100vw - 140rpx) !important;
  121. }
  122. .scs-nav-bar {
  123. background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 49.52%, #F5F7FA 100%);
  124. }
  125. </style>