You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_uniapp/pages/article/news_detail.vue

84 lines
2.0 KiB

9 months ago
<template>
<BaseContainer class="search-page">
<NavBar title="资讯详情" />
<view class="news-detail-page">
<view class="title">{{ articleDetails.title }}</view>
<view class="wrap">
<view class="type" v-for="item in articleDetails.label">{{ item }}</view>
<view class="time">
<text class="iconfont iconshijian11"></text>{{ articleDetails.add_time }}
</view>
<view class="browse">
<text class="iconfont iconliulanliang"></text>{{ articleDetails.visit }}
</view>
</view>
<mp-html class="detail" container-style="padding: 30rpx;background: #ffffff;"
:content="articleDetails.content"></mp-html>
</view>
</BaseContainer>
</template>
<script>
import {
getArticleDetails
} from "@/api/article";
import mpHtml from "mp-html/dist/uni-app/components/mp-html/mp-html.vue";
export default {
data() {
return {
articleDetails: {},
id: 0
};
},
components: {
mpHtml
},
filters: {
format: function (value) {
if (value) {
return value;
} else {
return 0;
}
}
},
watch: {
},
created() {
//#ifdef MP-WEIXIN
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
//#endif
},
// 分享朋友
onShareAppMessage() {
return { title: this.articleDetails.title, path: '/pages/article/news_detail?id=' + this.id +'&spread_uid='+(this.userInfo.uid??0) }
},
onLoad({ id }) {
console.log(id);
this.id = id
this.getArticleDetails();
},
methods: {
getArticleDetails () {
var that = this;
if (that.loading || that.finished) {
return;
}
that.loading = true;
uni.showLoading({
title: '加载中'
});
getArticleDetails({ id: that.id }).then(res => {
that.articleDetails = res.data;
uni.hideLoading();
}).catch(err => {
uni.hideLoading();
})
}
}
};
</script>