fanp 6 years ago
parent
commit
1e7a9d2fd8
  1. 63
      pages/user/myFavorite/index.js
  2. 3
      pages/user/myFavorite/index.json
  3. 30
      pages/user/myFavorite/index.wxml

63
pages/user/myFavorite/index.js

@ -11,7 +11,7 @@ Page({
*/ */
data: { data: {
list: [], list: [],
currentPage:1 currentPage: 1
}, },
/** /**
@ -22,12 +22,12 @@ Page({
}, },
fetchMyFavoriteList(){ fetchMyFavoriteList () {
console.log('啦啦啦') console.log('啦啦啦')
let page = this.data.currentPage let page = this.data.currentPage
userModel.getMyFavoriteList(page,res=>{ userModel.getMyFavoriteList(page, res => {
console.log(res) console.log(res)
const datas = res.result.list const datas = res.result.list
let tempDatas = [] let tempDatas = []
datas.forEach(item => { datas.forEach(item => {
@ -38,8 +38,8 @@ Page({
userIcon: item.groupAvator, userIcon: item.groupAvator,
userName: item.author, userName: item.author,
time: item.createTime, time: item.createTime,
commentNum: item.commentNum, commentNum: item.commentNum || '',
type:item.type type: item.type
}) })
}) })
if (page == 1) { if (page == 1) {
@ -67,34 +67,6 @@ Page({
wx.stopPullDownRefresh() wx.stopPullDownRefresh()
}) })
}, },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
@ -109,29 +81,22 @@ Page({
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { onReachBottom: function () {
let page = this.data.currentPage+1 let page = this.data.currentPage + 1
this.setData({ this.setData({
currPage: page, currPage: page,
}) })
this.fetchMyFavoriteList() this.fetchMyFavoriteList()
}, },
clickListItem (e) {
/** console.log(e)
* 用户点击右上角分享 if (e.detail.id) {
*/ let id = e.detail.id
onShareAppMessage: function () {
},
clickListItem(e) {
const item = e.detail.item;
console.log(item);
let id = item.topicId
if(item.type === '1'){
wx.navigateTo({ wx.navigateTo({
url: `/pages/article/index?id=${id}`, url: `/pages/article/index?id=${id}`,
}) })
}else { } else {
const item = e.detail.item;
let id = item.topicId
wx.navigateTo({ wx.navigateTo({
url: `/pages/topics/interactive/topicArticle/index?topicId=${id}`, url: `/pages/topics/interactive/topicArticle/index?topicId=${id}`,
}) })

3
pages/user/myFavorite/index.json

@ -2,6 +2,7 @@
"enablePullDownRefresh": true, "enablePullDownRefresh": true,
"navigationBarTitleText": "我的收藏", "navigationBarTitleText": "我的收藏",
"usingComponents": { "usingComponents": {
"cell": "../myTopics/myParticipant/cell/index" "cell": "../myTopics/myParticipant/cell/index",
"artice-cell": "/components/cell/index"
} }
} }

30
pages/user/myFavorite/index.wxml

@ -1,15 +1,25 @@
<!--pages/user/common/myFavorite/index.wxml--> <!--pages/user/common/myFavorite/index.wxml-->
<view class="container"> <view class="container">
<block wx:for="{{list}}" wx:key="{{index}}"> <block wx:for="{{list}}" wx:key="{{index}}">
<cell <block wx:if="{{item.type === '1'}}">
topicId="{{item.topicId}}" <artice-cell
title="{{item.title}}" cId="{{item.topicId}}"
topicImg="{{item.topicImg}}" title="{{item.title}}"
userName="{{item.userName}}" time="{{item.time}}"
time="{{item.time}}" bind:clickListItem="clickListItem"/>
commentNum="{{item.commentNum}}" </block>
type="{{item.type}}" <block wx:else>
userIcon="{{item.userIcon}}" <cell
bind:clickListItem="clickListItem"/> topicId="{{item.topicId}}"
title="{{item.title}}"
topicImg="{{item.topicImg}}"
userName="{{item.userName}}"
time="{{item.time}}"
commentNum="{{item.commentNum}}"
type="{{item.type}}"
userIcon="{{item.userIcon}}"
bind:clickListItem="clickListItem"/>
</block>
</block> </block>
</view> </view>

Loading…
Cancel
Save