106 lines
4.1 KiB
Plaintext
106 lines
4.1 KiB
Plaintext
<wxs module="fmt">
|
|
function ageLabel(arr) {
|
|
if (!arr || arr.length < 2) {
|
|
return '';
|
|
}
|
|
return arr[0] + '-' + arr[1] + '岁';
|
|
}
|
|
module.exports.ageLabel = ageLabel;
|
|
</wxs>
|
|
|
|
<view class="home-page">
|
|
<view class="home-header">
|
|
<view class="home-brand">
|
|
<text class="home-brand__duck">🦆</text>
|
|
<text class="home-brand__name">涂鸦丫</text>
|
|
</view>
|
|
<view class="home-search">
|
|
<text class="home-search__placeholder">搜索练习单(即将上线)</text>
|
|
</view>
|
|
</view>
|
|
|
|
<category-tabs tabs="{{tabs}}" active-tab="{{activeTab}}" bind:change="onTabChange" />
|
|
|
|
<view class="home-body">
|
|
<block wx:if="{{activeTab != 'all'}}">
|
|
<view class="home-grid">
|
|
<view
|
|
wx:for="{{filteredItems}}"
|
|
wx:key="id"
|
|
class="home-grid__cell"
|
|
bindtap="onCardTap"
|
|
data-id="{{item.id}}"
|
|
>
|
|
<worksheet-card
|
|
title="{{item.title}}"
|
|
preview-bg="{{item.previewBg}}"
|
|
preview-text="{{item.previewText}}"
|
|
img="{{item.img}}"
|
|
age-range="{{fmt.ageLabel(item.ageRange)}}"
|
|
difficulty="{{item.difficulty}}"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</block>
|
|
|
|
<block wx:else>
|
|
<view class="home-section home-section--hot">
|
|
<view class="home-section__title-row">
|
|
<text class="home-section__title">🔥 热门下载</text>
|
|
</view>
|
|
<scroll-view class="home-hot__scroll" scroll-x enable-flex>
|
|
<view class="home-hot__row">
|
|
<view
|
|
wx:for="{{hotItems}}"
|
|
wx:key="id"
|
|
class="home-hot__item"
|
|
bindtap="onHotCardTap"
|
|
data-id="{{item.id}}"
|
|
>
|
|
<view class="home-hot__card-wrap">
|
|
<worksheet-card
|
|
title="{{item.title}}"
|
|
preview-bg="{{item.previewBg}}"
|
|
preview-text="{{item.previewText}}"
|
|
img="{{item.img}}"
|
|
age-range="{{fmt.ageLabel(item.ageRange)}}"
|
|
difficulty="{{item.difficulty}}"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
</view>
|
|
|
|
<view wx:for="{{sections}}" wx:key="category" class="home-section">
|
|
<view class="home-section__head">
|
|
<view class="home-section__head-left">
|
|
<text class="home-section__icon">{{item.icon}}</text>
|
|
<text class="home-section__name">{{item.title}}</text>
|
|
</view>
|
|
<text class="home-section__more" bindtap="onSeeMore" data-category="{{item.category}}">更多</text>
|
|
</view>
|
|
<view class="home-grid">
|
|
<view
|
|
wx:for="{{item.items}}"
|
|
wx:for-item="w"
|
|
wx:key="id"
|
|
class="home-grid__cell"
|
|
bindtap="onCardTap"
|
|
data-id="{{w.id}}"
|
|
>
|
|
<worksheet-card
|
|
title="{{w.title}}"
|
|
preview-bg="{{w.previewBg}}"
|
|
preview-text="{{w.previewText}}"
|
|
img="{{w.img}}"
|
|
age-range="{{fmt.ageLabel(w.ageRange)}}"
|
|
difficulty="{{w.difficulty}}"
|
|
/>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</block>
|
|
</view>
|
|
</view>
|