diff --git a/models/topic.js b/models/topic.js
index 0514490..a0155fc 100644
--- a/models/topic.js
+++ b/models/topic.js
@@ -40,17 +40,6 @@ class TopicModel extends HTTP {
this.request(params)
}
- getResourceTypeList(success){
- let params = {
- url: TopicBaseUrl.resource_type_url,
- method: Method.GET,
- data: {
- },
- success: success
- }
- this.request(params)
- }
-
// 新建议题
topicAddGroup(title, content,images,success){
let params = {
@@ -255,6 +244,17 @@ class TopicModel extends HTTP {
this.request(params)
}
+ getResourceTypeList(success){
+ let params = {
+ url: TopicBaseUrl.resource_type_url,
+ method: Method.GET,
+ data: {
+ },
+ success: success
+ }
+ this.request(params)
+ }
+
}
diff --git a/pages/resource/index.js b/pages/resource/index.js
index 72c795a..b6fdb7b 100644
--- a/pages/resource/index.js
+++ b/pages/resource/index.js
@@ -7,10 +7,11 @@ Page({
* 页面的初始数据
*/
data: {
- titlePic:"/images/temp_1.png",
page:1,
list:[],
- show:true
+ show:false,
+ typeCode:'',
+ next:true
},
/**
@@ -18,6 +19,9 @@ Page({
*/
onLoad: function (options) {
var typeCode = options.typeCode;
+ this.setData({
+ typeCode:typeCode
+ })
topicModel.getResourceList(typeCode,1,res=>{
this.setData({
list:res.result.records
@@ -65,6 +69,31 @@ Page({
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
+ var th = this;
+ var next = th.data.next;
+ var typeCode = th.data.typeCode;
+ if(!next){
+ return;
+ }
+ var page = th.data.page;
+ var nextPage = page + 1;
+ var list = th.data.list;
+
+ topicModel.getResourceList(typeCode,nextPage,res=>{
+
+ if(res.result.records.length > 0){
+ list = list.concat(res.result.records);
+ th.setData({
+ list: list,
+ page: nextPage
+ })
+ }else{
+ th.setData({
+ next: false
+ })
+ }
+
+ })
},
@@ -73,14 +102,5 @@ Page({
*/
onShareAppMessage: function () {
- },
- detail:function(e){
- if (!e.currentTarget.dataset.id){
- return;
- }
-
- wx.navigateTo({
- url: 'detail/index?id=' + e.currentTarget.dataset.id
- })
}
})
\ No newline at end of file
diff --git a/pages/resource/index.json b/pages/resource/index.json
index 26abe29..f197c7c 100644
--- a/pages/resource/index.json
+++ b/pages/resource/index.json
@@ -1,5 +1,7 @@
{
"usingComponents": {
- "van-popup": "/components/vant/popup/index"
- }
+ "van-popup": "/components/vant/popup/index",
+ "resource":"./list/index"
+ },
+ "onReachBottomDistance":50
}
\ No newline at end of file
diff --git a/pages/resource/index.wxml b/pages/resource/index.wxml
index 732b501..04e5b29 100644
--- a/pages/resource/index.wxml
+++ b/pages/resource/index.wxml
@@ -1,21 +1,6 @@
-
-
-
-
-
-
-
-
- {{item.title}}
- {{item.typeName}}
-
-
-
-
-
+
-
-->
-
-
-
-
-
-
-
-
-
-
- {{item.title}}
-
-
-
-
- 置顶
-
- {{item.createTime}}
-
-
-
-
-
-
+
diff --git a/pages/topics/center/index.wxss b/pages/topics/center/index.wxss
index 3f774d0..2b2527b 100644
--- a/pages/topics/center/index.wxss
+++ b/pages/topics/center/index.wxss
@@ -1,131 +1,13 @@
/* pages/topics/interactive/index.wxss */
@import '../../../style/font.wxss';
-.publish{
- position: fixed;
- width: 40px;
- height: 40px;
- right: 20px;
- bottom: 40px;
-}
image{
width: 100%;
height: 100%;
}
-.container{
- font-family: PingFangSC-Regular;
- font-weight: 300;
-}
-
-.cell {
- /* border-bottom: 1px solid #E7E7E7;
- display: flex;
- flex-direction: row;
- padding: 10px 20px;
- align-items: center; */
- /* min-height: 80px; */
- display: flex;
- align-items: center;
- justify-content: center;
- width:100%;
- border-bottom: 1px solid #E7E7E7;
-}
-
-.content {
- display: flex;
- width:90%;
- height:80px;
- margin:15px 0px 5px 0px;
-}
-.left{
- width:22%;
- /* background-color: #EEEEEE; */
- /* border:1px solid black; */
- display: flex;
- /* align-items: center; */
- /* justify-content: center; */
-}
-.articleImg{
- width: 55px;
- height: 55px;
- border-radius: 50%;
-}
-
-.right{
- flex:1;
- display: flex;
- flex-direction: column;
- /* justify-content: space-between; */
- height: 100%;
- /* align-items: center; */
- justify-content: center;
- /* border:1px solid black; */
-}
-
-.right-top{
- height:60%;
- width:100%;
- /* border:1px solid black; */
- display: flex;
- /* 底部对齐 */
- align-items: center;
-
-}
-.right-title{
- /* font-size: 17px;
- color: #000;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- word-break: break-all;
- text-overflow: ellipsis;
- height:80%;
- width:100%; */
-
- font-size: 17px;
- color: #000;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 2;
- overflow: hidden;
- word-break: break-all;
- text-overflow: ellipsis;
- /* height:85%; */
- /* border: 1px solid black; */
-}
-
-.right-bottom{
- display: flex;
- /* flex-direction: row; */
- align-items: center;
- justify-content: flex-end;
- height: 40%;
- margin:10px 0px 5px 0px;
- /* border:1px solid black; */
- /* align-items: flex-end; */
-
-}
-.bottom-top{
- font-size: 14px;
- color:red;
- border-radius: 5px;
- border:1px solid red;
- margin:0px 10px;
- padding:0px 5px;
-}
-.cell_info_meta {
- display: flex;
- flex-direction: row;
- font-size: 12px;
- color: #D4D4D4;
-
-}
-
.nav{
height:250px;
}
-
.circular{
width: 55px;
height: 55px;
@@ -134,4 +16,5 @@ image{
display: flex;
align-items: center;
justify-content: center;
-}
\ No newline at end of file
+}
+
diff --git a/pages/topics/index.js b/pages/topics/index.js
index 29a5cec..15ed4c7 100644
--- a/pages/topics/index.js
+++ b/pages/topics/index.js
@@ -15,7 +15,7 @@ Page({
* 页面的初始数据
*/
data: {
- headerTitles: ['找资源','报需求','交朋友' ],
+ headerTitles: ['找资源','报需求','交朋友','租房子','找贷款' ],
segmentIndex: 0,
currPage: 1,
//留言互动的列表
@@ -23,7 +23,11 @@ Page({
goodIdeaList: [],
//赋能中心的列表
centerList: [],
- typeList:[]
+ typeList:[],
+ page:1,
+ next:true,
+ tab:"1",
+ active:"1"
},
@@ -41,43 +45,14 @@ Page({
console.log('已经绑定微信')
if (store.hasPhone()) {
console.log('已经绑定手机号码')
- // 页面出现在前台时执行
- // 更新TopicList 和centerList
- this.fetchTopicList()
- this.fetchCenterList()
- let segmentIndex = this.data.segmentIndex
- if (segmentIndex === 0 || segmentIndex === 1) {
- wx.pageScrollTo({
- scrollTop: 0,
- })
+ return this.fetchCenterList();
- this.setData({
- currPage: 1,
- })
- switch (this.data.segmentIndex) {
- case 0:
- return this.fetchTopicList()
- case 1:
- // return this.fetchGoodIdeaList()
- //GoodIdea修改为center
- return this.fetchCenterList()
- }
- }
} else {
console.log('未绑定手机号码')
wx.showModal({
title: '温馨提示',
content: '是否前往验证手机号码?',
success(res) {
- // if (res.confirm) {
- // wx.redirectTo({
- // url: '/pages/register/index',
- // })
- // } else if (res.cancel) {
- // wx.switchTab({
- // url: '/pages/home/index',
- // })
- // }
if(app.globalData.navigate.mobile){
var params = {
phone:app.globalData.navigate.mobile,
@@ -149,15 +124,35 @@ Page({
}
},
+ changeTabs:function(e){
+ var tab = e.detail.name;
+ this.setData({
+ page:1,
+ next:true,
+ tab:tab,
+ topicList:[],
+ centerList:[]
+ })
+ switch (tab) {
+ case "1":
+ return this.fetchCenterList();
+ case "3":
+ return this.fetchTopicList();
+ default:
+ return;
+ }
+ },
//留言互动
//fetch留言互动的资源
fetchTopicList () {
- let page = this.data.currPage
+ var th = this;
+ var page = th.data.page;
+ var list = th.data.topicList;
topicModel.getTopicList(page, res => {
console.log('议题列表')
console.log(res)
- if (res.result.list.length == 0) {
+ if (res.result.list.length == 0 && page == 1) {
wx.showToast({
title: '暂无数据',
icon: 'none'
@@ -179,206 +174,79 @@ Page({
isTouchMove:false,
})
})
- if (page == 1) {
- this.setData({
- topicList: tempDatas
+
+ if(tempDatas.length > 0){
+ list = list.concat(tempDatas);
+ th.setData({
+ topicList: list,
+ })
+ }else{
+ th.setData({
+ next: false,
+ page: page-1
})
- } else {
- if (tempDatas.length > 0) {
- const list = [...this.data.topicList, ...tempDatas]
- this.setData({
- topicList: list
- })
- } else {
- const page = this.data.currPage - 1
- this.setData({
- currPage: page
- })
- wx.showToast({
- title: '已加载全部',
- icon: 'none'
- })
- }
}
- console.log(this.data.topicList)
- wx.stopPullDownRefresh()
+
})
},
//赋能中心
fetchCenterList(){
- let page = this.data.currPage;
-
- topicModel.getResourceTypeList(res=>{
- this.setData({
- typeList:res.result
- })
- })
-
- topicModel.getCenterList(page,res => {
- if (res.list.length == 0) {
- wx.showToast({
- title: '暂无数据',
- icon: 'none'
- })
- return
- }
+ // let page = this.data.currPage;
+ var th = this;
+ var page = th.data.page;
+ var list = th.data.centerList;
- if(page == 1){
+ if(th.data.typeList.length == 0){
+ topicModel.getResourceTypeList(res=>{
this.setData({
- centerList: res.list
+ typeList:res.result
})
- }else{
- if (res.list.length > 0) {
- const list = [...this.data.centerList, ...res.list]
- this.setData({
- centerList: list
- })
- } else {
- const page = this.data.currPage - 1
- this.setData({
- currPage: page
- })
- wx.showToast({
- title: '已加载全部',
- icon: 'none'
- })
- }
- }
-
- })
- },
- //金点子
- //金点子资源刷新
- onRefreshList () {
- this.fetchGoodIdeaList()
- },
- //fetch金点子的资源
- fetchGoodIdeaList () {
- let page = this.data.currPage
- topicModel.goldenList(page, res => {
- console.log('金点子列表')
- console.log(res)
+ })
+ }
- const datas = res.result.list
- let tempDatas = []
- datas.forEach(item => {
- tempDatas.push({
- // 评论数据
- commentId: item.id,
- commentIcon: item.commentAvator,
- commentName: item.username,
- commentTime: item.createTime,
- comment: item.comment,
- praiseNum: item.supportNum,
- isSupport: item.isSupport,
- // 议题数据
- topicTtitle: item.title,
- topicGroupAvator: item.groupAvator,
- topicAuthor: item.author,
- topicGroupCreateTime: item.groupCreateTime,
- topicCommentNum: item.commentNum,
- topicGroupId: item.groupId,
- topicDetail: item.content
+ topicModel.getResourceList('',page,res => {
+ if(res.result.records.length > 0){
+ list = list.concat(res.result.records);
+ th.setData({
+ centerList: list,
})
- })
- if (page == 1) {
- this.setData({
- goodIdeaList: tempDatas
+ }else{
+ th.setData({
+ next: false,
+ page: page-1
})
- } else {
- if (tempDatas.length > 0) {
- const list = [...this.data.goodIdeaList, ...tempDatas]
- this.setData({
- goodIdeaList: list
- })
- } else {
- const page = this.data.currPage - 1
- this.setData({
- currPage: page
- })
- wx.showToast({
- title: '已加载全部',
- icon: 'none'
- })
- }
}
- console.log(this.data.goodIdeaList)
- wx.stopPullDownRefresh()
})
},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- // let segmentIndex = this.data.segmentIndex
- // if (segmentIndex === 2){
- // wx.stopPullDownRefresh()
- // }
- // if (segmentIndex === 0 || segmentIndex === 1) {
- // wx.pageScrollTo({
- // scrollTop: 0,
- // })
-
- // this.setData({
- // currPage: 1,
- // })
- // switch (this.data.segmentIndex) {
- // case 0:
- // return this.fetchTopicList()
- // case 1:
- // // return this.fetchGoodIdeaList()
- // return this.fetchCenterList()
- // }
- // }
- },
-
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
- let segmentIndex = this.data.segmentIndex
- if(segmentIndex === 2){
- return
- }
-
- if (segmentIndex === 0 || segmentIndex === 1) {
- const page = this.data.currPage + 1
- this.setData({
- currPage: page
- })
- switch (this.data.segmentIndex) {
- case 0:
- return this.fetchTopicList()
- case 1:
- // return this.fetchGoodIdeaList()
- return this.fetchCenterList()
- }
+ var next = this.data.next;
+ var tab = this.data.tab;
+ var page = this.data.page;
+ if(!next){
+ return;
}
-
- },
- // 定义点击标题的事件处理函数,将选中标题的id赋值给selectedTitle
- tapSegment: function (e) {
- console.log(e)
this.setData({
- currPage: 1
+ page: page + 1
})
- const item = e.detail;
- this.setData({
- segmentIndex: item.index
- });
- switch (item.index) {
- case 0:
- return this.fetchTopicList()
- case 1:
- // return this.fetchGoodIdeaList()
- console.log("点击页面fetchCenterList");
- return this.fetchCenterList()
+ console.log(tab)
+ switch (tab) {
+ case "1":
+ return this.fetchCenterList();
+ case "3":
+ return this.fetchTopicList();
+ default:
+ return;
}
+
},
+
deleteTopic(e) {
// console.log(e.detail.id)
let that = this
diff --git a/pages/topics/index.json b/pages/topics/index.json
index 77c6749..3cbcc97 100644
--- a/pages/topics/index.json
+++ b/pages/topics/index.json
@@ -7,6 +7,9 @@
"interactive": "./interactive/index",
"goodIdea": "./goodIdea/index",
"talents": "./talents/index",
- "center": "./center/index"
- }
+ "center": "./center/index",
+ "van-tab": "/components/vant/tab/index",
+ "van-tabs": "/components/vant/tabs/index"
+ },
+ "onReachBottomDistance":50
}
\ No newline at end of file
diff --git a/pages/topics/index.wxml b/pages/topics/index.wxml
index ff429ab..4d97300 100644
--- a/pages/topics/index.wxml
+++ b/pages/topics/index.wxml
@@ -1,9 +1,19 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -11,10 +21,9 @@
-
-
+
-
+