kevin.T 2 тижнів тому
батько
коміт
1faec8bd3b

+ 62 - 23
packages/app/src/pages-sub/home/content/index.vue

@@ -11,19 +11,62 @@ import { logo } from '../../../core/libs/svgs'
 import { getBanner, getContent } from '../../../core/libs/requests'
 import Article from '../components/article.vue'
 import { Content } from '../../../core/libs/models'
+import { isBoolean } from 'wot-design-uni/components/common/util'
 
 const id = ref()
 const type = ref()
+const bannerHome = ref<{
+  coverVideoImage: string
+  name: string
+  playCount: number
+  url: string
+  indexPromotionalVideoImage: string
+  detailsType: string
+  id: string | number
+  details: string
+  createTime: string | number
+}>({
+  coverVideoImage: '',
+  name: '',
+  url: '',
+  indexPromotionalVideoImage: '',
+  detailsType: '',
+  id: 0,
+  details: '',
+  createTime: 0,
+  playCount: 0,
+})
+const detailArticle = computed(() => {
+  if (type.value === 'banner') {
+    return {
+      isBanner: true,
+      ...data.value,
+    }
+  } else if (type.value === 'home-banner') {
+    return {
+      isBanner: true,
+      title: bannerHome.value.name,
+      contentDetail: bannerHome.value.details,
+      createTime: bannerHome.value.createTime.toString(),
+      viewsCount: bannerHome.value.playCount,
+    }
+  } else {
+    return {
+      isBanner: false,
+      ...data.value,
+    }
+  }
+})
 const request = ref<() => Promise<IResData<Partial<Content>>>>()
 const { data, run } = useRequest(() => request.value(), { initialData: {} })
-const formatData = (res) =>{
-	return {
-	  		data:{
-	  			isBanner: true,
-	  			title: res.name,
-	  			contentDetail: res.bannerDetailsContent
-	  		}
-	  } 
+const formatData = (res) => {
+  return {
+    data: {
+      isBanner: true,
+      title: res.name,
+      contentDetail: res.bannerDetailsContent,
+    },
+  }
 }
 onLoad(async (query: { id: string; type?: 'banner'; data?: string }) => {
   id.value = query.id
@@ -45,16 +88,12 @@ onLoad(async (query: { id: string; type?: 'banner'; data?: string }) => {
           },
         }
       })
-  }else if(type.value === 'home-banner'){
-		let res = JSON.parse(query.data)
-		console.log(res)	
-		request.value = () => {
-				return {
-					isBanner: true,
-					title: res.name,
-					contentDetail: res.bannerDetailsContent
-				}
-			}  
+  } else if (type.value === 'home-banner') {
+    console.log('home-banner', JSON.parse(query.data))
+    bannerHome.value = JSON.parse(query.data)
+    uni.setNavigationBarTitle({
+      title: bannerHome.value.name,
+    })
   } else {
     request.value = () => getContent({ id: id.value })
   }
@@ -70,12 +109,12 @@ onShareTimeline(() => ({
 <template>
   <div class="flex-grow bg-white">
     <Article
-      :isBanner="data.isBanner"
-      :title="data?.title"
+      :isBanner="detailArticle.isBanner"
+      :title="detailArticle?.title"
       :author="{ name: '筑巢荟' }"
-      :content="data?.contentDetail"
-      :createAt="data?.createTime"
-      :viewNum="data?.viewsCount || 0"
+      :content="detailArticle?.contentDetail"
+      :createAt="detailArticle?.createTime"
+      :viewNum="detailArticle?.viewsCount || 0"
     >
       <template #avatar><wd-img width="28" height="28" :src="logo"></wd-img></template>
     </Article>

+ 4 - 0
packages/app/src/pages/home/index.vue

@@ -205,6 +205,8 @@ onShareAppMessage(shareAppMessage)
               url,
               details,
               name,
+              createTime,
+              playCount,
             },
           } of swiperData"
           :key="id"
@@ -224,6 +226,8 @@ onShareAppMessage(shareAppMessage)
                 url,
                 details,
                 name,
+                createTime,
+                playCount,
               }"
               @play="handlePlay"
               @ended="autoplay = true"