預覽
timeline.gif
場景
用于快遞節(jié)點跟蹤、發(fā)展歷程等
要點
1.position作布局
2.border-radius畫圓點
3.moment格式化時間,區(qū)分當日(HH:mm)與前日的格式(YYYY-MM-DD HH:mm)
wxml
-
<view class="listview-container">
<block wx:for="{{newsList}}" wx:key="">
<view class="playlog-item" bindtap="itemTapped">
<view class="dotline">
<!-- 豎線 -->
<view class="line"></view>
<!-- 圓點 -->
<view class="dot"></view>
<!-- 時間戳 -->
</view>
<view class="content">
<text class="course">{{item.time}}</text>
<text class="chapter">{{item.content}}</text>
</view>
</view>
<ad unit-id="adunit-5abb45645905fc90" wx:if="{{index % 5 == 4}}"></ad>
</block></view>
|
wxss
-
/*時間軸*/
/*外部容器*/
.listview-container {
margin: 10rpx 10rpx;
}
/*行樣式*/
.playlog-item {
display: flex;
}
/*時間軸*/
.playlog-item .dotline {
width: 35px;
position: relative;
}
/*豎線*/
.playlog-item .dotline .line {
width: 1px;
height: 100%;
background: #ccc;
position: absolute;
top: 0;
left: 15px;
}
/*圓點*/
.playlog-item .dotline .dot {
width: 11px;
height: 11px;
background: #30ac63;
position: absolute;
top: 10px;
left: 10px;
border-radius: 50%;
}
/*時間戳*/
.playlog-item .dotline .time {
width: 100%;
position: absolute;
margin-top: 30px;
z-index: 99;
font-size: 12px;
color: #777;
text-align: center;
}
/*右側主體內容*/
.playlog-item .content {
width: 100%;
display: flex;
flex-direction: column;
border-bottom: 1px solid #ddd;
margin: 3px 0;
}
/*章節(jié)部分*/
.playlog-item .content .chapter {
font-size: 30rpx;
line-height: 68rpx;
color: #444;
white-space: normal;
padding-right: 10px;
}
/*課程部分*/
.playlog-item .content .course {
font-size: 28rpx;
line-height: 56rpx;
color: #999;
}
|
js
-
var moment = require('./moment.min');
// 格式化訂單
var formatNews = function (news) {
return news.map(item => {
var time = moment(item.postTime);
var zero = moment().format('YYYY-MM-DD');
var after = moment(time).isAfter(zero);
if (after) {
item.time = moment(item.postTime).format('HH:mm');
} else {
item.time = moment(item.postTime).format('YYYY-MM-DD HH:mm');
}
return item;
});
}
module.exports = {
formatNews
}
|
|