Draft
As a 小程序用户, I want 看到与tcb-shop-demo设计一致的现代化首页UI, so that 我能获得更好的视觉体验和更直观的商品浏览体验
mini/src/pages/index/index.tsx 首页组件tcb-shop-demo/pages/home/home.wxml 实现页面结构mini/src/components/goods-card/index.tsx 商品卡片组件tcb-shop-demo/components/goods-card/index.wxml 实现商品卡片布局mini/src/components/goods-list/index.tsx 商品列表组件tcb-shop-demo/components/goods-list/index.wxml 实现列表结构tdesign-miniprogrammini/package.json 中添加依赖mini/config/index.js 中配置小程序组件路径mini/app.config.ts 中配置usingComponentst-search 组件t-swiper 组件t-icon 组件t-toast 组件t-tabs 和 t-tab-panel 组件mini/src/pages/index/index.tsxmini/src/components/mini/src/tcb-theme.cssmini/src/layouts/tab-bar-layout.tsxtcb-shop-demo/pages/home/home.wxmltcb-shop-demo/pages/home/home.wxsstcb-shop-demo/pages/home/home.jstcb-shop-demo/components/goods-list/index.wxmltcb-shop-demo/components/goods-card/index.wxmltcb-shop-demo/components/goods-card/index.wxssmini/src/tcb-theme.css 中完整集成linear-gradient(#fff, #f5f5f5)cd mini
npm install tdesign-miniprogram
在 mini/config/index.js 中配置组件路径:
const config = {
// ... 其他配置
copy: {
patterns: [
{
from: 'node_modules/tdesign-miniprogram/miniprogram_dist/',
to: 'tdesign/',
},
],
},
}
在 mini/app.config.ts 中注册全局组件:
export default defineAppConfig({
usingComponents: {
't-search': 'tdesign/search/index',
't-swiper': 'tdesign/swiper/index',
't-icon': 'tdesign/icon/index',
't-toast': 'tdesign/toast/index',
't-tabs': 'tdesign/tabs/index',
't-tab-panel': 'tdesign/tabs/tab-panel/index',
},
})
Search组件
<t-search
placeholder="搜索商品"
disabled={false}
shape="round"
class="rounded-[32rpx] h-[64rpx]"
/>
Swiper组件
<t-swiper
autoplay
interval={3000}
indicator-dots
>
{banners.map((banner, index) => (
<swiper-item key={index}>
<image src={banner.image} mode="aspectFill" />
</swiper-item>
))}
</t-swiper>
Icon组件
<t-icon name="search" size="32rpx" color="#fa550f" />
<t-icon name="cart" size="32rpx" color="#fa550f" />
Toast组件
// 在TSX中需要通过ref调用
import { createSelectorQuery } from '@tarojs/taro'
const showToast = () => {
const query = createSelectorQuery()
query.select('#toast').node((res) => {
const toast = res.node
toast.show({
message: '操作成功',
theme: 'success',
duration: 2000,
})
}).exec()
}
// 在render中
<t-toast id="toast" />
Tabs组件
<t-tabs value={activeTab} bindchange={handleTabChange}>
{categories.map(category => (
<t-tab-panel key={category.id} label={category.name} value={category.id}>
<GoodsList categoryId={category.id} />
</t-tab-panel>
))}
</t-tabs>
class 属性而不是 className__tests__ 文件夹与源码并列| Date | Version | Description | Author |
|---|---|---|---|
| 2025-11-20 | 1.0 | 初始故事创建 | Bob (Scrum Master) |
This section is populated by the development agent during implementation
Record the specific AI agent model and version used for development
Reference any debug logs or traces generated during development
Notes about the completion of tasks and any issues encountered
List all files created, modified, or affected during story implementation
Results from QA Agent QA review of the completed story implementation