feat: migrate static pages to native tabbar
This commit is contained in:
61
packages/mingli/pages/search-books/index.js
Normal file
61
packages/mingli/pages/search-books/index.js
Normal file
@@ -0,0 +1,61 @@
|
||||
const { ROUTES, openStaticRoute } = require('../../../../utils/static-ux/route-map')
|
||||
|
||||
const SEARCH_CATALOG = Object.freeze([
|
||||
{
|
||||
key: 'classic-a',
|
||||
title: '滴天髓',
|
||||
subtitle: '命理经典结果',
|
||||
aliases: ['滴天', '天髓'],
|
||||
route: `${ROUTES.mingli.bookDetail}?scene=classic-a`
|
||||
},
|
||||
{
|
||||
key: 'classic-b',
|
||||
title: '穷通宝鉴',
|
||||
subtitle: '格局与用神',
|
||||
aliases: ['穷通', '宝鉴'],
|
||||
route: `${ROUTES.mingli.bookDetail}?scene=classic-b`
|
||||
}
|
||||
])
|
||||
|
||||
function createMingliSearchBooksPageData(keyword) {
|
||||
const normalizedKeyword = (keyword || '').trim()
|
||||
const results = normalizedKeyword
|
||||
? SEARCH_CATALOG.filter(item => {
|
||||
return (
|
||||
item.title.includes(normalizedKeyword) ||
|
||||
item.aliases.some(alias => alias.includes(normalizedKeyword))
|
||||
)
|
||||
}).map(item => ({ ...item }))
|
||||
: []
|
||||
|
||||
return {
|
||||
title: '搜索易学典籍',
|
||||
keyword: normalizedKeyword,
|
||||
history: ['滴天髓', '穷通宝鉴', '子平真诠'],
|
||||
results
|
||||
}
|
||||
}
|
||||
|
||||
function showNavigate(route) {
|
||||
openStaticRoute(route, wx)
|
||||
}
|
||||
|
||||
Page({
|
||||
data: createMingliSearchBooksPageData(''),
|
||||
|
||||
onLoad(options) {
|
||||
this.setData(createMingliSearchBooksPageData(options.keyword || options.q))
|
||||
},
|
||||
|
||||
handleHistoryTap(event) {
|
||||
this.setData(createMingliSearchBooksPageData(event.currentTarget.dataset.keyword))
|
||||
},
|
||||
|
||||
handleResultTap(event) {
|
||||
showNavigate(event.currentTarget.dataset.route)
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
createMingliSearchBooksPageData
|
||||
}
|
||||
5
packages/mingli/pages/search-books/index.json
Normal file
5
packages/mingli/pages/search-books/index.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"navigationBarTitleText": "搜索易学典籍",
|
||||
"navigationBarBackgroundColor": "#f8f0ee",
|
||||
"navigationBarTextStyle": "black"
|
||||
}
|
||||
21
packages/mingli/pages/search-books/index.wxml
Normal file
21
packages/mingli/pages/search-books/index.wxml
Normal file
@@ -0,0 +1,21 @@
|
||||
<view class="mingli-search-page">
|
||||
<view class="section-card">
|
||||
<text class="section-card__title">{{title}}</text>
|
||||
<text class="section-card__item" wx:for="{{history}}" wx:key="index" data-keyword="{{item}}" bindtap="handleHistoryTap">
|
||||
{{item}}
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{results.length}}" class="section-card">
|
||||
<text class="section-card__title">搜索结果</text>
|
||||
<view
|
||||
class="section-card__item"
|
||||
wx:for="{{results}}"
|
||||
wx:key="key"
|
||||
data-route="{{item.route}}"
|
||||
bindtap="handleResultTap"
|
||||
>
|
||||
{{item.title}} · {{item.subtitle}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
43
packages/mingli/pages/search-books/index.wxss
Normal file
43
packages/mingli/pages/search-books/index.wxss
Normal file
@@ -0,0 +1,43 @@
|
||||
page {
|
||||
min-height: 100%;
|
||||
background: linear-gradient(180deg, #f9f7f5 0%, #f3ebe8 100%);
|
||||
}
|
||||
|
||||
.mingli-search-page {
|
||||
box-sizing: border-box;
|
||||
min-height: 100vh;
|
||||
padding: 28rpx 20rpx 72rpx;
|
||||
}
|
||||
|
||||
.section-card {
|
||||
margin-top: 18rpx;
|
||||
padding: 24rpx;
|
||||
border: 1rpx solid rgba(139, 59, 49, 0.08);
|
||||
border-radius: 28rpx;
|
||||
background: rgba(255, 252, 248, 0.94);
|
||||
box-shadow: 0 10rpx 26rpx rgba(139, 59, 49, 0.06);
|
||||
}
|
||||
|
||||
.section-card:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.section-card__title {
|
||||
display: block;
|
||||
color: #2c2621;
|
||||
font-family: 'STSong', 'Songti SC', serif;
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.section-card__item {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
padding: 18rpx 20rpx;
|
||||
border-radius: 20rpx;
|
||||
background: rgba(139, 59, 49, 0.08);
|
||||
color: #8b3b31;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
Reference in New Issue
Block a user