index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <script setup lang="ts">
  2. import { StaticUrl, VITE_OSS_BASE_URL } from '@/config'
  3. import router from '@/router'
  4. const props = defineProps<{ categoryList: Api.xsbCategories[] }>()
  5. const emit = defineEmits(['changeNav'])
  6. const { ScrollDown } = storeToRefs(useSysXsbStore())
  7. const { statusBarHeight, MenuButtonHeight } = storeToRefs(useSysStore())
  8. const { name } = storeToRefs(useAddressStore())
  9. const { topNavActive, leftActive } = storeToRefs(useSysXsbStore())
  10. const current = ref(0)
  11. const swiperList = ref([
  12. 'https://wot-ui.cn/assets/redpanda.jpg',
  13. 'https://wot-ui.cn/assets/capybara.jpg',
  14. 'https://wot-ui.cn/assets/panda.jpg',
  15. 'https://wot-ui.cn/assets/moon.jpg',
  16. 'https://wot-ui.cn/assets/meng.jpg',
  17. ])
  18. const navActive = ref(0)
  19. const classfiylist = computed(() => props.categoryList.slice(0, 10))
  20. const swiperClassList = computed(() => props.categoryList.slice(10, props.categoryList.length))
  21. const navList = ref([
  22. { title: '为你推荐' },
  23. { title: '疯狂折扣' },
  24. { title: '' },
  25. { title: '地道特产' },
  26. { title: '预售' },
  27. ])
  28. const textArray = ref([
  29. '这是一条消息提示信息',
  30. '这是第二条消息',
  31. '这是第三条消息',
  32. ])
  33. function handleChangeNav(idx: number) {
  34. navActive.value = idx
  35. }
  36. function handleScroll(e: UniHelper.ScrollViewOnScrollEvent) {
  37. if (e.detail.scrollTop >= 80) {
  38. ScrollDown.value = true
  39. }
  40. else {
  41. ScrollDown.value = false
  42. }
  43. }
  44. function handleCommonName(name: string) {
  45. router.push({ name })
  46. }
  47. function handleCommonClass(item: Api.xsbCategories) {
  48. topNavActive.value = item.code
  49. leftActive.value = item.children[0].code
  50. emit('changeNav')
  51. }
  52. function handleSwiperClick(e: { index: number, item: Api.xsbCategories }) {
  53. handleCommonClass(e.item)
  54. }
  55. </script>
  56. <template>
  57. <view class="page-xsb">
  58. <wd-navbar
  59. title=""
  60. :custom-style="`background-color:${ScrollDown ? 'var(--them-color)' : 'transparent !important'}`"
  61. :bordered="false" :z-index="99" safe-area-inset-top left-arrow fixed @click-left="router.back()"
  62. >
  63. <template #left>
  64. <view class="h-full flex items-center">
  65. <wd-icon name="arrow-left" size="22px" color="#fff" />
  66. <view class="ml10rpx flex items-center" @click.stop="router.push({ name: 'common-selectAddress' })">
  67. <image :src="`${StaticUrl}/location.png`" class="h33.8rpx w29rpx" />
  68. <view class="ml10rpx max-w-280rpx truncate text-32rpx text-white">
  69. {{ name }}
  70. </view>
  71. </view>
  72. </view>
  73. </template>
  74. </wd-navbar>
  75. <scroll-view scroll-y class="content" @scroll="handleScroll">
  76. <view
  77. class="header-linear h320rpx px24rpx"
  78. :style="{ paddingTop: `${(Number(statusBarHeight) || 44) + MenuButtonHeight + 12}px` }"
  79. >
  80. <view class="h60rpx w-full flex items-center justify-between rounded-40rpx bg-white pr6rpx" @click="router.push({ name: 'xsb-search' })">
  81. <view class="flex items-center pb14rpx pl24rpx pt16rpx">
  82. <wd-icon name="search" size="14" color="#ccc" />
  83. <view class="search ml12rpx h-full w-full overflow-hidden">
  84. <wd-notice-bar
  85. :text="['霸王茶姬', '牛奶', '洗衣机']" custom-class="notice-bar" color="#ccc"
  86. background-color="#fff" direction="vertical"
  87. />
  88. </view>
  89. </view>
  90. <view
  91. class="h50rpx w96rpx flex items-center justify-center rounded-26rpx bg-[var(--them-color)] text-24rpx text-white font-semibold"
  92. >
  93. 搜索
  94. </view>
  95. </view>
  96. <scroll-view scroll-x class="mb20rpx mt20rpx h44rpx whitespace-nowrap">
  97. <view class="h-full flex items-center">
  98. <view
  99. v-for="item in 10" :key="item"
  100. class="mr32rpx h-full flex items-center justify-center rounded-22rpx bg-[rgba(255,255,255,.5)] px16rpx text-24rpx"
  101. >
  102. {{ item }}苹果
  103. </view>
  104. </view>
  105. </scroll-view>
  106. </view>
  107. <view class="px24rpx -mt180rpx">
  108. <wd-swiper v-model:current="current" :autoplay="false" :list="swiperList" :height="138" :indicator="false" />
  109. <view class="mt20rpx">
  110. <wd-card title="" custom-class="card-zt">
  111. <view class="px24rpx pt24rpx">
  112. <view class="grid grid-cols-5 gap-x-38rpx gap-y-24rpx">
  113. <view v-for="item, index in classfiylist" :key="index" @click="handleCommonClass(item)">
  114. <image :src="item.icon" class="h100rpx w100rpx" />
  115. <view class="mt12rpx text-24rpx text-#222">
  116. {{ item.name }}
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. <view class="swiper-img swiper pb20rpx">
  122. <wd-swiper
  123. :list="swiperClassList" :indicator="{ type: 'dots-bar' }" height="80"
  124. :display-multiple-items="5" :autoplay="false" :loop="false"
  125. custom-indicator-class="custom-indicator-class" value-key="icon" text-key="name"
  126. image-mode="aspectFit"
  127. @click="handleSwiperClick"
  128. />
  129. </view>
  130. </wd-card>
  131. </view>
  132. <view class="mt20rpx">
  133. <wd-notice-bar direction="vertical" :text="textArray" :delay="3" color="#222222" background-color="#fff">
  134. <template #prefix>
  135. <view class="mr20rpx">
  136. <wd-icon name="sound" size="22px" color="var(--them-color)" />
  137. </view>
  138. </template>
  139. </wd-notice-bar>
  140. </view>
  141. <view class="mt20rpx">
  142. <image :src="`${VITE_OSS_BASE_URL}2025/12/6671332ceef64985858aa8b548027bd3.png`" class="h236rpx w-full" />
  143. </view>
  144. <scroll-view scroll-x class="mb20rpx mt20rpx whitespace-nowrap">
  145. <view class="flex items-center">
  146. <view v-for="item, idx in navList" :key="idx" class="relative mr44rpx" @click="handleChangeNav(idx)">
  147. <image v-show="idx == 2" :src="`${StaticUrl}/chaozhi.png`" class="relative z-2 h-29.06rpx w-105.34rpx" />
  148. <text
  149. v-show="idx != 2" class="relative z-2 text-32rpx"
  150. :class="[navActive == idx ? 'text-36rpx font-semibold' : '']"
  151. >
  152. {{ item.title }}
  153. </text>
  154. <view
  155. v-show="navActive == idx"
  156. class="nav-line absolute bottom-0rpx left-50% z-1 h18rpx w80rpx rounded-10rpx -translate-x-50%"
  157. />
  158. </view>
  159. </view>
  160. </scroll-view>
  161. <view class="mt20rpx">
  162. <view class="flex items-center">
  163. <scroll-view scroll-y type="custom">
  164. <grid-view type="masonry" cross-axis-count="2" main-axis-gap="10" cross-axis-gap="10">
  165. <wd-swiper v-model:current="current" :autoplay="false" :list="swiperList" :height="231" />
  166. <view
  167. v-for="it in 20" :key="it" class="overflow-hidden rounded-16rpx bg-white pb16rpx"
  168. @click="handleCommonName('xsb-goods')"
  169. >
  170. <view class="relative h344rpx">
  171. <image
  172. :src="`${VITE_OSS_BASE_URL}2025/11/9d42892888304abf85487deea0271f62.png`"
  173. class="h344rpx w344rpx"
  174. />
  175. </view>
  176. <view class="mt20rpx px20rpx">
  177. <view class="text-left text-28rpx font-semibold">
  178. <view v-for="i in 2" :key="i" class="mr5px inline-block">
  179. <wd-tag type="primary">
  180. 新品{{ i }}
  181. </wd-tag>
  182. </view>
  183. 海湾高盐特大白虾200g
  184. </view>
  185. <view class="mt12rpx text-22rpx text-#AAAAAA">
  186. 已售5999
  187. </view>
  188. <view class="mt10rpx flex items-center justify-between">
  189. <view>
  190. <view class="mt20rpx flex items-end text-#FF4D3A font-semibold">
  191. <view class="text-24rpx">
  192. </view>
  193. <view class="text-36rpx line-height-[36rpx]">
  194. 1.395
  195. </view>
  196. </view>
  197. </view>
  198. <image :src="`${StaticUrl}/cart-yes.png`" class="h52rpx w52rpx" />
  199. </view>
  200. </view>
  201. </view>
  202. </grid-view>
  203. </scroll-view>
  204. </view>
  205. </view>
  206. </view>
  207. <view class="h100rpx" />
  208. </scroll-view>
  209. </view>
  210. </template>
  211. <style scoped lang="scss">
  212. .content {
  213. height: calc(100vh - var(--window-top) - 80rpx);
  214. }
  215. </style>