|
|
@ -1,8 +1,10 @@ |
|
|
|
// pages/topics/index.js
|
|
|
|
import dayjs from '../../utils/dayjs/index.js' |
|
|
|
import relativeTime from '../../utils/dayjs/relativeTime.js' |
|
|
|
dayjs.extend(relativeTime); |
|
|
|
import { TopicModel } from '../../models/topic.js' |
|
|
|
import { store } from '../../utils/store.js' |
|
|
|
|
|
|
|
dayjs.extend(relativeTime) |
|
|
|
let topicModel = new TopicModel() |
|
|
|
|
|
|
|
Page({ |
|
|
@ -15,18 +17,26 @@ Page({ |
|
|
|
segmentIndex: 0, |
|
|
|
currPage: 1, |
|
|
|
topicList: [], |
|
|
|
goodIdeaList:[] |
|
|
|
goodIdeaList: [] |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面加载 |
|
|
|
*/ |
|
|
|
onLoad: function () { |
|
|
|
if (store.hasPhone()) { |
|
|
|
console.log('已经绑定手机号码') |
|
|
|
this.fetchTopicList(); |
|
|
|
} else { |
|
|
|
console.log('未绑定手机号码') |
|
|
|
wx.redirectTo({ |
|
|
|
url: '/pages/register/index', |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
fetchTopicList(){ |
|
|
|
fetchTopicList() { |
|
|
|
let page = this.data.currPage |
|
|
|
topicModel.getTopicList(page,res=>{ |
|
|
|
topicModel.getTopicList(page, res => { |
|
|
|
console.log('议题列表') |
|
|
|
console.log(res) |
|
|
|
|
|
|
@ -38,7 +48,7 @@ Page({ |
|
|
|
title: item.title, |
|
|
|
userName: item.author, |
|
|
|
commentNum: item.commentNum, |
|
|
|
topicImg:item.image, |
|
|
|
topicImg: item.image, |
|
|
|
time: item.createTime, |
|
|
|
}) |
|
|
|
}) |
|
|
@ -67,10 +77,10 @@ Page({ |
|
|
|
wx.stopPullDownRefresh() |
|
|
|
}) |
|
|
|
}, |
|
|
|
onRefreshList(){ |
|
|
|
onRefreshList() { |
|
|
|
this.fetchGoodIdeaList() |
|
|
|
}, |
|
|
|
fetchGoodIdeaList(){ |
|
|
|
fetchGoodIdeaList() { |
|
|
|
let page = this.data.currPage |
|
|
|
topicModel.goldenList(page, res => { |
|
|
|
console.log('金点子列表') |
|
|
@ -81,19 +91,19 @@ Page({ |
|
|
|
datas.forEach(item => { |
|
|
|
tempDatas.push({ |
|
|
|
id: item.id, |
|
|
|
userIcon:item.image, |
|
|
|
userIcon: item.image, |
|
|
|
groupId: item.groupId, |
|
|
|
userName: item.username, |
|
|
|
time: item.createTime, |
|
|
|
comment: item.comment, |
|
|
|
praiseNum: item.supportNum, |
|
|
|
isPraise: false, |
|
|
|
detail:{ |
|
|
|
detail: { |
|
|
|
userIcon: item.groupAvator, |
|
|
|
userName: item.author, |
|
|
|
commentNum: item.commentNum, |
|
|
|
title: item.title, |
|
|
|
text:item.content, |
|
|
|
text: item.content, |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
@ -192,13 +202,13 @@ Page({ |
|
|
|
tapSegment: function (e) { |
|
|
|
console.log(e) |
|
|
|
this.setData({ |
|
|
|
currPage:1 |
|
|
|
currPage: 1 |
|
|
|
}) |
|
|
|
const item = e.detail; |
|
|
|
this.setData({ |
|
|
|
segmentIndex: item.index |
|
|
|
}); |
|
|
|
switch(item.index){ |
|
|
|
switch (item.index) { |
|
|
|
case 0: |
|
|
|
return this.fetchTopicList() |
|
|
|
case 1: |
|
|
|