mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-mobile.git
synced 2025-12-08 02:16:46 +08:00
185 lines
4.6 KiB
Vue
185 lines
4.6 KiB
Vue
<template>
|
|
<!--文章详细页面-->
|
|
<view><watermark></watermark>
|
|
<page-title :showBack="true">文章详细信息</page-title>
|
|
<u-toast ref="articleToast"></u-toast>
|
|
<view class="adetail content">
|
|
<!--文章内容-->
|
|
<view class="adetail-title">{{ detail.title }}</view>
|
|
<view class="adetail-info">
|
|
<view style="display: flex;line-height: 40upx;">
|
|
<author-info :name="detail.sysCreateBy" :avatar="detail.avatar"></author-info>
|
|
</view>
|
|
<view style="padding: 10upx 0upx 10upx 40upx;"> {{ detail.sysCreateTime }}</view>
|
|
</view>
|
|
<view class="adetail-body">
|
|
<view class="html-cont">
|
|
<u-parse :content="detail.content"></u-parse>
|
|
</view>
|
|
<view v-if="userInfo.aid==detail.sysCreateAid" style="display: flex;justify-content: flex-end;color: #b1b1b1;padding-top: 10px;">
|
|
<u-icon name="edit-pen-fill" label="编辑"></u-icon>
|
|
<u-icon style="margin-left: 20px;" name="trash" label="删除"></u-icon>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<comments ref="comComments" v-if="id!=''" :objType="2" :objId="id"></comments>
|
|
<interact-fixed v-if="detail.id" :type="2" :praises="false" @comment-success="commentSuccess" :data="detail"></interact-fixed>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import apiArticle from '@/api/modules/article.js'
|
|
import apiUser from '@/api/system/user.js'
|
|
import { mapGetters } from 'vuex';
|
|
export default {
|
|
data() {
|
|
return {
|
|
id:'',
|
|
detail:{avatar:''},
|
|
loadStatus:'more',
|
|
page:1,//当前页数
|
|
pagesize:10, //总页数
|
|
fileUrl:this.$config.fileUrl
|
|
}
|
|
},
|
|
|
|
onLoad (options) {
|
|
//console.log(options.id);
|
|
this.id = options.id;
|
|
this.getDetail();
|
|
},
|
|
onReachBottom(){
|
|
this.getDetail()
|
|
},
|
|
computed: {
|
|
...mapGetters(['userInfo'])
|
|
},
|
|
methods: {
|
|
getDetail(){
|
|
uni.showLoading({title:'加载中...'});
|
|
let $this=this;
|
|
apiArticle.detail(this.id,true).then(res=>{
|
|
if(res.status == 200){
|
|
apiUser.getByIds([res.result.sysCreateAid]).then(rs=>{
|
|
setTimeout(function(){ uni.hideLoading() },1000);
|
|
if(rs.status==200){
|
|
if(rs.result!='' && rs.result.length>0){
|
|
let author=rs.result[0];
|
|
res.result.avatar=$this.fileUrl+author.avatar;
|
|
res.result.orgInfo=author.orgInfo;
|
|
res.result.ucode=author.code;
|
|
}
|
|
$this.detail = res.result;
|
|
}else{
|
|
$this.detail = res.result;
|
|
}
|
|
})
|
|
}else{
|
|
setTimeout(function(){ uni.hideLoading() },1);
|
|
this.$refs.articleToast.show({message:'加载内容失败',type:'error'});
|
|
console.log(res.message+res.error);
|
|
}
|
|
|
|
}).catch(err=>{
|
|
setTimeout(function(){ uni.hideLoading() },1000);
|
|
})
|
|
},
|
|
commentSuccess(rs){
|
|
//console.log(rs,'success');
|
|
this.$refs.comComments.loadData(false);
|
|
},
|
|
toEdit(){
|
|
uni.navigateTo({
|
|
url:'/pages/plus/editArticle?id='+this.id
|
|
})
|
|
},
|
|
del(){
|
|
let $this=this;
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '您确定要删除此文章吗?',
|
|
success: function (res) {
|
|
if (res.confirm) {
|
|
//$this.del();
|
|
apiArticle.del($this.id).then(res=>{
|
|
if(res.status=200){
|
|
this.$refs.articleToast.show({message:'删除成功',type:'success'});
|
|
//
|
|
let pages =getCurrentPages();
|
|
//console.log(pages);
|
|
const prevPage=pages[pages.length-2];
|
|
if(!prevPage){
|
|
uni.switchTab({
|
|
url:'/pages/index/index'
|
|
})
|
|
}else{
|
|
uni.navigateBack();
|
|
}
|
|
}else{
|
|
this.$refs.articleToast.show({message:'删除失败,请稍后再试',type:'error'});
|
|
}
|
|
})
|
|
} else if (res.cancel) {
|
|
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.adetail{
|
|
.adetail-title{
|
|
font-weight: 600;
|
|
font-size: 1.5em;
|
|
padding: 10upx;
|
|
word-break:break-all;
|
|
width: 100%;
|
|
}
|
|
.adetail-info{
|
|
padding-top: 10px;
|
|
line-height: 50upx;
|
|
color: #7e7e7e;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
}
|
|
.adetail-body{
|
|
padding-top: 15px;
|
|
line-height: 55upx;
|
|
|
|
background-color: #FFFFFF;
|
|
>div{
|
|
text-indent:24px
|
|
}
|
|
}
|
|
|
|
}
|
|
.comments{
|
|
margin-top: 10px;
|
|
background-color: #FFFFFF;
|
|
.comments-top{
|
|
display: flex;
|
|
justify-content: space-between;
|
|
padding-bottom:30upx;
|
|
border-bottom: 1px solid #f4f4f4;
|
|
font-weight: 500;
|
|
font-size: 1.1em;
|
|
}
|
|
.comments-items{
|
|
padding-top: 20upx;
|
|
.comments-item{
|
|
padding-bottom: 15px;
|
|
}
|
|
.comments-avatar{
|
|
height: 60upx;
|
|
width: 60upx;
|
|
border-radius: 10%;
|
|
border: 1px solid #f3f3f3;
|
|
}
|
|
}
|
|
}
|
|
</style>
|