2023-04-17 16:14:18 +08:00

145 lines
2.8 KiB
JavaScript

// pages/messageCenter/messageCenter.js
const miucms = require('../../utils/miucms.js')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
list: [],
page: 1,
issubscribe: 1,
qrcode: "",
count: 0,
popupState: false,
officialLoadState: false, // 关注服务号组件的加载状态
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getList()
},
getList() {
if (this.data.page == 0) {
return
}
wx.showLoading({
title: '加载中...',
})
miucms.request(app.globalData.baseURL + "/tenement/message/lists", {
page: this.data.page
}).then(res => {
wx.hideLoading()
if (res.code == 200) {
let data = res.data
data.data && data.data.forEach(element => {
element.message = element.message.trim()
if (element.message.length >= 40) {
element['littleMessage'] = element.message.slice(0, 42) + '...'
}
});
for (let i = 0; i < data.data.length; i++) {
data.data[i]['reportshowState'] = 0
}
this.setData({
list: this.data.list.concat(data.data),
page: data.count > data.page * data.limit ? this.data.page + 1 : 0,
issubscribe: data.issubscribe,
qrcode: data.qrcode,
count: data.count,
})
} else {
wx.showModal({
title: '提示',
content: res.message
})
}
}).catch(err => {
wx.hideLoading()
})
},
cutUnfoldState(e) {
let index = e.currentTarget.dataset.index
this.data.list[index].reportshowState = 1
this.data.list[index].littleMessage = null
this.setData({
list: this.data.list
})
},
// 点击关注
attention() {
console.log("点击关注");
this.setData({
popupState: !this.data.popupState
})
},
// 点击标题跳转
jumpDetails(e) {
let uniqid = e.currentTarget.dataset.uniqid
wx.navigateTo({
url: `/pages/show/show?uniqid=${uniqid}`,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.setData({
list: [],
page: 1,
issubscribe: 1,
qrcode: '',
count: 0
})
wx.stopPullDownRefresh();
this.getList()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.getList()
},
})