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.
172 lines
3.9 KiB
172 lines
3.9 KiB
// pages/user/common/myIdea/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: [
|
|
// {
|
|
// ideaId: '1',
|
|
// userIcon: "",
|
|
// userName: "用户名",
|
|
// time: "刚刚",
|
|
// isGoodIdea: 1,
|
|
// praiseNum: "30",
|
|
// detail: {
|
|
// title: "习近平主持政治局第十七次集体... 拷贝",
|
|
// userIcon: "",
|
|
// userName: "用户名",
|
|
// time: "刚刚",
|
|
// commentNum: "33",
|
|
// text: "【内容以实际活动为准】市北区位于青岛市主城区地理位置的中心,西部濒临胶州湾,东部与崂山区为邻,北部与李沧区接壤,南部与市南区毗"
|
|
// }
|
|
// },
|
|
// {
|
|
// ideaId: "2",
|
|
// userIcon: "",
|
|
// userName: "用户名",
|
|
// time: "1分钟前",
|
|
// isGoodIdea: 0,
|
|
// praiseNum: "30",
|
|
// detail: {
|
|
// title: "习近平主持政治局第十七次集体... 拷贝",
|
|
// userIcon: "",
|
|
// userName: "用户名",
|
|
// time: "刚刚",
|
|
// commentNum: "33",
|
|
// text: "市北区位于青岛市主城区地理位置的中心,西部濒临胶州湾,东部与崂山区为邻,北部与李沧区接壤,南部与市南区毗连,东西最大距离11. 拷贝 2"
|
|
// }
|
|
// }
|
|
],
|
|
currentPage: 1
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.fetchMyIdeaList()
|
|
},
|
|
|
|
fetchMyIdeaList(){
|
|
let page = this.data.currentPage
|
|
userModel.goldenList(page,res=>{
|
|
console.log(res)
|
|
|
|
const datas = res.result.list
|
|
let tempDatas = []
|
|
datas.forEach(item => {
|
|
tempDatas.push({
|
|
ideaId: item.id,
|
|
userIcon: item.image,
|
|
groupId: item.groupId,
|
|
userName: item.username,
|
|
time: item.createTime,
|
|
comment: item.comment,
|
|
praiseNum: item.supportNum,
|
|
detail: {
|
|
userIcon: item.groupAvator,
|
|
userName: item.author,
|
|
commentNum: item.commentNum,
|
|
title: item.title,
|
|
text: item.content
|
|
}
|
|
})
|
|
})
|
|
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({
|
|
currentPage:1
|
|
})
|
|
this.fetchMyIdeaList()
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
let page = this.data.currentPage+1
|
|
this.setData({
|
|
currentPage:page
|
|
})
|
|
this.fetchMyIdeaList()
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
},
|
|
|
|
clickListItem(e) {
|
|
const itemData = e.detail.itemData;
|
|
console.log(itemData);
|
|
},
|
|
tapGoodIdeaPraise(e){
|
|
console.log('啦啦啦')
|
|
console.log(e)
|
|
}
|
|
})
|