上传文件至 '新闻小程序/pages/news-detail'
This commit is contained in:
parent
195db89cf2
commit
22be3e05ab
|
@ -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"
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
<view class="detail_start">
|
||||
<view class="news_title">{{detail.news_title}}</view>
|
||||
<view class="publisher-info">
|
||||
<view class="news_author">{{detail.news_author}}</view>
|
||||
<view wx:if="{{detail.news_date != 'None'}}">
|
||||
<view class="news_date">发布于{{detail.news_date}}</view>
|
||||
</view>
|
||||
<!-- <view class="news_author">{{detail.news_author}}</view>
|
||||
<view class="news_date">发布于{{detail.news_date}}</view> -->
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 新闻正文 -->
|
||||
|
@ -16,7 +19,7 @@
|
|||
</view>
|
||||
|
||||
|
||||
<!-- 收藏按钮 4.27-->
|
||||
<!-- 收藏按钮 -->
|
||||
<button class="collect" bindtap="collect">
|
||||
点击收藏<image class="collect_img" src="{{collect_img}}"></image>
|
||||
</button>
|
||||
|
|
Loading…
Reference in New Issue