diff --git a/新闻小程序/pages/news-detail/news-detail.js b/新闻小程序/pages/news-detail/news-detail.js index fb55b22..f474817 100644 --- a/新闻小程序/pages/news-detail/news-detail.js +++ b/新闻小程序/pages/news-detail/news-detail.js @@ -1,28 +1,34 @@ // pages/news-detail/news-detail.js let newsType = '' -let newsid = '' //4.27 -let collect = false //4.27 +let newsid = '' +let collect = false Page({ data: { }, onLoad: function (options) { - // console.log('从主页传递来的id:', options.id) - // console.log('从主页传递来的currentIndex:', options.currentIndex) - newsid = options.id //4.27 - newsType = options.currentIndex + console.log('从主页传递来的id:', options.id) + console.log('从主页传递来的currentIndex:', options.currentIndex) + newsid = options.id + // newsType = options.currentIndex let currentIndex = options.currentIndex if (currentIndex == 0) { - newsType = 'nd-news' + newsType = 'lqxy' } else if (currentIndex == 1) { - newsType = 'xg-news' + newsType = 'qcxy' } else if (currentIndex == 2) { - newsType = 'tw-news' + newsType = 'hyxy' } else if (currentIndex == 3) { - newsType = 'gj-news' + newsType = 'hkxy' } else if (currentIndex == 4) { - newsType = 'junshi-news' + newsType = 'gdxy' } else if (currentIndex == 5) { + newsType = 'zhxy' + } else if (currentIndex == 6) { + newsType = 'ysxy' + } else if (currentIndex == 7) { + newsType = 'rwxy' + } else if (currentIndex == 9) { newsType = 'lunbotu-news' } // 查询新闻详情数据,按不同板块 @@ -30,15 +36,15 @@ Page({ .get() .then(res => { console.log('新闻详情页请求成功', res) - collect = res.data.collect //4.27 + collect = res.data.collect this.setData({ detail: res.data, news_image: res.data.news_img, - collect_img: collect ? "../../images/collect-yes.png" : "../../images/collect-no.png" //4.27 + collect_img: collect ? "../../images/collect-yes.png" : "../../images/collect-no.png" }) }) }, - // 收藏按钮 4.27 + // 收藏按钮 collect() { this.setData({ collect_img: collect ? "../../images/collect-no.png" : "../../images/collect-yes.png" diff --git a/新闻小程序/pages/news-detail/news-detail.wxml b/新闻小程序/pages/news-detail/news-detail.wxml index 465b106..ad0a09e 100644 --- a/新闻小程序/pages/news-detail/news-detail.wxml +++ b/新闻小程序/pages/news-detail/news-detail.wxml @@ -2,8 +2,11 @@ {{detail.news_title}} - {{detail.news_author}} - 发布于{{detail.news_date}} + + 发布于{{detail.news_date}} + + @@ -16,7 +19,7 @@ - +