Commit eed85aaf by TengFengLian

游客攻略、动态列表分页加载

parent 4c88717c
const app = getApp()
Page({
data: {
// banner 列表数据
......@@ -6,6 +8,9 @@ Page({
bannerHeight: 300,
info: {},
// 接口参数
id: '',
},
onLoad: function (options) {
......@@ -62,4 +67,10 @@ Page({
bannerIndex: funcEvent.detail.current
})
},
//主题活动详情
getActivityDetail(){
var that = this
}
})
\ No newline at end of file
import iMiment from '../../npm/miment.js'
const app = getApp()
Page({
data: {
......@@ -7,8 +8,10 @@ Page({
},
onLoad: function () {
this.queryActivity()
this.queryOther()
// this.queryActivity()
// this.queryOther()
this.getActivityList(1)
this.getActivityList(0)
},
queryActivity: function () {
......@@ -68,8 +71,46 @@ Page({
},
onActivityDetail: function (funcItem) {
console.log('onActivityDetail',funcItem)
wx.navigateTo({
url: '/pages/activity-detail/activity-detail'
url: '/pages/activity-detail/activity-detail?id='+funcItem.currentTarget.dataset.id
})
},
//主题活动列表 type 1 近期 0 往期
getActivityList(type){
var that = this
app.wxRequest({
url: '/api/v1/activity/getList',
data: {
listType: type,
pageSize: 20,
pageNo: 1,
},
success: function(res) {
var tmpArr = [];
res.data.list.forEach(item => {
var tmpItem = {
id: item.id,
cover: item.cover,
title: item.name,
date: item.activeDate + ' ' + item.activeTime,//'6月30日-7月12日 10:00-12:00',
describe: item.summary,
}
tmpArr.push(tmpItem)
})
if (type == 1) {
that.setData({
activity: tmpArr
})
} else {
that.setData({
other: tmpArr
})
}
}
})
}
})
\ No newline at end of file
......@@ -21,21 +21,24 @@
</block>
</view>
<view class="title row">
<image src="./image/title-2.png"></image>
</view>
<block wx:if="{{other.length > 0}}">
<view class="title row">
<image src="./image/title-2.png"></image>
</view>
<view class="other row">
<block wx:for="{{other}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="other-item col" bindtap="onActivityDetail">
<view>
<image src="{{item.cover}}"></image>
</view>
<view class="other-item-info col">
<text>{{item.title}}</text>
<text>{{item.date}}</text>
<view class="other row" >
<block wx:for="{{other}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="other-item col" data-id="{{item.id}}" bindtap="onActivityDetail">
<view>
<image src="{{item.cover}}"></image>
</view>
<view class="other-item-info col">
<text>{{item.title}}</text>
<text>{{item.date}}</text>
</view>
</view>
</view>
</block>
</view>
</block>
</view>
</block>
</view>
\ No newline at end of file
......@@ -33,6 +33,8 @@ Page({
strategy: [],
strategyList: [],
loading: false,
moreData: true,
//接口参数
pageNo: 1,
pageSize: 10,
......@@ -219,11 +221,24 @@ Page({
// 游客攻略列表
loadVisiterPlanList() {
this.data.loading = true
var that = this
app.wxRequest({
url: '/api/v1/strategy/getList',
data: { pageSize: that.data.pageSize, pageNo: that.data.pageNo},
success: function (res) {
if (that.data.pageSize > Number(res.data.count)) {
that.setData({
moreData: false
})
} else {
that.setData({
moreData: true
})
}
that.setData({
loading: false
})
if (res.data.list.length > 0) {
let tempArray = []
......@@ -252,20 +267,34 @@ Page({
})
} else {
that.setData({
strategyList: that.data.strategyList.concat(tempArray)
// strategyList: that.data.strategyList.concat(tempArray)
strategyList: tempArray
})
}
// 游客攻略瀑布列表
wx.lin.renderWaterFlow(that.data.strategyList, false, () => {})
} else {
}
},
fail: function(err) {
that.setData({
loading: false
})
}
})
},
onReachBottom: function() {
console.log('触底啦')
if (this.data.loading || !this.data.moreData) {
return
}
this.data.pageNo += 1
this.loadVisiterPlanList()
}
})
\ No newline at end of file
......@@ -5,6 +5,8 @@ Page({
data: {
notice: [],
loading: false,
moreData: true,
// 接口参数
pageSize: 10,
pageNo: 1,
......@@ -54,7 +56,19 @@ Page({
app.wxRequest({
url: '/api/v1/dynamic/getList',
data: { pageSize: that.data.pageSize, pageNo: that.data.pageNo},
success: function (res) {
success: function(res) {
if (that.data.pageSize > Number(res.data.count)) {
that.setData({
moreData: false
})
} else {
that.setData({
moreData: true
})
}
that.setData({
loading: false
})
var tmpArr = [];
res.data.list.forEach(item => {
var content = item.content.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block" ')
......@@ -69,10 +83,32 @@ Page({
}
tmpArr.push(tmpItem)
})
if (that.data.pageNo == 1) {
that.setData({
notice: tmpArr
})
} else {
that.setData({
notice: that.data.notice.concat(tempArray)
})
}
},
fail: function(err) {
that.setData({
notice: tmpArr
loading: false
})
}
})
},
onReachBottom: function() {
console.log('触底啦')
if (this.data.loading || !this.data.moreData) {
return
}
this.data.pageNo += 1
this.getNoticeList()
}
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment