2022-07-08 08:15:29 +00:00
|
|
|
|
<template>
|
|
|
|
|
<view>
|
|
|
|
|
<status-nav :ifReturn="true" navBarTitle="新闻详情" :marginBottom="0"></status-nav>
|
|
|
|
|
<!-- 新闻视频 -->
|
2022-07-15 10:29:01 +00:00
|
|
|
|
<view class="news-video-img" v-if="articleDetail.video && isLoading">
|
2022-07-08 08:15:29 +00:00
|
|
|
|
<image :src="articleDetail.cover" mode="widthFix"></image>
|
|
|
|
|
<view class="news-video-btn" @tap.stop="playEv(articleDetail.video)">
|
2022-07-18 08:06:52 +00:00
|
|
|
|
<image src="/static/public/icon-play.png" mode="widthFix"></image>
|
2022-07-08 08:15:29 +00:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 新闻概述 -->
|
2022-07-15 10:29:01 +00:00
|
|
|
|
<view class="shop-summary news-summary" v-if="isLoading">
|
2022-07-08 08:15:29 +00:00
|
|
|
|
<view class="shop-title">{{articleDetail.title}}</view>
|
|
|
|
|
<view class="shop-txt news-txt flex">
|
|
|
|
|
<view class="left">
|
|
|
|
|
<view class="news-author">作者:{{articleDetail.author}}</view>
|
|
|
|
|
<view class="news-time">发布时间:{{time}}</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="right flex">
|
|
|
|
|
<view class="collection-btn flex" :class="articleDetail.is_collected == 1?'active':''" @tap="collectionEv(articleDetail.id)">
|
|
|
|
|
<image src="/static/public/icon-collection.png" mode="widthFix"></image>
|
2022-07-13 08:04:38 +00:00
|
|
|
|
<text>{{articleDetail.is_collected == 1?'已收藏':'收藏'}}</text>
|
2022-07-08 08:15:29 +00:00
|
|
|
|
</view>
|
|
|
|
|
<view class="share-btn flex">
|
|
|
|
|
<image src="/static/public/icon-share.png" mode="widthFix"></image>
|
|
|
|
|
<text>分享</text>
|
|
|
|
|
<button plain="true" data-name="shareBtn" open-type="share"></button>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<!-- 新闻详情 -->
|
2022-07-15 10:29:01 +00:00
|
|
|
|
<view class="shop-detail news-detail" v-if="isLoading">
|
2022-07-08 08:15:29 +00:00
|
|
|
|
<rich-text :nodes="content"></rich-text>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import statusNav from '@/components/status-navs/status-nav';
|
2022-07-13 08:04:38 +00:00
|
|
|
|
import {getCartNum,userInfoEv} from '@/jsFile/public-api.js';
|
|
|
|
|
import {mapState} from 'vuex'//引入mapState
|
2022-07-08 08:15:29 +00:00
|
|
|
|
export default {
|
|
|
|
|
components:{
|
|
|
|
|
statusNav
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
scrollHeight:uni.getSystemInfoSync().windowHeight - uni.getSystemInfoSync().statusBarHeight - 50,
|
|
|
|
|
newWidth:uni.getSystemInfoSync().windowWidth,
|
|
|
|
|
videoPlay: false, //是否全屏
|
|
|
|
|
videoUrl:'', //视频url
|
|
|
|
|
articleDetail:{}, //文章详情
|
|
|
|
|
id:'',//文章id
|
|
|
|
|
action:'collect', //收藏类型
|
|
|
|
|
time:'', //发布时间
|
|
|
|
|
content:'',//文章内容
|
2022-07-15 03:05:54 +00:00
|
|
|
|
cacheBusinessId:-1, //商户id
|
2022-07-15 10:29:01 +00:00
|
|
|
|
isLoading:false,
|
2022-07-08 08:15:29 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onLoad(op) {
|
|
|
|
|
this.id = op.id;
|
2022-07-12 10:07:08 +00:00
|
|
|
|
if(op.business_id){
|
2022-07-15 03:05:54 +00:00
|
|
|
|
this.cacheBusinessId = op.business_id;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onShow() {
|
|
|
|
|
if(this.cacheBusinessId !== -1){
|
|
|
|
|
this.$requst.post('/api/index/change-business',{business_id:this.cacheBusinessId}).then(res=>{
|
2022-07-12 10:07:08 +00:00
|
|
|
|
if(res.code == 0){
|
|
|
|
|
this.getDetail(this.id);
|
2022-07-13 08:04:38 +00:00
|
|
|
|
userInfoEv();
|
2022-07-12 10:07:08 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.getDetail(this.id);
|
2022-07-13 08:04:38 +00:00
|
|
|
|
userInfoEv();
|
2022-07-12 10:07:08 +00:00
|
|
|
|
}
|
2022-07-08 08:15:29 +00:00
|
|
|
|
},
|
|
|
|
|
// 分享到微信
|
2022-07-11 10:35:14 +00:00
|
|
|
|
onShareAppMessage(res) {
|
|
|
|
|
let path = uni.getStorageSync('page-path-options')+'&business_id='+uni.getStorageSync('business_id');
|
|
|
|
|
return {
|
|
|
|
|
path:path
|
|
|
|
|
}
|
2022-07-08 08:15:29 +00:00
|
|
|
|
},
|
|
|
|
|
// 分享到朋友圈
|
2022-07-11 10:35:14 +00:00
|
|
|
|
onShareTimeline(res){
|
|
|
|
|
let path = uni.getStorageSync('page-path-options')+'&business_id='+uni.getStorageSync('business_id');
|
|
|
|
|
return {
|
|
|
|
|
path:path
|
|
|
|
|
}
|
2022-07-08 08:15:29 +00:00
|
|
|
|
},
|
|
|
|
|
methods: {
|
2022-07-18 08:06:52 +00:00
|
|
|
|
// 播放视频
|
2022-07-08 08:15:29 +00:00
|
|
|
|
playEv(url){
|
2022-07-18 08:06:52 +00:00
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: `/pagesB/video/playVideo?src=${url}`
|
|
|
|
|
})
|
2022-07-15 10:29:01 +00:00
|
|
|
|
},
|
2022-07-08 08:15:29 +00:00
|
|
|
|
|
|
|
|
|
//收藏
|
|
|
|
|
collectionEv(){
|
|
|
|
|
console.log(this.shopDetail.collection,'是否分享')
|
|
|
|
|
if(this.shopDetail.collection !== 0){
|
|
|
|
|
this.shopDetail.collection = 1
|
|
|
|
|
}else{
|
|
|
|
|
this.shopDetail.collection = 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
// 查询文章详情
|
|
|
|
|
getDetail(id){
|
2022-07-14 02:00:23 +00:00
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '加载中'
|
|
|
|
|
});
|
2022-07-15 10:29:01 +00:00
|
|
|
|
this.isLoading =false;
|
2022-07-08 08:15:29 +00:00
|
|
|
|
this.$requst.post('/api/archives/detail',{id:id}).then(res=>{
|
|
|
|
|
if(res.code==0) {
|
2022-07-14 02:00:23 +00:00
|
|
|
|
// console.log(res,'文章详情')
|
2022-07-08 08:15:29 +00:00
|
|
|
|
this.articleDetail = res.data;
|
2022-07-14 02:00:23 +00:00
|
|
|
|
this.time = this.dateFormat(res.data.published_at.replace(/-/g,'/'))
|
2022-07-08 08:15:29 +00:00
|
|
|
|
this.content = this.$toolAll.tools.escape2Html(res.data.content)
|
|
|
|
|
}
|
|
|
|
|
uni.hideLoading();
|
2022-07-15 10:29:01 +00:00
|
|
|
|
this.isLoading =true;
|
2022-07-08 08:15:29 +00:00
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
// 时间格式转换
|
|
|
|
|
dateFormat (dateData) {
|
|
|
|
|
var date = new Date(dateData)
|
|
|
|
|
var y = date.getFullYear()
|
|
|
|
|
var m = date.getMonth() + 1
|
|
|
|
|
m = m < 10 ? '0' + m : m
|
|
|
|
|
var d = date.getDate()
|
|
|
|
|
d = d < 10 ? '0' + d : d
|
|
|
|
|
const time = y + '.' + m + '.' + d
|
|
|
|
|
return time
|
|
|
|
|
},
|
|
|
|
|
//收藏
|
|
|
|
|
collectionEv(id){
|
|
|
|
|
let params = {
|
|
|
|
|
archive_id:id,
|
|
|
|
|
action:this.action
|
|
|
|
|
}
|
|
|
|
|
if(this.articleDetail.is_collected == 1){
|
|
|
|
|
this.$requst.post('/api/archives/un-record',params).then(res=>{
|
|
|
|
|
if(res.code==0) {
|
|
|
|
|
// this.$toolAll.tools.showToast('取消收藏成功');
|
|
|
|
|
this.getDetail(this.id);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}else{
|
|
|
|
|
this.$requst.post('/api/archives/record',params).then(res=>{
|
|
|
|
|
if(res.code==0) {
|
|
|
|
|
// this.$toolAll.tools.showToast('收藏成功');
|
|
|
|
|
this.getDetail(this.id);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
|
|
</style>
|