index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <!--
  2. * @Author: jmy
  3. * @Date: 2026-01-06 12:02:41
  4. * @LastEditors: Please set LastEditors
  5. * @LastEditTime: 2026-01-06 15:02:20
  6. * @Description: 首页
  7. -->
  8. <template>
  9. <view class="w-all h-all flex flex-column bg-F5F7FA">
  10. <image src="/static/images/yuexuan_home_top_bg.png" class="absolute top-0 left-0 zi-1 w-all h-266"></image>
  11. <uni-nav-bar fixed :statusBar="true" left-icon="back" backgroundColor="" :border="false" rightWidth="0"
  12. leftWidth="0">
  13. <template v-slot:default>
  14. <view class="scs-headr-default flex items-center h-44">
  15. <view class="flex-1">
  16. <view class="fw-500 fs-18 text-000000">芳华悦选</view>
  17. <view class="fw-400 fs-12 text-999999">让家人放心吃健康安全的食品</view>
  18. </view>
  19. <view class="img-car flex items-center justify-center w-32 h-32 bg-white rounded-32">
  20. <image class="w-20 h-20" src="/static/images/shopping_car_icon.png"></image>
  21. </view>
  22. </view>
  23. </template>
  24. </uni-nav-bar>
  25. <!-- 搜索栏 -->
  26. <HomeSearch @onSearch="onSearch" />
  27. <view class="zi-10 flex-1 overflow-auto">
  28. <ScsScrollView ref="fresher" refresherBackground="transparent" :refresherEnabled="false"
  29. @onfresher="onfresher" @loadMore="loadMore" @handleScroll="(flag) => isShowToTop = flag">
  30. <template v-slot:list>
  31. <!-- tab栏 -->
  32. <view class="scs-nav-bar px-12 mt-11 rounded-8">
  33. <view class="flex items-center relative ">
  34. <ScsScrollNavbar :tabsData="tabsData" :tabCurrentIndex="tabCurrentIndex" nameKey="name"
  35. key="tabCurrentIndex" @tabChange="tabChange" />
  36. <image class="w-32 h-32 absolute bottom-2.5 right-40 zi-10"
  37. src="/static/images/white_gradient_bg.png">
  38. </image>
  39. <view class="flex items-center justify-center">
  40. <image class="w-16 h-16 ml-5 mr-12" src="/static/images/product_section_icon.png">
  41. </image>
  42. <image class="w-16 h-16 mr-7" src="/static/images/home_filter_icon.png"></image>
  43. </view>
  44. </view>
  45. <HomeMenu :autoplay="false" :swiperList="menusData" />
  46. </view>
  47. <!-- 商品栏 -->
  48. <HomeProduct />
  49. <!-- tab栏 -->
  50. <view class="tab-goods w-all mt-10 rounded-t-8 px-28">
  51. <ScsScrollNavbar :tabsData="tabsProduct" activeColor="#02B176" textColor="#333333"
  52. :isUseActImg="true" :isScroll="false" :isUseLine="false" :calcLeft="28"
  53. :tabCurrentIndex="tabsProductIndex" nameKey="name" key="tabsProductIndex"
  54. @tabChange="tabProductChange" />
  55. </view>
  56. <!-- 商品列表 -->
  57. <HomeGoods />
  58. <u-gap height="15"></u-gap>
  59. </template>
  60. </ScsScrollView>
  61. <ScsScrollTop :isShowToTop="isShowToTop" @goTop="$refs.fresher.goTop" />
  62. </view>
  63. <!-- 频道 可拖拽 -->
  64. <!-- <channel></channel> -->
  65. <channel ref="channelManager" :initial-my-channels="myChannels" :initial-all-channels="allChannels"
  66. :active-channel-id="activeChannelId" @channels-change="onChannelsChange" @order-change="onOrderChange"
  67. @channel-tap="onChannelTap" />
  68. </view>
  69. </template>
  70. <script>
  71. import HomeMenu from './components/home-menu.vue'
  72. import HomeProduct from './components/home-product.vue'
  73. import HomeSearch from './components/home-search.vue'
  74. import HomeGoods from './components/home-goods.vue'
  75. import {
  76. getMenu,
  77. getCanvas,
  78. getIndexData,
  79. getTuiDoctor,
  80. getTuiArticle,
  81. getTuiDoctorOrder,
  82. getCartCount
  83. } from '@/api/index'
  84. export default {
  85. components: {
  86. HomeMenu,
  87. HomeProduct,
  88. HomeSearch,
  89. HomeGoods,
  90. },
  91. data() {
  92. return {
  93. statusBarHeight: 0,
  94. tabsData: [
  95. { name: '精选' },
  96. { name: '健康新品' },
  97. { name: '营养保健' },
  98. { name: '健康滋补' },
  99. ],
  100. tabCurrentIndex: 0,
  101. menusData: [],
  102. tabsProduct: [
  103. { name: '今日主推' },
  104. { name: '健康新品' },
  105. { name: '营养保健' },
  106. ],
  107. tabsProductIndex: 0,
  108. goodList: [1, 2],
  109. isShowToTop: false,
  110. }
  111. },
  112. onLoad() {
  113. },
  114. onShow() {
  115. this.getMenuData();
  116. },
  117. methods: {
  118. // 搜索
  119. onSearch(keyword) {
  120. },
  121. // 分类tab切换
  122. tabChange(index) {
  123. this.tabCurrentIndex = index;
  124. },
  125. // 商品tab切换
  126. tabProductChange(index) {
  127. this.tabsProductIndex = index;
  128. },
  129. // 获取分类数据
  130. async getMenuData() {
  131. const { code, data, msg } = await getMenu();
  132. if (code == 200) {
  133. this.menusData = this.$scsUtils.splitArrayIntoSubarrays(data, 5) || []
  134. } else {
  135. uni.showToast({
  136. title: msg,
  137. icon: 'none'
  138. })
  139. }
  140. },
  141. // 下拉刷新
  142. onfresher() {
  143. const self = this;
  144. self.$refs.fresher.isTrigger = true;
  145. setTimeout(() => {
  146. self.$refs.fresher.refresherText = "刷新成功";
  147. self.$refs.fresher.isTrigger = false;
  148. }, 500);
  149. },
  150. // 上拉加载更多
  151. loadMore() {
  152. },
  153. }
  154. }
  155. </script>
  156. <style lang="scss" scoped>
  157. ::v-deep.scs-nav-bar {
  158. background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 49.52%, #F5F7FA 100%);
  159. .scs-scroll-navbar {
  160. width: calc(100vw - 140rpx) !important;
  161. .nav-underline {
  162. background: linear-gradient(90deg, rgba(56, 217, 125, 0.5) 0%, rgba(56, 217, 125, 0) 100%);
  163. bottom: 28rpx;
  164. }
  165. }
  166. }
  167. ::v-deep .tab-goods {
  168. background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 49.52%, #F5F7FA 100%);
  169. .scs-scroll-navbar {
  170. .nav-item {
  171. margin-right: 78rpx !important;
  172. }
  173. }
  174. }
  175. </style>