diff --git a/app.json b/app.json index 8db7699..7c3a774 100644 --- a/app.json +++ b/app.json @@ -2,6 +2,7 @@ "pages": [ "pages/index/index", "pages/travel/travel", + "pages/resource/resource", "pages/template/template", "pages/train/train", "pages/cultureMap/cultureMap", diff --git a/pages/index/index.js b/pages/index/index.js index 2eef5e8..1618d1a 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -210,6 +210,11 @@ Page({ url: '../travel/travel', }) }, + goResource: function () { + wx.navigateTo({ + url: '../resource/resource', + }) + }, /** * 生命周期函数--监听页面加载 */ diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 7507059..8ce8aaf 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -42,6 +42,10 @@ 文化旅游 + + + 数图资源 + diff --git a/pages/resource/resource.js b/pages/resource/resource.js new file mode 100644 index 0000000..67e38eb --- /dev/null +++ b/pages/resource/resource.js @@ -0,0 +1,136 @@ +// pages/resource/resource.js +const app = getApp() +Page({ + + /** + * 页面的初始数据 + */ + data: { + newsUrl: app.newsUrl, + directoriesParentId: '98c74389-2088-499b-a046-8611bdc57ea4', + typeList: [], + currentPage: 1, + rows: 10, + currentNewsDictionariesId: '' + }, + getType: function () { + var self = this + app.restAjax.get(app.restAjax.path('{newsUrl}/app/newsdirectories/listnewsdirectoriesrelease', [app.newsUrl]), { + directoriesParentId: self.data.directoriesParentId + }, null, function (code, data) { + self.setData({ + typeList: data + }) + self.getList(1) + }) + }, + changeType: function (e) { + this.setData({ + currentNewsDictionariesId: e.currentTarget.dataset.newsDirectoriesId + }) + this.getList(1) + }, + getList: function (page) { + var self = this + app.dialog.loading('正在加载'); + var info = { + newsDirectoriesParentId: self.data.directoriesParentId, + newsDirectoriesId: self.data.currentNewsDictionariesId ? self.data.currentNewsDictionariesId : '', + page: page, + rows: self.data.rows + } + app.restAjax.get(app.restAjax.path('{newsUrl}/app/newscontent/listpagenewscontentrelease', [app.newsUrl]), info, null, function (code, data) { + var newsArray; + for (var i = 0; i < data.rows.length; i++) { + data.rows[i].newsContentCoverList = data.rows[i].newsContentCoverList[0].contentCoverId + } + if(page <= 1) { + newsArray = data.rows; + } else { + newsArray = self.data.news.newsList; + newsArray = newsArray.concat(data.rows); + } + self.setData({ + currentPage: page, + trainList: newsArray + }) + if(data.rows.length == 0) { + app.dialog.msg('暂无数据'); + return; + } + }, function(code, data) { + app.dialog.msg(data.msg); + }, function() { + wx.stopPullDownRefresh(); + wx.hideLoading(); + }) + }, + goNewsDetail: function (e) { + var url = e.currentTarget.dataset.templateRecordUrl + var link = e.currentTarget.dataset.contentLink + if (link) { + wx.navigateTo({ + url: '../template/template?link=' + link, + }) + } else { + wx.navigateTo({ + url: '../template/template?url=' + url, + }) + } + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.getType() + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + this.getList(1); + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + this.getList(this.data.currentPage + 1); + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/resource/resource.json b/pages/resource/resource.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/resource/resource.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/resource/resource.wxml b/pages/resource/resource.wxml new file mode 100644 index 0000000..6761b90 --- /dev/null +++ b/pages/resource/resource.wxml @@ -0,0 +1,25 @@ + + + + + 全部 + + + + + {{item.directoriesName}} + + + + + + + {{item.newsContentTitle}} + + + + + {{item.newsContentPublishTime}} + + + \ No newline at end of file diff --git a/pages/resource/resource.wxss b/pages/resource/resource.wxss new file mode 100644 index 0000000..7912152 --- /dev/null +++ b/pages/resource/resource.wxss @@ -0,0 +1,141 @@ +.top-tab{ + position: fixed; + top: 0; + left: 0; + right: 0; + background: #fff; + overflow-x: auto; +} +.type{ + display: flex; +} +.tab-box{ + display: inline-flex; + justify-content: center; + align-items: center; + width: 30%; + position: relative; + height: 90rpx; + font-size: 30rpx; + color: #242424; + flex-shrink: 0; + padding: 0 10rpx; +} +.tab-box.active{ + color: #9F1512; +} +.tab-box image{ + position: absolute; + width: 15rpx; + height: 40rpx; + top: 50%; + margin-top: -20rpx; + display: none; +} +.tab-box.active image{ + display: block; +} +.tab-box image.selected-l{ + left: 10rpx; +} +.tab-box image.selected-r{ + right: 10rpx; +} +.area{ + overflow-x: auto; + white-space: nowrap; + position: fixed; + top: 90rpx; + left: 0; + right: 0; + border-bottom: 1px solid #DDD; + background: #fff; +} +.area-box{ + display: inline-flex; + width: 30%; + height: 90rpx; + /* line-height: 90rpx; + text-align: center; */ + align-items: center; + justify-content: center; + padding: 0 20px; + box-sizing: border-box; + position: relative; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-size: 30rpx; +} +.area-box.active{ + color: #9F1512; +} +.area-box image{ + position: absolute; + width: 15rpx; + height: 40rpx; + top: 50%; + margin-top: -20rpx; + display: none; +} +.area-box.active image{ + display: block; +} +.area-box image.selected-l{ + left: 20rpx; +} +.area-box image.selected-r{ + right: 20rpx; +} +.news{ + padding: 0 30rpx; + border-bottom: 5px solid #FBFBFB; + margin-top: 90rpx; +} +.news-box{ + padding: 30rpx 0; + border-bottom: 1px solid #EBEBEB; + display: flex; + flex-direction: column; +} +.news-box:first-child{ + padding-top: 0; +} +.news-title{ + color: #242424; + font-size: 30rpx; + font-weight: bold; +} +.news-info{ + color: #949494; + margin-top: 15rpx; + font-size: 24rpx; +} +.news-info text{ + margin-right: 20rpx; +} +.news-big-pic, .news-small-pic{ + margin-top: 10rpx; +} +.news-big-pic image{ + width: 100%; +} +.news-small-pic image{ + width: 100%; + height: 400rpx; +} +.transverse-news{ + flex-direction: row; + justify-content: space-between; +} +.news-row-img{ + width: 30%; + height: 150rpx; +} +.news-row-img image{ + width: 100%; + height: 100%; +} +.news-row-info{ + width: 68%; +} \ No newline at end of file diff --git a/pages/template/template.js b/pages/template/template.js index 6cbbcf7..9fd6d5f 100644 --- a/pages/template/template.js +++ b/pages/template/template.js @@ -13,10 +13,35 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - console.log(options) - this.setData({ - url: options.url - }) + if (options.link) { + var type = options.link.split('.') + if (type[type.length-1] == 'pdf') { + wx.downloadFile({ + url: options.link, + success: function (res) { + const filePath = res.tempFilePath + console.log(res) + wx.openDocument({ + filePath: filePath, + fileType: 'pdf', + success: function (res) { + console.log(res) + } + }) + }, + fail: function (error) { + console.log(error) + } + }) + } + // this.setData({ + // url: options.link + // }) + } else { + this.setData({ + url: 'https://www.wgink.ink/' + options.url + }) + } }, /** diff --git a/pages/template/template.wxml b/pages/template/template.wxml index ab5952c..4839609 100644 --- a/pages/template/template.wxml +++ b/pages/template/template.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file