feat: migrate static pages to native tabbar
This commit is contained in:
125
packages/tcm/pages/book-detail/index.js
Normal file
125
packages/tcm/pages/book-detail/index.js
Normal file
@@ -0,0 +1,125 @@
|
||||
const { resolveScene } = require('../../../../utils/static-ux/shared')
|
||||
const { ROUTES, openStaticRoute } = require('../../../../utils/static-ux/route-map')
|
||||
|
||||
const BOOK_DETAIL_SURFACES = Object.freeze({
|
||||
'classic-a': {
|
||||
coverText: '黄',
|
||||
title: '黄帝内经素问',
|
||||
subtitle: '传世中医典籍 · 学习阅读入口',
|
||||
tags: ['经典', '入门'],
|
||||
description: '当前典籍详情页只保留封面、简介、目录和推荐区块,不迁移旧项目的详情接口。',
|
||||
progressText: '已读到:上古天真论',
|
||||
primaryRoute: `${ROUTES.tcm.section}?scene=reader-a`,
|
||||
catalog: [
|
||||
{
|
||||
key: 'chapter-1',
|
||||
title: '上古天真论',
|
||||
route: `${ROUTES.tcm.section}?scene=reader-a`,
|
||||
children: ['节录一', '节录二']
|
||||
},
|
||||
{
|
||||
key: 'chapter-2',
|
||||
title: '四气调神大论',
|
||||
route: `${ROUTES.tcm.section}?scene=reader-a`,
|
||||
children: ['节录一', '节录二']
|
||||
}
|
||||
],
|
||||
recommends: [
|
||||
{
|
||||
key: 'recommend-b',
|
||||
title: '伤寒论',
|
||||
route: `${ROUTES.tcm.bookDetail}?scene=classic-b`
|
||||
}
|
||||
]
|
||||
},
|
||||
'classic-b': {
|
||||
coverText: '伤',
|
||||
title: '伤寒论',
|
||||
subtitle: '经方经典 · 学习阅读入口',
|
||||
tags: ['经方', '进阶'],
|
||||
description: '静态详情页保留目录结构和推荐卡片,为后续新数据层留出清晰接口边界。',
|
||||
progressText: '已读到:太阳病篇',
|
||||
primaryRoute: `${ROUTES.tcm.section}?scene=reader-b`,
|
||||
catalog: [
|
||||
{
|
||||
key: 'chapter-1',
|
||||
title: '太阳病篇',
|
||||
route: `${ROUTES.tcm.section}?scene=reader-b`,
|
||||
children: ['条文一', '条文二']
|
||||
},
|
||||
{
|
||||
key: 'chapter-2',
|
||||
title: '阳明病篇',
|
||||
route: `${ROUTES.tcm.section}?scene=reader-b`,
|
||||
children: ['条文一', '条文二']
|
||||
}
|
||||
],
|
||||
recommends: [
|
||||
{
|
||||
key: 'recommend-a',
|
||||
title: '黄帝内经素问',
|
||||
route: `${ROUTES.tcm.bookDetail}?scene=classic-a`
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
function cloneCatalog(items) {
|
||||
return items.map(item => ({
|
||||
...item,
|
||||
children: [...item.children]
|
||||
}))
|
||||
}
|
||||
|
||||
function cloneItems(items) {
|
||||
return items.map(item => ({ ...item }))
|
||||
}
|
||||
|
||||
function createTcmBookDetailPageData(rawScene) {
|
||||
const scene = resolveScene(rawScene, ['classic-a', 'classic-b'], 'classic-a')
|
||||
const surface = BOOK_DETAIL_SURFACES[scene]
|
||||
|
||||
return {
|
||||
title: '典籍详情',
|
||||
scene,
|
||||
coverText: surface.coverText,
|
||||
book: {
|
||||
title: surface.title,
|
||||
subtitle: surface.subtitle
|
||||
},
|
||||
tags: [...surface.tags],
|
||||
description: surface.description,
|
||||
progressText: surface.progressText,
|
||||
primaryRoute: surface.primaryRoute,
|
||||
catalog: cloneCatalog(surface.catalog),
|
||||
recommends: cloneItems(surface.recommends)
|
||||
}
|
||||
}
|
||||
|
||||
function showNavigate(route) {
|
||||
openStaticRoute(route, wx)
|
||||
}
|
||||
|
||||
Page({
|
||||
data: createTcmBookDetailPageData('classic-a'),
|
||||
|
||||
onLoad(options) {
|
||||
this.setData(createTcmBookDetailPageData(options.scene))
|
||||
},
|
||||
|
||||
handlePrimaryTap() {
|
||||
showNavigate(this.data.primaryRoute)
|
||||
},
|
||||
|
||||
handleCatalogTap(event) {
|
||||
showNavigate(event.currentTarget.dataset.route)
|
||||
},
|
||||
|
||||
handleRecommendTap(event) {
|
||||
showNavigate(event.currentTarget.dataset.route)
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
createTcmBookDetailPageData
|
||||
}
|
||||
5
packages/tcm/pages/book-detail/index.json
Normal file
5
packages/tcm/pages/book-detail/index.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "典籍详情",
|
||||
"navigationBarBackgroundColor": "#f8ecd8",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
54
packages/tcm/pages/book-detail/index.wxml
Normal file
54
packages/tcm/pages/book-detail/index.wxml
Normal file
@@ -0,0 +1,54 @@
|
||||
<view class="book-detail-page">
|
||||
<view class="hero-card">
|
||||
<view class="hero-card__cover">{{coverText}}</view>
|
||||
<view class="hero-card__body">
|
||||
<text class="hero-card__title">{{book.title}}</text>
|
||||
<text class="hero-card__subtitle">{{book.subtitle}}</text>
|
||||
<view class="hero-card__tags">
|
||||
<text class="hero-card__tag" wx:for="{{tags}}" wx:key="index">{{item}}</text>
|
||||
</view>
|
||||
<view class="hero-card__button" bindtap="handlePrimaryTap">开始阅读</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section-card">
|
||||
<text class="section-card__title">简介</text>
|
||||
<text class="section-card__description">{{description}}</text>
|
||||
</view>
|
||||
|
||||
<view class="section-card">
|
||||
<text class="section-card__title">我的阅读进度</text>
|
||||
<text class="section-card__description">{{progressText}}</text>
|
||||
</view>
|
||||
|
||||
<view class="section-card">
|
||||
<text class="section-card__title">章节目录</text>
|
||||
<view
|
||||
class="catalog-row"
|
||||
wx:for="{{catalog}}"
|
||||
wx:key="key"
|
||||
data-route="{{item.route}}"
|
||||
bindtap="handleCatalogTap"
|
||||
>
|
||||
<view class="catalog-row__body">
|
||||
<text class="catalog-row__title">{{item.title}}</text>
|
||||
<text class="catalog-row__child" wx:for="{{item.children}}" wx:key="index">{{item}}</text>
|
||||
</view>
|
||||
<text class="catalog-row__arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section-card">
|
||||
<text class="section-card__title">相关推荐</text>
|
||||
<view
|
||||
class="recommend-card"
|
||||
wx:for="{{recommends}}"
|
||||
wx:key="key"
|
||||
data-route="{{item.route}}"
|
||||
bindtap="handleRecommendTap"
|
||||
>
|
||||
<text class="recommend-card__cover">典</text>
|
||||
<text class="recommend-card__title">{{item.title}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
147
packages/tcm/pages/book-detail/index.wxss
Normal file
147
packages/tcm/pages/book-detail/index.wxss
Normal file
@@ -0,0 +1,147 @@
|
||||
page {
|
||||
min-height: 100%;
|
||||
background: linear-gradient(180deg, #fbf4e9 0%, #f3eadf 100%);
|
||||
}
|
||||
|
||||
.book-detail-page {
|
||||
box-sizing: border-box;
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 20rpx 72rpx;
|
||||
}
|
||||
|
||||
.hero-card,
|
||||
.section-card {
|
||||
margin-top: 18rpx;
|
||||
padding: 28rpx;
|
||||
border: 1rpx solid rgba(118, 83, 42, 0.08);
|
||||
border-radius: 32rpx;
|
||||
background: rgba(255, 250, 242, 0.92);
|
||||
box-shadow: 0 18rpx 42rpx rgba(86, 58, 25, 0.08);
|
||||
}
|
||||
|
||||
.hero-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.hero-card__cover {
|
||||
width: 126rpx;
|
||||
height: 168rpx;
|
||||
border-radius: 24rpx;
|
||||
background: linear-gradient(180deg, #d0b288 0%, #b98b5a 100%);
|
||||
color: #fff9ef;
|
||||
font-family: 'STSong', 'Songti SC', serif;
|
||||
font-size: 42rpx;
|
||||
font-weight: 700;
|
||||
line-height: 168rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hero-card__body {
|
||||
flex: 1;
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.hero-card__title,
|
||||
.section-card__title,
|
||||
.catalog-row__title {
|
||||
display: block;
|
||||
color: #2c2419;
|
||||
font-family: 'STSong', 'Songti SC', serif;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.hero-card__subtitle,
|
||||
.section-card__description,
|
||||
.catalog-row__child {
|
||||
display: block;
|
||||
margin-top: 10rpx;
|
||||
color: #7d705d;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.hero-card__tags {
|
||||
margin-top: 14rpx;
|
||||
}
|
||||
|
||||
.hero-card__tag {
|
||||
display: inline-block;
|
||||
margin-right: 8rpx;
|
||||
padding: 8rpx 16rpx;
|
||||
border-radius: 999rpx;
|
||||
background: rgba(111, 66, 22, 0.08);
|
||||
color: #6f4216;
|
||||
font-size: 22rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.hero-card__button {
|
||||
display: inline-block;
|
||||
margin-top: 18rpx;
|
||||
padding: 18rpx 24rpx;
|
||||
border-radius: 24rpx;
|
||||
background: linear-gradient(135deg, #9a622d 0%, #6f4216 100%);
|
||||
color: #fff8ef;
|
||||
font-size: 26rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.catalog-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 16rpx;
|
||||
padding: 18rpx 0;
|
||||
border-bottom: 1rpx solid rgba(118, 83, 42, 0.08);
|
||||
}
|
||||
|
||||
.catalog-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.catalog-row__body {
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.catalog-row__arrow {
|
||||
color: #bfa882;
|
||||
font-size: 28rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.recommend-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-top: 16rpx;
|
||||
padding: 18rpx 0;
|
||||
border-bottom: 1rpx solid rgba(118, 83, 42, 0.08);
|
||||
}
|
||||
|
||||
.recommend-card:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.recommend-card__cover {
|
||||
width: 70rpx;
|
||||
height: 90rpx;
|
||||
border-radius: 18rpx;
|
||||
background: linear-gradient(180deg, #d0b288 0%, #b98b5a 100%);
|
||||
color: #fff9ef;
|
||||
font-family: 'STSong', 'Songti SC', serif;
|
||||
font-size: 28rpx;
|
||||
font-weight: 700;
|
||||
line-height: 90rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.recommend-card__title {
|
||||
margin-left: 16rpx;
|
||||
color: #2c2419;
|
||||
font-size: 28rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
Reference in New Issue
Block a user