Browse Source

feat: 添加更新设置索引配置的接口,优化视频播放功能并调整业务类型为数字

EvilDragon 3 months ago
parent
commit
ee2a169646

+ 4 - 2
packages/app/src/core/libs/requests.ts

@@ -282,6 +282,8 @@ export const getSetIndexConfigs = (query = {}) =>
       createTime: string
     }[]
   }>('/app-api/basicsetting/set-index-config/page', query)
+export const updateSetIndexConfig = (data: { id: number; status: number }) =>
+  httpPut('/app-api/basicsetting/set-index-config/update', data)
 
 /**
  * 获取材料商列表
@@ -752,9 +754,9 @@ export const createBrowseHistory = (data: {
    */
   bizId?: string
   /**
-   * 业务类型,可用值:分享,获客,浏览
+   * 业务类型,可用值:分享,获客,浏览 [1,2,3]
    */
-  bizType?: string
+  bizType?: string | number
   /**
    * 时长:单位-秒
    */

+ 4 - 2
packages/app/src/pages/home/components/home-banner.vue

@@ -1,5 +1,6 @@
 <script setup lang="ts">
 import ImageEvo from '@/components/image-evo.vue'
+import { updateSetIndexConfig } from '@/core/libs/requests'
 import { unix } from 'dayjs'
 
 const props = withDefaults(
@@ -10,15 +11,16 @@ const props = withDefaults(
   }>(),
   {},
 )
-// const emits = defineEmits()
+const emits = defineEmits<{ play: [id: string | number] }>()
 const instance = getCurrentInstance()
 const playing = ref(false)
 const duration = ref(0)
 const durationText = computed(() => unix(duration.value).format('mm:ss'))
 const videoContext = ref<UniNamespace.VideoContext>()
-const handlePlay = () => {
+const handlePlay = async () => {
   videoContext.value?.play()
   playing.value = true
+  emits('play', props.id)
 }
 const handleLoadedMetaData = ({ detail }) => {
   duration.value = detail.duration

+ 12 - 2
packages/app/src/pages/home/index.vue

@@ -23,6 +23,7 @@ import {
   getSetIndexConfigs,
   getStudyTours,
   shareCircle,
+  updateSetIndexConfig,
 } from '../../core/libs/requests'
 import { logo } from '../../core/libs/svgs'
 import PageHelper from '@/components/page-helper.vue'
@@ -38,7 +39,7 @@ import ButtonEvo from '@/components/button-evo.vue'
 import ImgBtnEvo from '@/components/img-btn-evo.vue'
 import SectionHeading from '@/components/section-heading.vue'
 import dayjs from 'dayjs'
-import { sort } from 'radash'
+import { pick, sort } from 'radash'
 import { Activity, StudyTour } from '../../core/libs/models'
 
 defineOptions({
@@ -91,6 +92,10 @@ const setHotActivities = async () => {
   console.log(sort(res.flat(), (it) => it.startAt))
   hotActivities.value = sort(res.flat(), (it) => it.startAt) as any
 }
+const handlePlay = async (id) => {
+  const body = pick(swiperData.value?.find((it) => it.data.id === id).data, ['id', 'status'])
+  await updateSetIndexConfig(body)
+}
 onShow(async () => {
   pageHelperRef.value?.refresh()
   // await setStudyTours()
@@ -130,7 +135,12 @@ onShareAppMessage(async ({ from, target }) => {
           :key="id"
         >
           <swiper-item>
-            <HomeBanner :id="id" :url="indexPromotionalVideoImage" :cover="coverVideoImage" />
+            <HomeBanner
+              :id="id"
+              :url="indexPromotionalVideoImage"
+              :cover="coverVideoImage"
+              @play="handlePlay"
+            />
           </swiper-item>
         </template>
       </swiper>

+ 2 - 1
packages/app/src/pages/mine/homepage/index.vue

@@ -150,7 +150,8 @@ onUnload(async () => {
     viewDuration.value = dayjs().diff(viewStartAt.value, 'seconds')
     const { data, code } = await createBrowseHistory({
       stylistId: id.value,
-      bizType: '浏览',
+      bizType: 3,
+      // bizId: '1',
       duration: viewDuration.value.toString(),
     })
   }