From 32bd6d9f4647f609533a182d35d70304b55a8fa5 Mon Sep 17 00:00:00 2001 From: xuxu Date: Thu, 10 Sep 2020 17:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B5=84=E6=BA=90=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/resource/detail/index.js | 123 +++++++++++++++++++++++++++++++ pages/resource/detail/index.json | 3 + pages/resource/detail/index.wxml | 20 +++++ pages/resource/detail/index.wxss | 61 +++++++++++++++ pages/resource/index.js | 86 +++++++++++++++++++++ pages/resource/index.json | 5 ++ pages/resource/index.wxml | 31 ++++++++ pages/resource/index.wxss | 76 +++++++++++++++++++ 8 files changed, 405 insertions(+) create mode 100644 pages/resource/detail/index.js create mode 100644 pages/resource/detail/index.json create mode 100644 pages/resource/detail/index.wxml create mode 100644 pages/resource/detail/index.wxss create mode 100644 pages/resource/index.js create mode 100644 pages/resource/index.json create mode 100644 pages/resource/index.wxml create mode 100644 pages/resource/index.wxss diff --git a/pages/resource/detail/index.js b/pages/resource/detail/index.js new file mode 100644 index 0000000..00b3193 --- /dev/null +++ b/pages/resource/detail/index.js @@ -0,0 +1,123 @@ +// pages/resource/detail/index.js +import { TopicModel } from '../../../models/topic.js' +let topicModel = new TopicModel() +Page({ + + /** + * 页面的初始数据 + */ + data: { + titlePic:"/images/temp_1.png", + unStar: '/images/common/star.png', + star: '/images/common/star_light.png', + detail:{}, + isCollect:false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var id = options.id; + topicModel.getResourceDetail(id,res=>{ + + if(res.result.isCollection == 1){ + this.setData({ + isCollect:true, + }) + }else{ + this.setData({ + isCollect:false, + }) + } + this.setData({ + detail:res.result, + }) + + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + }, + previewImage:function(e){ + // var current = e.target.dataset.src; + var th = this; + if(th.data.detail.titlePic){ + var urls = [th.data.detail.titlePic]; + wx.previewImage({ + urls:urls// 需要预览的图片http链接列表 + }) + }else{ + return; + } + + }, + onClickCollect:function(){ + this.setData({ + isCollect: !this.data.isCollect + }) + this.fetchTopicCollect(); + + + }, + + fetchTopicCollect(){ + let id = this.data.detail.id + topicModel.resourceCollect(id,res =>{ + //console.log('收藏') + if(res.code === 200){ + wx.showToast({ + title: '收藏成功', + icon: 'none' + }) + } + }) + }, + +}) \ No newline at end of file diff --git a/pages/resource/detail/index.json b/pages/resource/detail/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/resource/detail/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/resource/detail/index.wxml b/pages/resource/detail/index.wxml new file mode 100644 index 0000000..ee388b5 --- /dev/null +++ b/pages/resource/detail/index.wxml @@ -0,0 +1,20 @@ + + + + + + + + + + {{detail.title}} + {{detail.typeName}} + + + + + + + + + diff --git a/pages/resource/detail/index.wxss b/pages/resource/detail/index.wxss new file mode 100644 index 0000000..77956e9 --- /dev/null +++ b/pages/resource/detail/index.wxss @@ -0,0 +1,61 @@ +/* pages/resource/detail/index.wxss */ +/* @import '../../style/font.wxss'; */ +page{ + width: 100%; + display: flex; + align-items: center; + flex-direction: column; +} + +.title{ + display: flex; + align-items: center; + justify-content: space-between; + width: 90%; + min-height: 90px; + border-bottom: 2px solid whitesmoke; + margin-top:5px; +} + +.left{ + display: flex; + align-items: center; + flex: 1; +} + +.right{ + width: 15px; + text-align:right; +} + +.articleImg{ + width: 55px; + height: 55px; + display: flex; + align-items: center; + /* border-radius: 50%; */ +} + +.content{ + margin-left: 15px; + margin-right: 20px; + flex: 1; +} + +.tit{ + width: 100%; + font-weight:1000; +} + +.r_type{ + font-size: 13px; +} + +.artice_collect { + width: 20px; + height: 20px; +} + +.text{ + width: 90%; +} diff --git a/pages/resource/index.js b/pages/resource/index.js new file mode 100644 index 0000000..72c795a --- /dev/null +++ b/pages/resource/index.js @@ -0,0 +1,86 @@ +// pages/resource/index.js +import { TopicModel } from '../../models/topic.js' +let topicModel = new TopicModel() +Page({ + + /** + * 页面的初始数据 + */ + data: { + titlePic:"/images/temp_1.png", + page:1, + list:[], + show:true + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + var typeCode = options.typeCode; + topicModel.getResourceList(typeCode,1,res=>{ + this.setData({ + list:res.result.records + }) + + }) + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + 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 new file mode 100644 index 0000000..26abe29 --- /dev/null +++ b/pages/resource/index.json @@ -0,0 +1,5 @@ +{ + "usingComponents": { + "van-popup": "/components/vant/popup/index" + } +} \ No newline at end of file diff --git a/pages/resource/index.wxml b/pages/resource/index.wxml new file mode 100644 index 0000000..732b501 --- /dev/null +++ b/pages/resource/index.wxml @@ -0,0 +1,31 @@ + + + + + + + + + + {{item.title}} + {{item.typeName}} + + + + + + + + + + + 内容内容内容内容内容内容内容 + + + + \ No newline at end of file diff --git a/pages/resource/index.wxss b/pages/resource/index.wxss new file mode 100644 index 0000000..052c115 --- /dev/null +++ b/pages/resource/index.wxss @@ -0,0 +1,76 @@ +/* pages/resource/index.wxss */ +@import '../../style/font.wxss'; +page{ + width: 100%; + display: flex; + background-color: whitesmoke; +} +.container{ + display: flex; + width: 100%; + flex-direction: column; + align-items: center; + background-color: white; + margin-top:10px; +} + +.column{ + display: flex; + align-items: center; + justify-content: space-between; + width: 90%; + height: 90px; + border-bottom: 2px solid whitesmoke; +} + +.left{ + display: flex; + align-items: center; + flex: 1; +} + +.right{ + width: 15px; + text-align:right; +} + +.articleImg{ + width: 55px; + height: 55px; + display: flex; + align-items: center; + /* border-radius: 50%; */ +} + +.content{ + margin-left: 15px; + margin-right: 20px; + flex: 1; +} + +.title{ + width: 100%; + display: -webkit-box; + -webkit-line-clamp: 1; + overflow: hidden; + text-overflow: ellipsis; + -webkit-box-orient: vertical; + word-break: break-all; + font-weight:1000; +} + +.r_type{ + font-size: 13px; +} +.tips{ + width: 100%; + height: 100%; + display: flex; + flex-direction: column; + align-items: center; +} +.tips-con{ + width: 90%; + height: 90; +} +