W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
解釋:圖文詳情頁模板。你可以加載含有圖片、文本、引用、標題等形式的內容。同時,圖文詳情頁模板內置了回到頂端按鈕與關注/取消關注按鈕,支持點擊作者跳轉與圖片查看器。圖文詳情頁通常用來展示文章、帖子等內容的詳情。
npm i @smt-ui-template/page-content-detail
.
├── project.swan.json
├── app.json
├── app.js
├── pages
└── @smt-ui-template-content-detail // 模板文件
{
"pages": [
...
"pages/@smt-ui-template-content-detail/index/index",
...
]
}
<view class="wrap">
<view s-if="!showPageStatus" class="content-header" ></view>
<scroll-view scroll-y scroll-top="{=scrollTop=}" s-if="!showPageStatus" class="content-container {{isPhoneX ? 'content-container-ipx' : ''}}" bindscroll="onPageScroll" bindtouchmove="scrollPage" bindtouchstart="touchstart">
<view class="content-title">
<text selectable>{{title}}</text>
</view>
<view class="content-desp">
<view class="author-detail" bindtap="tapuser" data-user-id="{{authorId}}">
<image class="author-avator" mode="widthFix" src="{{avator}}"></image>
<view class="author-other">
<view class="author-name">{{author}}</view>
<view class="publish-date">{{date}}</view>
</view>
</view>
<button s-if="showFollowBtn" class="follow-btn" size="mini" type="{{isFollow ? 'default' : 'primary'}}" bindtap="tapfollow" loading="{{btnLoading}}">{{btnLoading ? '' : (isFollow ? '已關注' : '關注')}}</button>
</view>
<view class="content-detail">
<view s-for="item in content" class="detail-{{item.type}}">
<quote s-if="item.type == 'quote'" content="{{item.content}}"></quote>
<text selectable s-if="item.type == 'p' || item.type == 'title'">{{item.content}}</text>
<image lazy-load s-if="item.type == 'img'" mode="widthFix" src="{{item.content}}" data-src="{{item.content}}" bindtap="tapimg" bindlongpress="longtapimg"></image>
</view>
</view>
<top class="top-view {{showTopBtn ? 'top-view-show' : 'top-view-hide'}}" bind:top="backToTop"></top>
</scroll-view>
</view>
設計指南
為保證信息流分發(fā)時落地頁瀏覽體驗的一致性,建議正文字號使用默認字號 57px,如需自定義正文字號,可在正負 3px 空間內浮動。
getArticleDetail(articleId, cb) {
let params = {
url: '',
method: 'GET',
data: {
articleId
},
...
swan.navigateTo({
url: `/user-detail/user-detail?userId=${userId}`
});
tapfollow(e) {
...
let params = {
url: '',
method: 'POST',
data: {
authorId: this.data.authorId
},
...
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯系方式:
更多建議: