diff --git a/pages/resource/resource.js b/pages/resource/resource.js index 67e38eb..9cdef80 100644 --- a/pages/resource/resource.js +++ b/pages/resource/resource.js @@ -11,7 +11,8 @@ Page({ typeList: [], currentPage: 1, rows: 10, - currentNewsDictionariesId: '' + currentNewsDictionariesId: '', + trainList: [] }, getType: function () { var self = this @@ -47,7 +48,7 @@ Page({ if(page <= 1) { newsArray = data.rows; } else { - newsArray = self.data.news.newsList; + newsArray = self.data.trainList; newsArray = newsArray.concat(data.rows); } self.setData({ @@ -70,14 +71,20 @@ Page({ var link = e.currentTarget.dataset.contentLink if (link) { wx.navigateTo({ - url: '../template/template?link=' + link, + url: '../template/template?link=' + encodeURIComponent(link), }) } else { wx.navigateTo({ - url: '../template/template?url=' + url, + url: '../template/template?url=' + encodeURIComponent(url), }) } }, + doClearCurrentNewsDictionariesId: function () { + this.setData({ + currentNewsDictionariesId: '' + }) + this.getList(1) + }, /** * 生命周期函数--监听页面加载 */ diff --git a/pages/template/template.js b/pages/template/template.js index 9fd6d5f..c5b50f2 100644 --- a/pages/template/template.js +++ b/pages/template/template.js @@ -13,19 +13,22 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { + console.log(options) if (options.link) { + options.link = decodeURIComponent(options.link) + app.dialog.loading('正在加载'); 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) + wx.stopPullDownRefresh(); + wx.hideLoading(); } }) }, @@ -33,11 +36,13 @@ Page({ console.log(error) } }) + } else { + this.setData({ + url: options.link + }) } - // this.setData({ - // url: options.link - // }) } else { + options.url = decodeURIComponent(options.url) this.setData({ url: 'https://www.wgink.ink/' + options.url }) diff --git a/pages/train/train.js b/pages/train/train.js index 064bd29..bfe316c 100644 --- a/pages/train/train.js +++ b/pages/train/train.js @@ -78,11 +78,11 @@ Page({ var link = e.currentTarget.dataset.contentLink if (link) { wx.navigateTo({ - url: '../template/template?url=' + link, + url: '../template/template?link=' + encodeURIComponent(link), }) } else { wx.navigateTo({ - url: '../template/template?url=' + url, + url: '../template/template?url=' + encodeURIComponent(url), }) } }, diff --git a/pages/travel/travel.js b/pages/travel/travel.js index 3185236..d7a147b 100644 --- a/pages/travel/travel.js +++ b/pages/travel/travel.js @@ -52,11 +52,11 @@ Page({ var link = e.currentTarget.dataset.contentLink if (link) { wx.navigateTo({ - url: '../template/template?url=' + link, + url: '../template/template?link=' + encodeURIComponent(link), }) } else { wx.navigateTo({ - url: '../template/template?url=' + url, + url: '../template/template?url=' + encodeURIComponent(url), }) } },