市北人才赋能平台 --小程序端
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.
 

152 lines
2.9 KiB

// pages/topics/attract/ocean/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-hyrcfnzx', 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
})
}
}
console.log(res)
wx.stopPullDownRefresh()
})
},
//海洋人才赋能中心点击列表cell获取id,进入页面
clickListItem(e) {
console.log('海洋人才赋能中心点击-->',e)
const {
id,
index,
type
} = e.detail
this.setData({
[`list[${index}].readed`]: true
})
// this.goOceanDetail(id)
//type 文章/活动标识0-文章,1-活动
if (type == 0) {
this.goOceanDetail(id)
} else {
this.gotoActivityPage(id)
}
},
goOceanDetail(id) {
wx.navigateTo({
url: `/pages/topics/attract/oceanDetail/index?id=${id}`,
})
},
//活动 1
gotoActivityPage(id) {
wx.navigateTo({
url: `/pages/topics/activity/activityDetail/index?activityId=${id}`,
})
},
})