市北人才赋能平台 --小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

151 lines
2.8 KiB

// pages/topics/attract/space/index.js
import {
TopicModel
} from '../../../../models/topic'
let topicModel = new TopicModel()
Page({
/**
* 页面的初始数据
*/
data: {
loading: true,
currPage: 1,
pageSize: 10,
list: [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.fetchList()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.setData({
currPage: 1,
list: []
})
this.fetchList()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
const page = this.data.currPage + 1
this.setData({
currPage: page
})
this.fetchList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
fetchList() {
let page = this.data.currPage
let pageSize = this.data.pageSize
topicModel.getAttractList('sc-ztkj', page, pageSize, res => {
this.setData({
loading: false
})
const datas = res.list
let tempDatas = []
datas.forEach(item => {
tempDatas.push({
id: item.id,
title: item.title,
image: item.titlePic,
showTop: item.isTop == 1 ? true : false,
time: item.createTime,
readed: item.isRead == 0 ? false : true,
type:item.type
})
})
if (page == 1) {
this.setData({
list: tempDatas
})
} else {
if (tempDatas.length > 0) {
const list = [...this.data.list, ...tempDatas]
this.setData({
list: list
})
} else {
const page = this.data.currPage - 1
this.setData({
currPage: page
})
}
}
wx.stopPullDownRefresh()
})
},
//折腾空间中心详情
clickListItem(e) {
//console.log(e.detail)
const {
id,
index,
type
} = e.detail
this.setData({
[`list[${index}].readed`]: true
})
// this.goSpacenDetail(id)
//type 文章/活动标识0-文章,1-活动
if (type == 0) {
this.goSpacenDetail(id)
} else {
this.gotoActivityPage(id)
}
},
goSpacenDetail(id) {
wx.navigateTo({
url: `/pages/topics/attract/spaceDetail/index?id=${id}`,
})
},
//活动 1
gotoActivityPage(id) {
wx.navigateTo({
url: `/pages/topics/activity/activityDetail/index?activityId=${id}`,
})
},
})