feat: 更新业务组件
This commit is contained in:
parent
952d5ded20
commit
a8b11c2b06
48
app/components/business/bizcard.tsx
Normal file
48
app/components/business/bizcard.tsx
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 电子名片组件
|
||||
* =========================================
|
||||
* 1. 纯卡片风格
|
||||
* 2. 卡片+图片风格
|
||||
* 3. 纯图片风格
|
||||
* 4. 图片背景风格
|
||||
* =========================================
|
||||
**/
|
||||
import { View, Text } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
interface BizCardProps {
|
||||
title: string;
|
||||
userInfo: User;
|
||||
}
|
||||
|
||||
export const BizCardTpl_01 = memo(({ userInfo }: BizCardProps) => {
|
||||
return (
|
||||
<View>
|
||||
<Text>{userInfo.name}</Text>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
|
||||
export const BizCardTpl_02 = memo(() => {
|
||||
return (
|
||||
<View className="bg-white p-3 h-30 rounded-sm shadow">
|
||||
<Text>Card Title</Text>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
|
||||
export const BizCardTpl_03 = memo(() => {
|
||||
return (
|
||||
<View>
|
||||
<Text>Card Title</Text>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
|
||||
export const BizCardTpl_04 = memo(() => {
|
||||
return (
|
||||
<View>
|
||||
<Text>Card Title</Text>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
7
app/components/business/button.tsx
Normal file
7
app/components/business/button.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
// 按钮组件
|
||||
export const ButtonTpl = memo(() => {
|
||||
return <View></View>;
|
||||
});
|
||||
7
app/components/business/grids.tsx
Normal file
7
app/components/business/grids.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
// 宫格组件
|
||||
export const GridsTpl = memo(() => {
|
||||
return <View></View>;
|
||||
});
|
||||
16
app/components/business/image.tsx
Normal file
16
app/components/business/image.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import { View, Image } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
interface Props {
|
||||
src: string;
|
||||
size: "small" | "medium" | "large" | "raw";
|
||||
}
|
||||
|
||||
export const ImageTpl = memo(({ src, size }: Props) => {
|
||||
console.log(size);
|
||||
return (
|
||||
<View>
|
||||
<Image src={src} mode="widthFix" />
|
||||
</View>
|
||||
);
|
||||
});
|
||||
9
app/components/business/index.ts
Normal file
9
app/components/business/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export * from "./bizcard";
|
||||
export * from "./noticebar";
|
||||
export * from "./swiper";
|
||||
export * from "./image";
|
||||
export * from "./button";
|
||||
export * from "./meida";
|
||||
export * from "./grids";
|
||||
export * from "./list";
|
||||
export * from "./video";
|
||||
7
app/components/business/list.tsx
Normal file
7
app/components/business/list.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
// 列表组件
|
||||
export const ListTpl = memo(() => {
|
||||
return <View></View>;
|
||||
});
|
||||
7
app/components/business/meida.tsx
Normal file
7
app/components/business/meida.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import { View } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
// 图文组件
|
||||
export const MeidaImageTpl = memo(() => {
|
||||
return <View></View>;
|
||||
});
|
||||
35
app/components/business/noticebar.tsx
Normal file
35
app/components/business/noticebar.tsx
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 公告组件
|
||||
* =========================================
|
||||
* 1. 横向单行文本
|
||||
* 2. 横向滚动文本
|
||||
* 3. 竖向滚动多行文本
|
||||
* =========================================
|
||||
**/
|
||||
|
||||
import { View, Text } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
export const NoticeBarTpl_01 = memo(() => {
|
||||
return (
|
||||
<View>
|
||||
<Text>公告内容</Text>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
|
||||
export const NoticeBarTpl_02 = memo(() => {
|
||||
return (
|
||||
<View>
|
||||
<Text>公告内容</Text>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
|
||||
export const NoticeBarTpl_03 = memo(() => {
|
||||
return (
|
||||
<View>
|
||||
<Text>公告内容</Text>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
12
app/components/business/swiper.tsx
Normal file
12
app/components/business/swiper.tsx
Normal file
@ -0,0 +1,12 @@
|
||||
import { Swiper, SwiperItem, View } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
export const SwiperTpl = memo(() => {
|
||||
return (
|
||||
<Swiper>
|
||||
<SwiperItem>
|
||||
<View className="swiper-item">1</View>
|
||||
</SwiperItem>
|
||||
</Swiper>
|
||||
);
|
||||
});
|
||||
7
app/components/business/video.tsx
Normal file
7
app/components/business/video.tsx
Normal file
@ -0,0 +1,7 @@
|
||||
import { Video } from "@tarojs/components";
|
||||
import { memo } from "react";
|
||||
|
||||
// 视频组件
|
||||
export const VideoTpl = memo(() => {
|
||||
return <Video src="https://example.com/video.mp4" />;
|
||||
});
|
||||
@ -109,11 +109,12 @@ const LayoutContainer = memo(
|
||||
},
|
||||
);
|
||||
|
||||
// 自定义页脚
|
||||
// 自定义页脚 底部安全区,暂时未适配 Android
|
||||
const LayoutFooter = memo(({ children }: PropsWithChildren) => {
|
||||
return (
|
||||
<View className="h-[150px] bg-green-500 text-white flex items-center justify-center">
|
||||
{children}
|
||||
<View className=" bg-green-500 text-white">
|
||||
<View>{children}</View>
|
||||
<View className="min-h-6 safe_bottom bg-amber-400"></View>
|
||||
</View>
|
||||
);
|
||||
});
|
||||
|
||||
@ -1,9 +1,16 @@
|
||||
import Layout from "@/components/layout/Layout";
|
||||
import { View, Text } from "@tarojs/components";
|
||||
import { View } from "@tarojs/components";
|
||||
import { useDidShow } from "@tarojs/taro";
|
||||
import { useRefresherConfig } from "@/components/layout";
|
||||
import React, { Suspense } from "react";
|
||||
import { usePageContent } from "./hooks";
|
||||
|
||||
const BizCardTpl02 = React.lazy(() =>
|
||||
import("@/components/business").then((module) => ({
|
||||
default: module.BizCardTpl_02,
|
||||
})),
|
||||
);
|
||||
|
||||
export default function Index() {
|
||||
const { pageLoading, pageContent, loadPageContent } = usePageContent();
|
||||
|
||||
@ -30,16 +37,11 @@ export default function Index() {
|
||||
className="bg-red-400"
|
||||
refresherConfig={refresherConfig}
|
||||
>
|
||||
<View className="space-y-4">
|
||||
{Array.from({ length: 10 }).map((_, index) => (
|
||||
<View
|
||||
key={index}
|
||||
className="h-[200px] text-center leading-[200px] bg-red-500 text-white text-2xl"
|
||||
>
|
||||
<Text className="">{pageContent}</Text>
|
||||
</View>
|
||||
))}
|
||||
<Suspense fallback={<View className="space-y-4 p-3">加载中</View>}>
|
||||
<View className="space-y-4 p-3">
|
||||
<BizCardTpl02 />
|
||||
</View>
|
||||
</Suspense>
|
||||
</Layout.Container>
|
||||
<Layout.Footer>测试页脚</Layout.Footer>
|
||||
</Layout>
|
||||
|
||||
@ -1 +1,7 @@
|
||||
@import "weapp-tailwindcss";
|
||||
|
||||
@layer utilities {
|
||||
.safe_bottom {
|
||||
height: env(safe-area-inset-bottom);
|
||||
}
|
||||
}
|
||||
|
||||
6
types/types.d.ts
vendored
Normal file
6
types/types.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
interface User {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string;
|
||||
age: number;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user