From c3e6b774f9c244b74cf0d9b85341909dd7f1a596 Mon Sep 17 00:00:00 2001 From: slj Date: Mon, 22 Nov 2021 16:28:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=8B=E8=83=BD=E4=B8=AD=E5=BF=83=E6=88=91?= =?UTF-8?q?=E7=9A=84=E6=B4=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.json | 3 +- models/topic.js | 6 +- pages/resource/detail/index.js | 117 +++++++++--- pages/resource/detail/index.json | 4 +- pages/resource/detail/index.wxml | 44 +++-- pages/resource/detail/index.wxss | 15 ++ pages/resource/index.wxml | 19 +- pages/resource/list/index.js | 43 +++-- pages/topics/activity/activityDetail/index.js | 45 ++--- .../topics/activity/activityDetail/index.wxml | 69 +++---- pages/topics/activity/activitySign/index.js | 169 ++++++++++++++++++ pages/topics/activity/activitySign/index.json | 7 + pages/topics/activity/activitySign/index.wxml | 27 +++ pages/topics/activity/activitySign/index.wxss | 33 ++++ pages/topics/demand/index.js | 1 - pages/user/index.js | 1 - project.private.config.json | 6 + 17 files changed, 460 insertions(+), 149 deletions(-) create mode 100644 pages/topics/activity/activitySign/index.js create mode 100644 pages/topics/activity/activitySign/index.json create mode 100644 pages/topics/activity/activitySign/index.wxml create mode 100644 pages/topics/activity/activitySign/index.wxss diff --git a/app.json b/app.json index a1ce906..3faea7a 100644 --- a/app.json +++ b/app.json @@ -45,7 +45,8 @@ "pages/topics/attract/oceanDetail/index", "pages/topics/attract/spaceDetail/index", "pages/topics/reportDemand/index", - "pages/topics/activity/activityDetail/index" + "pages/topics/activity/activityDetail/index", + "pages/topics/activity/activitySign/index" ], "window": { "backgroundTextStyle": "light", diff --git a/models/topic.js b/models/topic.js index 26de278..960be69 100644 --- a/models/topic.js +++ b/models/topic.js @@ -340,9 +340,9 @@ class TopicModel extends HTTP { url: TopicBaseUrl.activity_list_url, method: Method.POST, data: { - source: source, - page: page, - pageSize: 10, + source:source, + pageNo:page, + pageSize:10, }, success: success } diff --git a/pages/resource/detail/index.js b/pages/resource/detail/index.js index f2fcc53..6d1ae95 100644 --- a/pages/resource/detail/index.js +++ b/pages/resource/detail/index.js @@ -1,6 +1,10 @@ // pages/resource/detail/index.js -import { TopicModel } from '../../../models/topic.js' -import { config } from '../../../config.js' +import { + TopicModel +} from '../../../models/topic.js' +import { + config +} from '../../../config.js' var WxParse = require('../../../components/wxParse/wxParse.js'); let topicModel = new TopicModel() Page({ @@ -9,38 +13,48 @@ Page({ * 页面的初始数据 */ data: { - titlePic:config.api_url + "/image/head.jpg", + titlePic: config.api_url + "/image/head.jpg", unStar: '/images/common/star.png', star: '/images/common/star_light.png', - detail:{}, - isCollect:false, - show:false + detail: {}, + isCollect: false, + show: false, + source:'', + currPage: 1, + activityList:[] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { + console.log(options) var id = options.id; - topicModel.getResourceDetail(id,res=>{ - wx.setNavigationBarTitle({ title:res.result.typeName}) + topicModel.getResourceDetail(id, res => { + this.setData({ + source:res.result.title + }) + this.fetchActivityList() + wx.setNavigationBarTitle({ + title: res.result.typeName + }) - if(res.result.typeCode != 'zcfn'){ + if (res.result.typeCode != 'zcfn') { this.setData({ - show:true + show: true }) } - if(res.result.isCollection == 1){ + if (res.result.isCollection == 1) { this.setData({ - isCollect:true, + isCollect: true, }) - }else{ + } else { this.setData({ - isCollect:false, + isCollect: false, }) } this.setData({ - detail:res.result, + detail: res.result, }) WxParse.wxParse('article', 'html', this.data.detail.content, this, 5); @@ -96,32 +110,32 @@ Page({ onShareAppMessage: function () { }, - previewImage:function(e){ + previewImage: function (e) { // var current = e.target.dataset.src; var th = this; - if(th.data.detail.titlePic){ - var urls = [th.data.detail.titlePic]; + if (th.data.detail.titlePic) { + var urls = [th.data.detail.titlePic]; wx.previewImage({ - urls:urls// 需要预览的图片http链接列表 + urls: urls // 需要预览的图片http链接列表 }) - }else{ + } else { return; } - + }, - onClickCollect:function(){ + onClickCollect: function () { this.setData({ isCollect: !this.data.isCollect }) let id = this.data.detail.id - topicModel.resourceCollect(id,res =>{ + topicModel.resourceCollect(id, res => { //console.log('收藏') - if(res.code === 200){ + if (res.code === 200) { wx.showToast({ title: '收藏成功', icon: 'none' }) - }else{ + } else { wx.showToast({ title: '取消收藏', icon: 'none' @@ -131,9 +145,60 @@ Page({ }, - onTap:function(){ + onTap: function () { wx.navigateTo({ url: '/pages/resource/demand/index?type=resource&id=' + this.data.detail.id }) }, + + //活动 + fetchActivityList() { + var th = this; + var page = th.data.currPage; + let source=th.data.source + topicModel.getActivityList(source, page, res => { + console.log('机构活动列表---', res) + const datas = res.result.records + let tempDatas = [] + datas.forEach((item, index) => { + tempDatas.push({ + activityId: item.id, + title: item.title, + activityImg: item.titlePic, + time: item.createTime, + commentNum:item.commentNum, + dataIndex: index + ((page - 1) * 10), + isTouchMove: false, + }) + }) + if (page == 1) { + this.setData({ + activityList: tempDatas + }) + } else { + if (tempDatas.length > 0) { + const list = [...this.data.activityList, ...tempDatas] + this.setData({ + activityList: list + }) + } else { + const page = this.data.currPage - 1 + this.setData({ + currPage: page + }) + wx.showToast({ + title: '已加载全部', + icon: 'none' + }) + } + } + wx.stopPullDownRefresh() + }) + }, + clickListItem(e) { + const activityId = e.detail.activityId; + wx.navigateTo({ + url: `/pages/topics/activity/activityDetail/index?activityId=${activityId}`, + }) + }, }) \ No newline at end of file diff --git a/pages/resource/detail/index.json b/pages/resource/detail/index.json index 8835af0..97ebcea 100644 --- a/pages/resource/detail/index.json +++ b/pages/resource/detail/index.json @@ -1,3 +1,5 @@ { - "usingComponents": {} + "usingComponents": { + "cell": "../../topics/activity/cell/index" + } } \ No newline at end of file diff --git a/pages/resource/detail/index.wxml b/pages/resource/detail/index.wxml index d3b0d10..e5ef7d9 100644 --- a/pages/resource/detail/index.wxml +++ b/pages/resource/detail/index.wxml @@ -1,25 +1,37 @@ - - - - - - - - {{detail.title}} - {{detail.typeName}} - + + + + + - - + + {{detail.title}} + {{detail.typeName}} - - -