index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page;推荐使用json5,更强大,且允许注释 -->
  2. <route lang="json5" type="home">
  3. {
  4. layout: 'tabbar',
  5. style: {
  6. navigationStyle: 'custom',
  7. navigationBarTitleText: '首页',
  8. },
  9. }
  10. </route>
  11. <script lang="ts" setup>
  12. import Card from '@/components/card.vue'
  13. import HotActivity from '@/components/hot-activity.vue'
  14. import MomentItem from '@/components/moment-item.vue'
  15. import useRequest from '../../hooks/useRequest'
  16. import Menus from './components/menus.vue'
  17. import { getCircles, getSetIndexConfigs } from '../../core/libs/requests'
  18. import { logo } from '../../core/libs/svgs'
  19. defineOptions({
  20. name: 'Home',
  21. })
  22. const instance = getCurrentInstance()
  23. const { data: circlesData, run } = useRequest(() => getCircles({}), { initialData: { list: [] } })
  24. const { data: indexConfigsData, run: setIndexConfigsData } = useRequest(
  25. () => getSetIndexConfigs(),
  26. { initialData: { list: [] } },
  27. )
  28. const swiperData = ref<{ data: any; videoContext: UniNamespace.VideoContext; playing: boolean }[]>()
  29. const swiperCurrent = ref(0)
  30. onShow(async () => {
  31. await run()
  32. })
  33. onLoad(async () => {
  34. await setIndexConfigsData()
  35. swiperData.value = indexConfigsData.value.list.map((it) => ({
  36. data: it,
  37. videoContext: uni.createVideoContext(`video-${it.id}`, instance),
  38. playing: false,
  39. }))
  40. })
  41. const toAbout = () => {
  42. uni.navigateTo({ url: '/pages/home/about/index' })
  43. }
  44. const handleSwiperChange = ({ detail: { current } }) => {
  45. swiperCurrent.value = current
  46. }
  47. const handlePlay = () => {
  48. swiperData.value[swiperCurrent.value].videoContext.play()
  49. swiperData.value[swiperCurrent.value].playing = true
  50. }
  51. onShareAppMessage(() => ({}))
  52. </script>
  53. <template>
  54. <view class="">
  55. <view class="bg-black w-full relative aspect-[1.26/1]">
  56. <swiper @change="handleSwiperChange">
  57. <template
  58. v-for="{
  59. data: { id, coverVideoImage, indexPromotionalVideoImage },
  60. playing,
  61. } of swiperData"
  62. :key="id"
  63. >
  64. <swiper-item>
  65. <div class="w-full h-full relative">
  66. <video
  67. class="w-full h-full"
  68. :id="`video-${id}`"
  69. :src="indexPromotionalVideoImage"
  70. ></video>
  71. <div v-if="!playing" class="absolute left-0 top-0 w-full h-full bg-black">
  72. <wd-img width="100%" height="100%" :src="coverVideoImage" />
  73. </div>
  74. <div
  75. v-if="!playing"
  76. class="w-[375px] h-[90px] bg-gradient-to-t from-black to-black/0 absolute left-0 bottom-0 w-full flex items-center"
  77. >
  78. <view class="mx-7">
  79. <wd-button
  80. plain
  81. custom-class="bg-transparent! border-white! text-white!"
  82. icon="play"
  83. @click="handlePlay"
  84. >
  85. 02:30
  86. </wd-button>
  87. </view>
  88. </div>
  89. </div>
  90. </swiper-item>
  91. </template>
  92. </swiper>
  93. </view>
  94. <view class="bg-[#f6f6f6] relative bottom-4 rounded-t-2xl py-1">
  95. <!-- <ScheduleCard custom-class="my-6 mx-3.5"></ScheduleCard> -->
  96. <menus></menus>
  97. <!-- <view class="my-6 mx-3.5">
  98. <HotActivity></HotActivity>
  99. </view> -->
  100. <view class="my-6 mx-3.5" @click="toAbout()">
  101. <Card>
  102. <div class="flex items-center gap-2">
  103. <wd-img width="28" height="28" :src="logo"></wd-img>
  104. <div class="text-black/90 text-base font-normal font-['PingFang_SC'] leading-[10.18px]">
  105. 1分钟快速了解筑巢荟
  106. </div>
  107. <div class="flex-1"></div>
  108. <wd-icon name="help-circle" size="22px" custom-class="text-black/60"></wd-icon>
  109. </div>
  110. </Card>
  111. </view>
  112. <view class="mx-3.5 text-5 font-400">设计圈</view>
  113. <view class="mx-3.5">
  114. <template v-for="it of circlesData.list" :key="it.id">
  115. <view class="my-6">
  116. <MomentItem :options="it"></MomentItem>
  117. </view>
  118. </template>
  119. </view>
  120. </view>
  121. </view>
  122. </template>
  123. <style></style>