From e629874abe6e295a008a18aa609bc4a42d633e84 Mon Sep 17 00:00:00 2001
From: sunlizhou <296190577@qq.com>
Date: Fri, 1 Sep 2023 16:56:48 +0800
Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E9=A1=B5=E9=9D=A2=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E5=85=BC=E5=AE=B9=E5=A4=9A=E7=A7=8D=E7=B1=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/app.config.ts | 1 -
src/pages/home/components/search.tsx | 2 +-
src/pages/preview/brand/info/info.tsx | 72 +++++++-------
src/pages/preview/search/list/index.config.ts | 5 -
.../preview/search/list/index.module.scss | 32 -------
src/pages/preview/search/list/index.tsx | 95 -------------------
.../search/search/components/list.module.scss | 25 ++++-
.../preview/search/search/components/list.tsx | 77 ++++++++++++---
.../preview/search/search/index.config.ts | 2 +-
src/pages/preview/search/search/index.tsx | 6 +-
src/utils/day.ts | 1 +
11 files changed, 131 insertions(+), 187 deletions(-)
delete mode 100644 src/pages/preview/search/list/index.config.ts
delete mode 100644 src/pages/preview/search/list/index.module.scss
delete mode 100644 src/pages/preview/search/list/index.tsx
diff --git a/src/app.config.ts b/src/app.config.ts
index 3cc50b3..a71824d 100644
--- a/src/app.config.ts
+++ b/src/app.config.ts
@@ -94,7 +94,6 @@ export default defineAppConfig({
'illness/article/article',
'webView/webView',
'search/search/index',
- 'search/list/index',
]
},
],
diff --git a/src/pages/home/components/search.tsx b/src/pages/home/components/search.tsx
index eef3ff5..a75e30c 100644
--- a/src/pages/home/components/search.tsx
+++ b/src/pages/home/components/search.tsx
@@ -13,7 +13,7 @@ export const Search: FC = () => {
return (
- 搜索课程
+ 点击搜索
)
}
diff --git a/src/pages/preview/brand/info/info.tsx b/src/pages/preview/brand/info/info.tsx
index a964f9f..596c6a1 100644
--- a/src/pages/preview/brand/info/info.tsx
+++ b/src/pages/preview/brand/info/info.tsx
@@ -66,43 +66,49 @@ const BrandInfo: FC = () => {
return (
-
+
+ {brandInfo?.introductory_video_resource?.url &&
+
+ }
+ {brandInfo?.brand_album?.length
+ && brandInfo?.brand_album?.split(',').map((d) =>
+
+
+ )
+ }
+
+
+ {curIndex} / {(brandInfo?.brand_album?.split(',').length || 0) + ((brandInfo && brandInfo.introductory_video_resource) ? 1 : 0)}
+
+ >
+ }
+
- >
- {brandInfo?.introductory_video_resource?.url &&
-
- }
- {brandInfo?.brand_album?.length
- && brandInfo?.brand_album?.split(',').map((d) =>
-
-
- )
- }
-
-
- {curIndex} / {(brandInfo?.brand_album?.split(',').length || 0) + ((brandInfo && brandInfo.introductory_video_resource) ? 1 : 0)}
-
{brandInfo?.name}
-
+
{
diff --git a/src/pages/preview/search/list/index.config.ts b/src/pages/preview/search/list/index.config.ts
deleted file mode 100644
index 632a800..0000000
--- a/src/pages/preview/search/list/index.config.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export default definePageConfig({
- navigationBarTitleText: '搜索列表',
- navigationBarBackgroundColor:'#F2F8F6',
- onReachBottomDistance: 50
-})
diff --git a/src/pages/preview/search/list/index.module.scss b/src/pages/preview/search/list/index.module.scss
deleted file mode 100644
index f2d21e8..0000000
--- a/src/pages/preview/search/list/index.module.scss
+++ /dev/null
@@ -1,32 +0,0 @@
-.box {
- display: flex;
- margin-bottom: 20rpx;
- background-color: #fff;
- border-radius: 16rpx;
- padding: 24rpx;
- box-sizing: border-box;
-}
-.image{
- width: 128rpx;
- height:128rpx;
- background-color: #ededed;
- border-radius: 8rpx;
-}
-.rightBox{
- padding-left: 24rpx;
- box-sizing: border-box;
- flex: 1;
-}
-.desc{
- font-size: 24rpx;
- font-weight: 500;
- color: #909795;
- line-height: 34rpx;
- display: -webkit-box;
- word-break: break-all;
- text-overflow: ellipsis;
- overflow: hidden;
- -webkit-box-orient:vertical;
- -webkit-line-clamp:2;
-}
-
diff --git a/src/pages/preview/search/list/index.tsx b/src/pages/preview/search/list/index.tsx
deleted file mode 100644
index ddafdfe..0000000
--- a/src/pages/preview/search/list/index.tsx
+++ /dev/null
@@ -1,95 +0,0 @@
-import {FC, useCallback, useEffect, useState} from "react";
-import {View} from "@tarojs/components";
-import styles from './index.module.scss'
-import Taro, {useReachBottom, useRouter} from "@tarojs/taro";
-import Empty from "@/components/empty/empty";
-import Spinner from "@/components/spinner";
-import Img from "@/components/image/image";
-import { SearchApi } from "@/api/search";
-
-const SearchList: FC = () => {
- const {name} = useRouter().params as unknown as { name: string}
- const [page, setPage] = useState(1)
- const [brands, setBrands] = useState([])
- const [total, setTotal] = useState(0)
- const [text, setText] = useState('')
- const [loading, setLoading] = useState(true)
-
- useEffect(() => {
- getData()
- }, [page,name])
-
- const getData = useCallback(async () => {
- try {
- const data = await SearchApi.list(page, 10,name)
- if (page === 1) {
- if (data.data.length < 10) {
- setText('没有更多了~')
- } else {
- setText('上拉加载更多~')
- }
- }
- setTotal(data.total)
- setBrands([
- ...brands,
- ...data.data
- ])
- } catch (e) {
- }
- setLoading(false)
- }, [page])
-
-
- function jumpInfo(id: number,type:string) {
- console.log(type,'type')
- let url = ''
- switch (type){
- case 'brand':
- url = '/pages/preview/brand/info/info';
- break;
- case 'illness':
- url = '/pages/preview/illness/list/list';
- break;
- case 'article':
- url = '/pages/preview/illness/article/article'
- break
- case 'video_record':
- url = '/pages/preview/videoFull/videoFull'
- break
- }
- Taro.navigateTo({url: `${url}?id=${id}`})
-
- }
-
- useReachBottom(useCallback(() => {
- if (brands?.length < total) {
- setPage(page + 1)
- } else {
- setText('没有更多了~')
- }
- }, [total, brands]))
-
-
- return (
-
-
- {
- brands.length ?
- <>
- {brands.map((d) => jumpInfo(d.data.id,d.data.table)} className={styles.box} key={d.data.id}>
-
-
- {d.data.title}
- {d.graphic_introduction}
-
- )
- }
- {text}
- > :
- }
-
- )
-}
-
-export default SearchList
-
diff --git a/src/pages/preview/search/search/components/list.module.scss b/src/pages/preview/search/search/components/list.module.scss
index f2d21e8..eb3ac5f 100644
--- a/src/pages/preview/search/search/components/list.module.scss
+++ b/src/pages/preview/search/search/components/list.module.scss
@@ -1,22 +1,43 @@
.box {
+ margin-left:30rpx;
+ margin-bottom: 24rpx;
+ width:690rpx;
display: flex;
margin-bottom: 20rpx;
background-color: #fff;
border-radius: 16rpx;
padding: 24rpx;
box-sizing: border-box;
+ position: relative;
}
.image{
- width: 128rpx;
- height:128rpx;
background-color: #ededed;
border-radius: 8rpx;
}
+.play {
+ position: absolute;
+ z-index: 9999;
+ width: 50rpx !important;
+ height: 50rpx !important;
+ top: 99rpx;
+ left: 99rpx;
+ background: transparent !important;
+}
.rightBox{
padding-left: 24rpx;
box-sizing: border-box;
flex: 1;
}
+.articleLeftBox{
+ padding-right: 24rpx;
+ box-sizing: border-box;
+ flex: 1;
+}
+.videoRightBox{
+ padding-left: 24rpx;
+ box-sizing: border-box;
+ flex: 1;
+}
.desc{
font-size: 24rpx;
font-weight: 500;
diff --git a/src/pages/preview/search/search/components/list.tsx b/src/pages/preview/search/search/components/list.tsx
index 7082961..e99f42a 100644
--- a/src/pages/preview/search/search/components/list.tsx
+++ b/src/pages/preview/search/search/components/list.tsx
@@ -1,17 +1,20 @@
import {FC, useCallback, useEffect, useState} from "react";
-import {ScrollView, View} from "@tarojs/components";
+import {Image, ScrollView, View} from "@tarojs/components";
import styles from './list.module.scss'
import Taro from "@tarojs/taro";
import Empty from "@/components/empty/empty";
import Img from "@/components/image/image";
import { SearchApi } from "@/api/search";
import { AtLoadMore } from 'taro-ui'
+import {rfc33392time} from "@/utils/day";
+import play from "@/static/img/play.png";
type Props = {
name:string
clear:boolean
}
const SearchList: FC = ({name,clear}) => {
+ console.log(name,'name')
const globalData = Taro.getApp().globalData
const [page, setPage] = useState(1)
const [brands, setBrands] = useState([])
@@ -26,14 +29,13 @@ const SearchList: FC = ({name,clear}) => {
}
},[clear])
useEffect(() => {
- if(name){
+ if(name && clear){
getData()
}
- }, [page,name])
+ }, [page,name,clear])
const getData = useCallback(async () => {
try {
- console.log(name)
const data = await SearchApi.list(page, 10,name)
if (page === 1) {
if (data.data.length < 10) {
@@ -58,7 +60,7 @@ const SearchList: FC = ({name,clear}) => {
}, [page,name])
- function jumpInfo(id: number,type:string) {
+ function jumpInfo(id: number,type:string,health:any) {
console.log(type,'type')
let url = ''
switch (type){
@@ -71,8 +73,10 @@ const SearchList: FC = ({name,clear}) => {
case 'article':
url = '/pages/preview/illness/article/article'
break
- case 'video_record':
- url = '/pages/preview/videoFull/videoFull'
+ case 'video_records':
+ return Taro.navigateTo({url: `/pages/preview/videoFull/videoFull?url=${health.resources.url}&poster=${health.url_path}&title=${health.title}`})
+ case 'courses':
+ url = '/pages/business/videoInfo/videoInfo'
break
}
Taro.navigateTo({url: `${url}?id=${id}`})
@@ -93,22 +97,65 @@ const SearchList: FC = ({name,clear}) => {
className='scrollview'
scrollY
scrollWithAnimation
- style={{height:`${globalData.windowHeight-60-30}px`,paddingBottom:`30px`}}
+ style={{height:`${globalData.windowHeight-60}px`,backgroundColor:`#f5f5f5`}}
onScrollToLower={onScrollToLower}
>
{ loading && }
{
brands.length >= 1 && !loading &&
<>
- {brands.map((d) => jumpInfo(d.data.id,d.data.table)} className={styles.box} key={d.data.id}>
-
-
- {d.data.title}
- {d.graphic_introduction}
+ {brands.map((d) =>
+ jumpInfo(d.data.id,d.data.table,d.data['@data'])} className={styles.box} key={d.data.id}>
+ {
+ d.data.table === 'brand' &&
+ <>
+
+
+ {d.data.title}
+ {d.data.content || '暂无品牌简介'}
+
+ >
+ }
+ {
+ d.data.table === 'article' &&
+ <>
+
+ {d.data['@data'].title}
+ {rfc33392time(d.data['@data'].created_at)} {d.data['@data'].page_view}阅读
+
+
+ >
+ }
+ {
+ d.data.table === 'video_records' &&
+ <>
+
+
+
+ {d.data['@data'].title}
+ {d.data['@data'].introduction}
+ 播放量: {d.data['@data'].video_view}
+
+ >
+ }
+ {
+ d.data.table === 'courses' &&
+ <>
+
+
+ {d.data['@data'].title}
+ 课时:{d.data['@data'].class_hour}节 销量:{d.data['@data'].charge}
+
+ >
+ }
+
+
+
+
- )
+ )
}
- {text}
+ {text}
>
}
{ !loading && brands.length === 0 && }
diff --git a/src/pages/preview/search/search/index.config.ts b/src/pages/preview/search/search/index.config.ts
index 08bb2d5..4fdde3a 100644
--- a/src/pages/preview/search/search/index.config.ts
+++ b/src/pages/preview/search/search/index.config.ts
@@ -1,5 +1,5 @@
export default definePageConfig({
- navigationBarTitleText: '课程搜索',
+ navigationBarTitleText: '搜索',
navigationBarBackgroundColor:'#F2F8F6',
onReachBottomDistance: 50
})
diff --git a/src/pages/preview/search/search/index.tsx b/src/pages/preview/search/search/index.tsx
index 81379a7..95bfc6f 100644
--- a/src/pages/preview/search/search/index.tsx
+++ b/src/pages/preview/search/search/index.tsx
@@ -21,8 +21,10 @@ const Search:FC = () => {
})
useEffect(()=>{
- getRecentSearch()
- },[!show])
+ if(!show){
+ getRecentSearch()
+ }
+ },[show])
function inpFn(e){
setValue(e.detail.value)
diff --git a/src/utils/day.ts b/src/utils/day.ts
index 9025c1a..206b688 100644
--- a/src/utils/day.ts
+++ b/src/utils/day.ts
@@ -15,6 +15,7 @@ export const rfc33392time = (dateStr: string): string => {
.toISOString()
.replace(/T/g, ' ')
.replace(/\.[\d]{3}Z/, '')
+ .slice(0,16)
}
const TIME_OFFSET = (() => {