talk_appAmin/pages/work/workinfo.vue

575 lines
12 KiB
Vue

<template>
<view class="">
<!-- 审核的信息 -->
<view class="shenghe_item" >
<image v-if="postInfo.status==0" src="../../static/images/icon/pass.png" mode="" class="pass_unpass pass"></image>
<image v-if="postInfo.status==3 | postInfo.status==4" src="../../static/images/icon/unpass.png" mode="" class="pass_unpass unpass">
</image>
<view class="user_header">
<view class="">
<view class="user_img">
<image :src="getAvatar(postInfo.avatar)" mode=""></image>
</view>
<view class="user_msg">
<h4>{{ postInfo.nickName }}</h4>
<p>{{timeAgo(postInfo.createTime)}}{{postInfo.address ? '·' + postInfo.address : ""}}</p>
</view>
</view>
<view class="text_style">
</view>
</view>
<!-- 审核的文章标题 -->
<view class="shenghe_title">
<h4>{{ postInfo.title }}</h4>
</view>
<!-- 审核的文章内 -->
<view class="shenghe_text">
<p>{{postInfo.content}}</p>
</view>
<!-- 文章图片 -->
<view class="imgs_box">
<view v-for="(item,index) in toimage(postValue.media)">
<image :src="item" mode="" class="imageitem" ></image>
</view>
</view>
<!-- 文章标签 -->
<view class="text_span">
<text class="tabInfo" v-for="(tabItem, index2) in strToList(postInfo.tab)"
:key="index2" :text="'#' + tabItem">{{'#' + dictTab(tabItem)}}</text>
</view>
<!-- 审核未通过的提示框 -->
<view class="tishi_box" v-if="postInfo.status==3 | postInfo.status==4">
<h2>审核未通过</h2>
<p>未通过原因:{{ postInfo.auditAdvice }}</p>
</view>
</view>
<footer>
<view class="footer_top" v-if=" postInfo.status==1 | postInfo.status==2 | postInfo.status==3">
<view class="footer_btn footer_btn_left" @click="actiAudit">
通过
</view>
<view class="footer_btn footer_btn_right" @click="open">
不通过
</view>
</view>
<!-- <view class="footer_bottom">=</view> -->
</footer>
<!-- 弹窗显示不通过原因 -->
<view>
<up-popup :show="show" @close="close" @open="open" mode="center" :round="12">
<view class="popup">
<!-- 标题 -->
<h4>未通过原因</h4>
<!-- 输入区域0 -->
<view class="input_text" style="margin-top: 20rpx; margin-left: 20rpx;">
<textarea name="" placeholder="请输入未通过内容" v-model="value2" id="" maxlength="50" cols="30" rows="10"></textarea>
<text>{{value2?value2.length:0}}/50</text>
</view>
<view class="popup_btns">
<view class="popup_btns_left popup_btn" @click="close()">
取消
</view>
<view class="popup_btns_right popup_btn" @click="UNpass">
</view>
</view>
</view>
</up-popup>
</view>
</view>
</template>
<script setup>
import {
ref,
reactive,
computed,
onMounted,
onBeforeUnmount,
getCurrentInstance
} from 'vue';
import {
listPost,
applist,
listPostFollow,
getPost,
delPost,
addPost,
updateAuditPost,
getLoginUserinfo
} from "@/api/talk/post";
import {
useStore
} from 'vuex';
import {
onReachBottom,
onLoad,
onPageScroll
} from "@dcloudio/uni-app";
import PostView from "@/pages/common/postview/index.vue";
import {
getDicts
} from "@/api/system/dict/data";
const { proxy } = getCurrentInstance();
const postInfo = ref({})
const bottomVal = ref(0);
const commentType = ref(0);
const toAnswerObj = ref([]);
const toAnswerIndex = ref(0);
const inputValue = ref("");
const loginUser = reactive(uni.getStorageSync('loginUserPost'));
const postValue = reactive(uni.getStorageSync('postInfo'));
const postCommentList = ref([]);
const total = ref(0);
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
postId: null,
uid: null,
toUserId: null,
rootId: 0,
content: null,
hot: null,
type: null,
address: null,
});
const queryParamsSon = reactive({
pageNum: 1,
pageSize: 5,
postId: null,
uid: null,
toUserId: null,
rootId: 0,
content: null,
hot: null,
type: null,
address: null,
});
const store = useStore();
const QNDomain = store.state.user.QNDomain;
var value2 = ref('')
//判断文章状态根据 1 2 3 v-if判断
var page_type = ref(3)
// 创建响应式数据
const show = ref(false);
const dictPostTab = ref([])
onLoad(() => {
getDicts('post_tab').then(e => {
dictPostTab.value = e.data
})
getPostInfo();
})
const getPostInfo = () => {
queryParams.postId = postValue.id;
getPost(queryParams.postId).then(e=>{
console.log("e:",e);
postInfo.value = e.data
})
};
function getAvatar(avatar) {
return QNDomain + avatar;
}
function formatDate(input) {
const date = new Date(input);
if (isNaN(date)) {
throw new Error('Invalid date');
}
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}.${month}.${day}`;
}
function timeAgo(input) {
const date = new Date(input);
if (isNaN(date)) {
throw new Error('Invalid date');
}
const now = new Date();
const diff = now - date;
const minutes = Math.floor(diff / 60000); // 1 minute = 60000 ms
const hours = Math.floor(diff / 3600000); // 1 hour = 3600000 ms
const days = Math.floor(diff / 86400000); // 1 day = 86400000 ms
if (minutes < 60) {
if (minutes == 0) {
return '刚刚';
}
return `${minutes}分钟前`;
} else if (hours < 24) {
return `${hours}小时前`;
} else if (days < 3) {
return `${days}天前`;
} else {
return formatDate(date);
}
}
const toimage = (url) => {
if (typeof url === 'string') {
let info = url.split(",");
let processedInfo = info.map(item => QNDomain + item);
// console.log("processedInfo", processedInfo);
return processedInfo;
}
return null;
};
// 时间格式化
function formattedDate(timestamp){
const date = new Date(timestamp);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hour = date.getHours().toString().padStart(2, '0');
const minute = date.getMinutes().toString().padStart(2, '0');
const second = date.getSeconds().toString().padStart(2, '0');
const formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
return formattedDate
}
// 定义方法 弹出打开
function open() {
// 打开逻辑,比如设置 show 为 true
show.value = true;
value2.value = postInfo.value.auditAdvice;
}
//弹出关闭
function close() {
// 关闭逻辑,设置 show 为 false
show.value = false;
// console.log('close');
}
const actiAudit = () => {
proxy.$modal.loading("数据提交中~")
let form = {
id: postInfo.value.id,
status: 0
}
updateAuditPost(form).then(e => {
proxy.$modal.closeLoading()
if (e.code == 200) {
proxy.$modal.msgSuccess('审核通过')
getPost(postInfo.value.id).then(response => {
postInfo.value = response.data;
});
}
console.log("通过:", e);
})
}
// 未通过弹窗的确定点击事件
function UNpass() {
proxy.$modal.loading("数据提交中~")
let form = {
id: postInfo.value.id,
status: 4,
auditAdvice: value2.value
}
updateAuditPost(form).then(e => {
proxy.$modal.closeLoading()
if (e.code == 200) {
proxy.$modal.msgSuccess('审核成功')
getPost(postInfo.value.id).then(response => {
postInfo.value = response.data;
});
}
})
close()
}
function strToList(strList) {
let list = strList.split(",");
console.log("strList:",strList, " list:",list);
return list;
}
const dictTab = (tab) => {
const dict = dictPostTab.value.find((dict) => dict.dictValue === tab);
return dict ? dict.dictLabel : '未知状态';
}
</script>
<style lang="scss" scoped>
page {
background-color: #fff;
}
.shenghe_item {
width: 750rpx;
background: #ffffff;
padding: 30rpx 32rpx 216rpx 32rpx;
position: relative;
}
.pass_unpass {
position: absolute;
right: 0;
}
.pass {
width: 263rpx;
height: 200rpx;
}
.unpass {
width: 230rpx;
height: 200rpx;
}
.user_header {
width: 100%;
display: flex;
justify-content: space-between;
height: 84rpx;
.user_img {
width: 84rpx;
height: 84rpx;
margin-right: 19rpx;
image {
width: 84rpx;
height: 84rpx;
border-radius: 50%;
}
}
.user_msg {
h4 {
font-weight: 600;
width: 186rpx;
height: 31rpx;
font-size: 30rpx;
text-align: left;
color: #000000 100%;
margin-bottom: 18rpx;
}
p {
height: 30rpx;
font-size: 30rpx;
color: #999999;
}
}
.text_style {
right: 0;
font-weight: 400;
width: 84rpx;
height: 28rpx;
font-size: 28rpx;
text-align: left;
color: #6AA2FF;
}
}
.user_header>view {
display: flex;
}
.shenghe_title {
h4 {
font-weight: 600;
width: 100%;
height: 80rpx;
font-size: 30rpx;
text-align: left;
color: #000000;
margin-top: 31rpx;
}
}
.shenghe_text {
width: 100%;
word-break: break-all;
overflow: hidden;
}
.imgs_box {
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
padding-top: 34rpx;
.imageitem {
flex-grow: 30%;
width: 222rpx;
height: 222rpx;
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin-bottom: 6rpx;
margin-right: 6rpx;
}
}
.text_span {
margin-top: 28rpx;
.tabInfo {
padding: 8rpx;
background-color: #F7F8FA;
display: inline-block;
border-radius: 10rpx 10rpx 10rpx 10rpx;
font-size: 24rpx;
color: #3477FC;
font-weight: 600;
margin-bottom: 20rpx;
margin-right: 24rpx;
}
}
footer {
position: fixed;
bottom: 0px;
border-top: 4rpx solid #f6f6f6;
}
.footer_top {
width: 750rpx;
height: 94rpx;
background: #ffffff;
display: flex;
align-items: center;
justify-content: space-around;
}
.footer_bottom {
width: 750rpx;
height: 68rpx;
background: #f6f6f6;
}
.footer_btn {
width: 300rpx;
height: 60rpx;
border-radius: 30rpx 30rpx 30rpx 30rpx;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 28rpx;
font-weight: 600;
}
.footer_btn_left {
background: #6aa2ff;
}
.footer_btn_right {
background: #fa3939;
}
.popup {
width: 600rpx;
border-radius: 24rpx 24rpx 24rpx 24rpx;
background: #ffffff;
padding-bottom: 20rpx;
}
.popup {}
.popup h4 {
font-weight: 600;
text-align: center;
height: 31rpx;
font-size: 30rpx;
color: #000000 100%;
margin-top: 32rpx;
}
.input_area {
width: 552rpx;
height: 246rpx;
border-radius: 16rpx 16rpx 16rpx 16rpx;
background: #f4f5f6;
margin: 31rpx auto;
}
.popup_btns {
width: 100%;
display: flex;
align-items: center;
justify-content: space-around;
}
.popup_btn {
width: 180rpx;
height: 50rpx;
border-radius: 16rpx 16rpx 16rpx 16rpx;
display: flex;
align-items: center;
justify-content: space-around;
font-weight: 600;
font-size: 24rpx;
margin-top: 48rpx;
color: #FFFFFF;
}
.popup_btns_left {
background-color: #6AA2FF;
}
.popup_btns_right {
background-color: #FA3939;
}
.tishi_box {
width: 686rpx;
height: 134rpx;
border-radius: 24rpx 24rpx 24rpx 24rpx;
background: #ffffff;
box-shadow: 0rpx 0rpx 20rpx #ececed;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
color: #FA3939;
}
.tishi_box h2{
font-size: 36rpx;
}
.tishi_box p{
font-size: 24rpx;
margin-top: 16rpx;
}
.input_text{
width: 552rpx;
height: 246rpx;
border-radius: 16rpx 16rpx 16rpx 16rpx;
background: #f4f5f6;
margin: 0 auto;
margin-top: 32rpx;
position: relative;
textarea{
width: 552rpx;
height: 246rpx;
padding: 24rpx;
font-size: 24rpx;
}
text{
position: absolute;
right: 24rpx;
bottom: 24rpx;
font-size: 24rpx;
color: #999999;
}
}
</style>