2.修改tab的样式

v2
king 2 years ago
parent a43a0fabc2
commit acd6b352b5
  1. 2
      src/components/pageScript/pageScript.tsx
  2. 35
      src/components/tabs/tabs.tsx
  3. 2
      src/pages/index/index.tsx
  4. 64
      src/pages/preview/brand/info/info.module.scss
  5. 10
      src/pages/preview/brand/info/info.tsx
  6. 33
      src/pages/preview/brand/list/list.tsx

@ -9,7 +9,7 @@ interface Props {
const PageScript: FC<Props> = (props) => { const PageScript: FC<Props> = (props) => {
return <View return <View
className={'text-center font-24 text-dark py-3 ' + props.className} className={'text-center font-24 text-muted py-3 ' + props.className}
style={props.styles}> style={props.styles}>
{props.text || "暂无更多"} {props.text || "暂无更多"}
</View> </View>

@ -24,6 +24,7 @@ interface TabsProps {
backMode?: boolean // 块级模式 backMode?: boolean // 块级模式
style?: CSSProperties style?: CSSProperties
hiddenSliding?: boolean // 取消底部滑块 hiddenSliding?: boolean // 取消底部滑块
scrollable?: boolean
} }
const Tabs: FC<TabsProps> = (opt) => { const Tabs: FC<TabsProps> = (opt) => {
@ -49,19 +50,33 @@ const Tabs: FC<TabsProps> = (opt) => {
return index === current return index === current
} }
let children = (
<View className={'tabs-scroll ' + (opt.tabList.length < 5 ? 'justify-around' : '')}>
{opt.tabList.map((d, index) => <View
key={index}
className={'tabs-item ' + (is_current(d.value, index) && 'current ') + (!opt.hiddenSliding && 'sliding')}
onClick={(event) => onChange(event, index, d)}>
{d.title}
</View>)}
</View>
)
if (opt.scrollable != false) {
children = (
<ScrollView scrollX scrollLeft={left} scrollWithAnimation showScrollbar={false} style={{height: opt.height}}>
{children}
</ScrollView>
)
} else {
children = (
<View style={{height: opt.height}}>
{children}
</View>
)
}
return ( return (
<View className={`tabs ${opt.backMode && 'tabsBack'}`} style={{height: opt.height, ...opt.style}}> <View className={`tabs ${opt.backMode && 'tabsBack'}`} style={{height: opt.height, ...opt.style}}>
<ScrollView scrollX scrollLeft={left} scrollWithAnimation showScrollbar={false} style={{height: opt.height}}> {children}
<View className={'tabs-scroll ' + (opt.tabList.length < 5 ? 'justify-around' : '')}>
{opt.tabList.map((d, index) => <View
key={index}
className={'tabs-item ' + (is_current(d.value, index) && 'current ') + (!opt.hiddenSliding && 'sliding')}
onClick={(event) => onChange(event, index, d)}>
{d.title}
</View>)}
</View>
</ScrollView>
</View> </View>
) )
} }

@ -26,7 +26,7 @@ const Index: FC = () => {
<View className={styles.content}> <View className={styles.content}>
<NavigationBar <NavigationBar
cancelBack cancelBack
leftNode={<Tabs tabList={category} onChange={tabChange} current={categoryKey} hiddenSliding/>} leftNode={<Tabs tabList={category} onChange={tabChange} current={categoryKey} scrollable={false} hiddenSliding/>}
backgroundColor={'transparent'} backgroundColor={'transparent'}
/> />
<VideoList <VideoList

@ -1,48 +1,60 @@
page{ page {
background-color: #fff !important; background-color: #fff !important;
} }
.swiper{
width:750rpx; .swiper {
height:600rpx; width: 750rpx;
height: 600rpx;
} }
.curIndexBox{
.curIndexBox {
position: absolute; position: absolute;
top:500rpx; top: 530rpx;
right:30rpx; right: 30rpx;
background-color: rgba(0,0,0,0.5); background-color: rgba(0, 0, 0, 0.5);
border-radius: 30rpx; border-radius: 30rpx;
padding: 5rpx 30rpx; padding: 10rpx 20rpx;
color:#fff; display: flex;
justify-content: center;
align-items: center;
line-height: 1;
color: #fff;
transform: scale(0.8);
} }
.body{
background-color:#f1f8f6; .body {
background-color: #f1f8f6;
width: 750rpx; width: 750rpx;
box-sizing: border-box; box-sizing: border-box;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 500rpx; min-height: 500rpx;
.top{
.top {
position: sticky; position: sticky;
position: -webkit-sticky; position: -webkit-sticky;
top: 0; top: 0;
padding:40rpx 30rpx 30rpx 30rpx; padding: 40rpx 30rpx 30rpx 30rpx;
background-color: #fff; background-color: #fff;
.title{
.title {
font-size: 32rpx; font-size: 32rpx;
font-weight: bold; font-weight: bold;
color: #323635; color: #323635;
line-height:44rpx; line-height: 44rpx;
} }
} }
.bottom{
.bottom {
margin-top: 20rpx; margin-top: 20rpx;
flex:1; flex: 1;
background-color: #fff; background-color: #fff;
border-radius: 32rpx 32rpx 0 0; border-radius: 32rpx 32rpx 0 0;
width: 100%; width: 100%;
padding: 0 30rpx; padding: 0 30rpx;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
.box { .box {
display: flex; display: flex;
background-color: #fff; background-color: #fff;
@ -50,24 +62,28 @@ page{
padding: 30rpx; padding: 30rpx;
box-sizing: border-box; box-sizing: border-box;
} }
.inner{
flex:1; .inner {
flex: 1;
display: flex; display: flex;
padding-bottom: 24rpx; padding-bottom: 24rpx;
border-bottom: 2rpx solid #F5F8F7; border-bottom: 2rpx solid #F5F8F7;
.image{
.image {
width: 172rpx; width: 172rpx;
height:128rpx; height: 128rpx;
background-color: #eee; background-color: #eee;
border-radius: 8rpx; border-radius: 8rpx;
overflow: hidden; overflow: hidden;
} }
.leftBox{
.leftBox {
padding-right: 24rpx; padding-right: 24rpx;
box-sizing: border-box; box-sizing: border-box;
flex: 1; flex: 1;
} }
.desc{
.desc {
font-size: 22rpx; font-size: 22rpx;
font-weight: 500; font-weight: 500;
color: #909795; color: #909795;

@ -4,7 +4,6 @@ import {brandApi, BrandRecord} from "@/api";
import styles from './info.module.scss' import styles from './info.module.scss'
import Taro, {useReachBottom, useRouter} from "@tarojs/taro"; import Taro, {useReachBottom, useRouter} from "@tarojs/taro";
import LineEllipsis from "@/components/textCollapse/collapse"; import LineEllipsis from "@/components/textCollapse/collapse";
import Empty from "@/components/empty/empty";
import Img from "@/components/image/image"; import Img from "@/components/image/image";
import Spin from "@/components/spinner"; import Spin from "@/components/spinner";
import Collect from "@/components/collect/collect"; import Collect from "@/components/collect/collect";
@ -103,12 +102,13 @@ const BrandInfo: FC = () => {
} }
</Swiper> </Swiper>
<View className={styles.curIndexBox}> <View className={styles.curIndexBox}>
<Text>{curIndex} / {(brandInfo?.brand_album?.split(',').length || 0) + ((brandInfo && brandInfo.introductory_video_resource) ? 1 : 0)}</Text> <Text className={'font-26'}>{curIndex}</Text>
<Text>/</Text>
<Text>{(brandInfo?.brand_album?.split(',').length || 0) + ((brandInfo && brandInfo.introductory_video_resource) ? 1 : 0)}</Text>
</View> </View>
</> </>
} }
<View className={styles['body']}> <View className={styles['body']}>
<View className={styles['top']}> <View className={styles['top']}>
<View className='flex justify-between'> <View className='flex justify-between'>
@ -123,7 +123,9 @@ const BrandInfo: FC = () => {
articleList.map(d => <ArticlesBox data={d}/>)} articleList.map(d => <ArticlesBox data={d}/>)}
<PageScript/> <PageScript/>
</> </>
: <Empty name='空空如也'/> : <View className="py-6">
<PageScript text="还没有发布文章"/>
</View>
} }
</View> </View>
</View> </View>

@ -1,5 +1,5 @@
import {FC, ReactNode, useCallback, useEffect, useState} from "react"; import {FC, ReactNode, useCallback, useEffect, useState} from "react";
import {Image, Video, View} from "@tarojs/components"; import {Text, Video, View} from "@tarojs/components";
import {brandApi, BrandRecord} from "@/api"; import {brandApi, BrandRecord} from "@/api";
import Taro, {useReachBottom} from "@tarojs/taro"; import Taro, {useReachBottom} from "@tarojs/taro";
import Empty from "@/components/empty/empty"; import Empty from "@/components/empty/empty";
@ -7,12 +7,13 @@ import Spinner from "@/components/spinner";
import Img from "@/components/image/image"; import Img from "@/components/image/image";
import {beforeTime} from "@/utils/time"; import {beforeTime} from "@/utils/time";
import styles from './list.module.scss' import styles from './list.module.scss'
import articleLine from "@/static/img/articleLine.png" // import articleLine from "@/static/img/articleLine.png"
import Collect from "@/components/collect/collect"; // import Collect from "@/components/collect/collect";
import PageScript from "@/components/pageScript/pageScript"; import PageScript from "@/components/pageScript/pageScript";
const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onClick}) => { const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onClick}) => {
let media: ReactNode let media: ReactNode
let hasMedia = true
if (data.introductory_video_resource) { if (data.introductory_video_resource) {
media = <Video media = <Video
style={{width: '100%'}} style={{width: '100%'}}
@ -26,10 +27,12 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl
mode="aspectFill" mode="aspectFill"
style={{background: '#ededed'}} style={{background: '#ededed'}}
/> />
} else {
hasMedia = false
} }
return ( return (
<View className="bg-white flex flex-column justify-stretch mb-2_4 rounded-10 clip"> <View className="bg-white flex flex-column justify-stretch mb-2 clip">
<View className="p-3"> <View className="p-3">
<View onClick={onClick}> <View onClick={onClick}>
<View className='mb-2 font-32 flex'> <View className='mb-2 font-32 flex'>
@ -39,31 +42,29 @@ const BrandItem: FC<{ data: BrandRecord; onClick: VoidFunction }> = ({data, onCl
src={data.logo} src={data.logo}
mode='aspectFill' mode='aspectFill'
errorType='brand' errorType='brand'
className="rounded-10 clip" className="rounded clip"
style={{background: '#ededed'}} style={{background: '#ededed'}}
/> />
<View className="ml-2 flex-1"> <View className="ml-2 flex-1">
<View className="text-row1 font-28">{data.name}</View> <View className="text-row1 font-28">{data.name}</View>
<View className='font-24 mt-2 text-muted'>{beforeTime(data.created_at)}·</View> <View className='font-24 mt-2 text-muted'>
<Text>{beforeTime(data.created_at)}</Text>
<Text className='ml-2'> {data.article_count || 0}</Text>
</View>
</View> </View>
</View> </View>
{hasMedia && <View className={styles.previewImag + ' mb-2'}>{media}</View>}
<View className={styles.previewImag}> <View className="font-24 text-muted text-row3" style={{lineHeight: 1.4}}>
{media}
</View>
<View className="font-24 text-muted mb-4 text-row3 mt-2" style={{lineHeight: 1.4}}>
{data.graphic_introduction} {data.graphic_introduction}
</View> </View>
</View> </View>
{/*<View className="flex gap20rpx font-24 text-muted justify-around">
<View className="flex gap20rpx font-24 text-muted justify-around">
<View className={styles.feature}> <View className={styles.feature}>
<Image src={articleLine}/> <Image src={articleLine}/>
{data.article_count || 0} {data.article_count || 0}
</View> </View>
<Collect owner_id={data.id} owner_type={4} select={data.collect}/> <Collect owner_id={data.id} owner_type={4} select={data.collect}/>
</View> </View>*/}
</View> </View>
</View> </View>
) )
@ -125,7 +126,7 @@ const BrandList: FC = () => {
return ( return (
<View className='p-2'> <View className='py-2'>
<Spinner enable={loading} overlay/> <Spinner enable={loading} overlay/>
{ {
brands.length ? brands.length ?

Loading…
Cancel
Save