
<import src="../../components/trip/trip.wxml"/>
<scroll-view class="list" style="height: {{ windowHeight }}px; width: {{ windowWidth }}px;" scroll-y="true" bindscrolltolower="loadMore" lower-threshold="800">
<block wx:for="{{ trips }}" wx:for-item="trip" wx:key="trip.data[0].id">
<template is="m-trip" wx:if="{{ trip.type === 4 }}" data="{{trip: trip.data[0], mode: 1}}" />
</block>
<view class="loading">
正在加载...
</view>
</scroll-view>
|
@import "../../components/trip/trip.wxss";
page{
background-color: #f6f6f6;
}
.list{
}
.m-trip{
margin: 20rpx;
}
.trip-title{
margin-bottom: 10rpx;
}
.loading{
color: #b0b0b0;
text-align: center;
margin: 20rpx 0;
}
.loading-gif{
width: 220rpx;
height: 42rpx;
vertical-align: bottom;
}
|
const App = getApp();
const api = require('../../utils/api.js');
const util = require('../../utils/util.js');
const formatTime = util.formatTime;
Page({
data: {
trips: [],
start: 0,
loading: false,
windowWidth: App.systemInfo.windowWidth,
windowHeight: App.systemInfo.windowHeight,
},
onLoad() {
this.loadMore();
},
onPullDownRefresh() {
this.loadMore(null, true);
},
loadMore(e, needRefresh) {
const self = this;
const loading = self.data.loading;
const data = {
next_start: self.data.start,
};
if (loading) {
return;
}
self.setData({
loading: true,
});
api.getHotTripList({
data,
success: (res) => {
let newList = res.data.data.elements;
newList.map((trip) => {
const item = trip;
item.data[0].date_added = formatTime(new Date(item.data[0].date_added * 1000), 1);
return item;
});
if (needRefresh) {
wx.stopPullDownRefresh();
} else {
newList = self.data.trips.concat(newList);
}
self.setData({
trips: newList,
});
const nextStart = res.data.data.next_start;
self.setData({
start: nextStart,
loading: false,
});
},
});
},
viewTrip(e) {
const ds = e.currentTarget.dataset;
wx.navigateTo({
url: `../trip/trip?id=${ds.id}&name=${ds.name}`,
});
},
});
|
模板简介:该模板名称为【微信小程序大图旅游文章支持无限加载列表样式制作设计教程】,大小是,文档格式为.,推荐使用打开,作品中的图片,文字等数据均可修改,图片请在作品中选中图片替换即可,文字修改直接点击文字修改即可,您也可以新增或修改作品中的内容,该模板来自用户分享,如有侵权行为请联系网站客服处理。欢迎来懒人模板【小程序教程】栏目查找您需要的精美模板。