W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
解釋: 搜索頁(yè)模板,包括搜索框、搜索推薦、搜索運(yùn)營(yíng)、搜索結(jié)果列表等內(nèi)容。
npm i @smt-ui-template/page-search
.
├── project.swan.json
├── app.json
├── app.js
├── pages
└── @smt-ui-template-page-search // 模板文件
{
"pages": [
...
"pages/@smt-ui-template-page-search/index/index"
...
]
}
<!-- index.swan -->
<view class="container" bindtap="containerTap">
<topbar
title="搜索"
has-back="{{showBack}}"
backgroundColor="#fff"
bindnavigateback="navigateBack">
</topbar>
<view class="search-bar-area">
<smt-search-bar class="search-bar"
search-icon-color="#999"
placeholder="{{searchPlaceholder}}"
preset-word="{{searchPresetword}}"
value="{=searchValue=}"
focus="{=isFocus=}"
bindsearch="search"
bindclear="clear"
bindinput="input"
bindfocus="focus"
theme="white"/>
</view>
<view style="padding-bottom: {{isFocus ? keybordHeight : 0 }}px;" class="search-content-area">
<search-block
title="歷史搜索"
max-height="367.75rpx"
s-if="historyItems.length > 0 && searchValue == ''">
<slot slot="actions">
<view class="history-action-group">
<view s-if="showActions" catchtap="deleteAll" class="action-delete-all">全部刪除</view>
<view s-if="showActions" catchtap="hideActions" class="action-complate">完成</view>
<view s-else class="action-delete" catchtap="showActions">
<smt-icon name="trash" color="#999" size="32.61rpx"></smt-icon>
</view>
</view>
</slot>
<slot slot="content">
<block s-for="item, index in historyItems">
<view
class="history-label history-label-{{item.status}}"
hover-class="history-label-hover"
hover-start-time="0"
hover-stay-time="0"
data-status="{{item.status}}"
data-index="{{index}}"
data-value="{{item.label}}"
catchtap="historyLabelTap"
bindlongpress="historyLableLongpress">{{item.label}}
<smt-icon
class="icon-delete"
s-if="item.status === 1"
name="delete"
color="#999"
size="21.74rpx"></smt-icon>
</view>
</block>
</slot>
</search-block>
<search-block
title="大家都在搜"
max-height="289.86rpx"
s-if="operateItems.length > 0 && searchValue == ''">
<slot slot="content">
<block s-for="item, index in operateItems">
<view
class="operate-item {{index % 2 == 0 ? '' : 'operate-odd'}}"
hover-class="operate-item-hover"
hover-stay-time="100"
bindtap="operateItemTap"
data-item="{{item}}">{{item}}</view>
</block>
</slot>
</search-block>
<view class="suggestion-area swan-security-margin-bottom" s-if="searchValue !== '' && suggestionItems.length > 0">
<block s-for="item in suggestionItems">
<view
class="suggestion-item-container"
hover-class="suggestion-item-hover"
hover-stay-time="100"
bindtap="suggestionTap"
data-item="{{item.label}}">
<view class="suggestion-item">
<smt-icon name="magnifying-glass" color="#ccc" size="32.61rpx"></smt-icon>
<view class="search-suggestion-item">
<block s-for="text in item.textArr">
<text selectable="false" class="{{text === searchValue ? 'text-highlight' : ''}}">{{text}}</text>
</block>
</view>
<view catchtap="suggestionArrowTap" data-item="{{item.label}}">
<smt-icon name="arrow-top-left" color="#ccc" size="32.61rpx"></smt-icon>
</view>
</view>
</view>
</block>
</view>
<view class="search-result-area swan-security-margin-bottom" s-if="searchValue !== '' && suggestionItems.length == 0 && searchResult.length > 0">
<block s-for="item in searchResult">
<view
class="search-result-item-container"
hover-class="search-result-item-hover"
hover-stay-time="100"
data-item="{{item}}"
bindtap="resultItemTap">
<view class="search-result-item">
<view class="search-result-name">
<block s-for="text in item.textArr">
<text selectable="false" class="{{text === searchValue ? 'text-highlight' : ''}}">{{text}}</text>
</block>
</view>
<view class="search-result-desc">{{item.desc}}</view>
</view>
</view>
</block>
</view>
</view>
<view class="search-status-area" s-if="isLoading || showStatus">
<smt-page-status
class="search-status"
loading="{{pageStatus.loading}}"
loading-title="{{pageStatus.loadingTitle}}"
bind:smtreloading="reloading"
title="{{pageStatus.title}}"
desc="{{pageStatus.desc}}"
icon="{{pageStatus.icon}}"
showBtn="{{pageStatus.showBtn}}"
btnText="{{pageStatus.btnText}}">
</smt-page-status>
</view>
</view>
{
"navigationBarTitleText": "智能小程序示例",
"navigationStyle": "custom",
"usingComponents": {
"topbar": "../components/topbar/topbar",
"search-block": "../components/search-block/search-block",
"smt-search-bar": "@smt-ui/component/src/search-bar",
"smt-icon": "@smt-ui/component/src/icon",
"smt-page-status": "@smt-ui/component/src/page-status"
}
}
頁(yè)面路徑: index/index
搜索模板頁(yè)包括導(dǎo)航欄、搜索框、搜索歷史區(qū)域、搜索推薦區(qū)域、搜索推薦列表、搜索結(jié)果列表等內(nèi)容,開(kāi)發(fā)者可根據(jù)自身需要添加或刪除模塊。
名稱 | 版本號(hào) |
---|---|
@smt-ui/component | latest |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: