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

150 lines
3.1 KiB

// pages/user/common/myMessage/index.js
import dayjs from '../../../utils/dayjs/index.js'
import relativeTime from '../../../utils/dayjs/relativeTime.js'
dayjs.extend(relativeTime);
import { UserModel } from '../../../models/user.js'
let userModel = new UserModel()
Page({
/**
* 页面的初始数据
*/
data: {
list:[
// {
// msgName:"活动提醒",
// msgType:0,
// title:"您的报名活动还有两天开始,立即查看",
// time:"11:58"
// },
// {
// msgName: "消息提醒",
// msgType: 1,
// title: "您的评论被点赞,立即查看",
// time: "11:58"
// },
// {
// msgName: "系统提醒",
// msgType: 2,
// title: "您的报名活动还有两天开始,查看详情",
// time: "11:58"
// }
],
currentPage: 1
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.fetchMyMessageList()
},
fetchMyMessageList(){
let page = this.data.currentPage
userModel.getMyMessageList(page,res=>{
console.log('我的消息')
console.log(res)
const datas = res.result.list
let tempDatas = []
datas.forEach(item => {
tempDatas.push({
contentId: item.contentId,
messageId:item.id,
title: item.content,
time: item.createTime,
messageStatus: item.messageStatus,
msgType: Number(item.messageType),
msgName: item.messageType === '1' ? '评论消息' : '活动消息'
})
})
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.showToast({
title: '已加载全部',
icon: 'none'
})
}
}
console.log(this.data.list)
wx.stopPullDownRefresh()
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.setData({
currPage: 1,
})
this.fetchMyMessageList()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
const page = this.data.currPage + 1
this.setData({
currPage: page
})
this.fetchMyMessageList()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
clickListItem(e) {
const itemData = e.detail.itemData;
console.log(itemData);
}
})