Commit eed85aaf by TengFengLian

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

parent 4c88717c
const app = getApp()
Page({ Page({
data: { data: {
// banner 列表数据 // banner 列表数据
...@@ -6,6 +8,9 @@ Page({ ...@@ -6,6 +8,9 @@ Page({
bannerHeight: 300, bannerHeight: 300,
info: {}, info: {},
// 接口参数
id: '',
}, },
onLoad: function (options) { onLoad: function (options) {
...@@ -62,4 +67,10 @@ Page({ ...@@ -62,4 +67,10 @@ Page({
bannerIndex: funcEvent.detail.current bannerIndex: funcEvent.detail.current
}) })
}, },
//主题活动详情
getActivityDetail(){
var that = this
}
}) })
\ No newline at end of file
import iMiment from '../../npm/miment.js' import iMiment from '../../npm/miment.js'
const app = getApp()
Page({ Page({
data: { data: {
...@@ -7,8 +8,10 @@ Page({ ...@@ -7,8 +8,10 @@ Page({
}, },
onLoad: function () { onLoad: function () {
this.queryActivity() // this.queryActivity()
this.queryOther() // this.queryOther()
this.getActivityList(1)
this.getActivityList(0)
}, },
queryActivity: function () { queryActivity: function () {
...@@ -68,8 +71,46 @@ Page({ ...@@ -68,8 +71,46 @@ Page({
}, },
onActivityDetail: function (funcItem) { onActivityDetail: function (funcItem) {
console.log('onActivityDetail',funcItem)
wx.navigateTo({ 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,13 +21,14 @@ ...@@ -21,13 +21,14 @@
</block> </block>
</view> </view>
<block wx:if="{{other.length > 0}}">
<view class="title row"> <view class="title row">
<image src="./image/title-2.png"></image> <image src="./image/title-2.png"></image>
</view> </view>
<view class="other row"> <view class="other row" >
<block wx:for="{{other}}" wx:for-index="index" wx:for-item="item" wx:key="index"> <block wx:for="{{other}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<view class="other-item col" bindtap="onActivityDetail"> <view class="other-item col" data-id="{{item.id}}" bindtap="onActivityDetail">
<view> <view>
<image src="{{item.cover}}"></image> <image src="{{item.cover}}"></image>
</view> </view>
...@@ -38,4 +39,6 @@ ...@@ -38,4 +39,6 @@
</view> </view>
</block> </block>
</view> </view>
</block>
</view> </view>
\ No newline at end of file
...@@ -33,6 +33,8 @@ Page({ ...@@ -33,6 +33,8 @@ Page({
strategy: [], strategy: [],
strategyList: [], strategyList: [],
loading: false,
moreData: true,
//接口参数 //接口参数
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
...@@ -219,11 +221,24 @@ Page({ ...@@ -219,11 +221,24 @@ Page({
// 游客攻略列表 // 游客攻略列表
loadVisiterPlanList() { loadVisiterPlanList() {
this.data.loading = true
var that = this var that = this
app.wxRequest({ app.wxRequest({
url: '/api/v1/strategy/getList', url: '/api/v1/strategy/getList',
data: { pageSize: that.data.pageSize, pageNo: that.data.pageNo}, 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
})
if (res.data.list.length > 0) { if (res.data.list.length > 0) {
let tempArray = [] let tempArray = []
...@@ -252,7 +267,8 @@ Page({ ...@@ -252,7 +267,8 @@ Page({
}) })
} else { } else {
that.setData({ that.setData({
strategyList: that.data.strategyList.concat(tempArray) // strategyList: that.data.strategyList.concat(tempArray)
strategyList: tempArray
}) })
} }
...@@ -262,10 +278,23 @@ Page({ ...@@ -262,10 +278,23 @@ Page({
} else { } 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({ ...@@ -5,6 +5,8 @@ Page({
data: { data: {
notice: [], notice: [],
loading: false,
moreData: true,
// 接口参数 // 接口参数
pageSize: 10, pageSize: 10,
pageNo: 1, pageNo: 1,
...@@ -54,7 +56,19 @@ Page({ ...@@ -54,7 +56,19 @@ Page({
app.wxRequest({ app.wxRequest({
url: '/api/v1/dynamic/getList', url: '/api/v1/dynamic/getList',
data: { pageSize: that.data.pageSize, pageNo: that.data.pageNo}, 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 = []; var tmpArr = [];
res.data.list.forEach(item => { res.data.list.forEach(item => {
var content = item.content.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block" ') var content = item.content.replace(/<img/gi, '<img style="max-width:100%;height:auto;display:block" ')
...@@ -69,10 +83,32 @@ Page({ ...@@ -69,10 +83,32 @@ Page({
} }
tmpArr.push(tmpItem) tmpArr.push(tmpItem)
}) })
if (that.data.pageNo == 1) {
that.setData({ that.setData({
notice: tmpArr notice: tmpArr
}) })
} else {
that.setData({
notice: that.data.notice.concat(tempArray)
})
} }
},
fail: function(err) {
that.setData({
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