10 changed files with 962 additions and 1 deletions
@ -0,0 +1,38 @@ |
|||||
|
import request from '@/utils/request'; |
||||
|
import { AxiosPromise } from 'axios'; |
||||
|
import { UserDetail, UserQuery, NaviQuery, Navi ,PageParam,graphicformList} from './types'; |
||||
|
|
||||
|
|
||||
|
//获取当前用户详细信息
|
||||
|
export function getUserDetail(data: UserQuery): AxiosPromise<UserDetail> { |
||||
|
return request({ |
||||
|
url: '/javasys/user/detail', |
||||
|
method: 'post', |
||||
|
data: data, |
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
//获取左侧导航栏信息
|
||||
|
export function getZxxyNavis(data: NaviQuery): AxiosPromise<Navi[]> { |
||||
|
return request({ |
||||
|
url: '/javasys/archive/zxxy', |
||||
|
method: 'post', |
||||
|
data: data, |
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
//获取推荐分页
|
||||
|
export function getTuijian(data: PageParam): AxiosPromise<graphicformList> { |
||||
|
return request({ |
||||
|
url: '/javasys/graphicform/zxxy', |
||||
|
method: 'post', |
||||
|
data: data, |
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
@ -0,0 +1,100 @@ |
|||||
|
|
||||
|
|
||||
|
// 滚动监听器
|
||||
|
export function onScroll() { |
||||
|
|
||||
|
|
||||
|
// 获取所有锚点元素
|
||||
|
const navContents = document.querySelectorAll('.models') |
||||
|
|
||||
|
// 所有锚点元素的 offsetTop
|
||||
|
const offsetTopArr = [] |
||||
|
navContents.forEach(item => { |
||||
|
offsetTopArr.push(item.offsetTop) |
||||
|
}) |
||||
|
// 获取当前文档流的 scrollTop
|
||||
|
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop |
||||
|
// 定义当前点亮的导航下标
|
||||
|
let navIndex = 0 |
||||
|
for (let n = 0; n < offsetTopArr.length; n++) { |
||||
|
// 如果 scrollTop 大于等于第n个元素的 offsetTop 则说明 n-1 的内容已经完全不可见
|
||||
|
// 那么此时导航索引就应该是n了
|
||||
|
if (scrollTop+350 >= offsetTopArr[n]) { |
||||
|
navIndex = n |
||||
|
} |
||||
|
//若滚动条已经到底则直接激活最后一个导航
|
||||
|
if (scrollTop + document.documentElement.clientHeight === document.documentElement.scrollHeight) { |
||||
|
navIndex = offsetTopArr.length - 1; |
||||
|
} |
||||
|
} |
||||
|
//active.value = navIndex
|
||||
|
return navIndex; |
||||
|
} |
||||
|
|
||||
|
// 跳转到指定索引的元素
|
||||
|
export function scrollTo(index) { |
||||
|
|
||||
|
// 获取目标的 offsetTop
|
||||
|
// css选择器是从 1 开始计数,我们是从 0 开始,所以要 +1
|
||||
|
const targetOffsetTop = document.querySelector(`.content .models:nth-child(${index + 1})`).offsetTop |
||||
|
// 获取当前 offsetTop
|
||||
|
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop |
||||
|
// 定义一次跳 150 个像素
|
||||
|
const STEP = 50 |
||||
|
// 判断是往下滑还是往上滑
|
||||
|
if (scrollTop > targetOffsetTop) { |
||||
|
// 往上滑
|
||||
|
smoothUp() |
||||
|
} else { |
||||
|
// 往下滑
|
||||
|
smoothDown() |
||||
|
} |
||||
|
// 定义往下滑函数
|
||||
|
function smoothDown() { |
||||
|
// 如果当前 scrollTop 小于 targetOffsetTop 说明视口还没滑到指定位置
|
||||
|
if (scrollTop < targetOffsetTop) { |
||||
|
// 如果和目标相差距离大于等于 STEP 就跳 STEP
|
||||
|
// 否则直接跳到目标点,目标是为了防止跳过了。
|
||||
|
if (targetOffsetTop - scrollTop >= STEP) { |
||||
|
scrollTop += STEP |
||||
|
} else { |
||||
|
scrollTop = targetOffsetTop |
||||
|
} |
||||
|
document.body.scrollTop = scrollTop |
||||
|
document.documentElement.scrollTop = scrollTop |
||||
|
// 关于 requestAnimationFrame 可以自己查一下,在这种场景下,相比 setInterval 性价比更高
|
||||
|
requestAnimationFrame(smoothDown) |
||||
|
} |
||||
|
} |
||||
|
// 定义往上滑函数
|
||||
|
function smoothUp() { |
||||
|
if (scrollTop > targetOffsetTop) { |
||||
|
if (scrollTop - targetOffsetTop >= STEP) { |
||||
|
scrollTop -= STEP |
||||
|
} else { |
||||
|
scrollTop = targetOffsetTop |
||||
|
} |
||||
|
document.body.scrollTop = scrollTop |
||||
|
document.documentElement.scrollTop = scrollTop |
||||
|
requestAnimationFrame(smoothUp) |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
export function formatDate(timestamp) { |
||||
|
var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
|
||||
|
|
||||
|
var Y = date.getFullYear() + '-'; |
||||
|
|
||||
|
var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; |
||||
|
|
||||
|
var D = date.getDate() + ' '; |
||||
|
|
||||
|
var h = date.getHours() + ':'; |
||||
|
|
||||
|
var m = date.getMinutes() + ':'; |
||||
|
|
||||
|
var s = date.getSeconds(); |
||||
|
|
||||
|
return Y+M+D+h+m+s; |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,159 @@ |
|||||
|
//用户查询
|
||||
|
export interface UserQuery { |
||||
|
userkey: string; |
||||
|
usertoken: string; |
||||
|
} |
||||
|
|
||||
|
//用户信息
|
||||
|
export interface UserDetail { |
||||
|
//证件号码
|
||||
|
idcardno?: string[]; |
||||
|
//姓名
|
||||
|
name: string; |
||||
|
//头像url
|
||||
|
icon?: string; |
||||
|
//工号
|
||||
|
wmNumber: string; |
||||
|
//唯一识别码
|
||||
|
wmKey: number; |
||||
|
//adminorg
|
||||
|
adminorg:number; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
//导航栏查询
|
||||
|
export interface NaviQuery { |
||||
|
atParentId: string; |
||||
|
|
||||
|
} |
||||
|
//导航栏信息
|
||||
|
export interface Navi{ |
||||
|
|
||||
|
atId:number; |
||||
|
//档案分类名称
|
||||
|
atTitle:string; |
||||
|
//档案分类状态
|
||||
|
atStater:number; |
||||
|
//档案分类父级
|
||||
|
atParentId:number; |
||||
|
//写入时间
|
||||
|
atTime:number; |
||||
|
//添加人员
|
||||
|
atUid:number; |
||||
|
//排序
|
||||
|
atSort:number; |
||||
|
|
||||
|
} |
||||
|
export type cardList = PageResult<Graphicform[]> |
||||
|
//卡片
|
||||
|
export interface Graphicform { |
||||
|
gId?:number; |
||||
|
//标题
|
||||
|
gTitle?:string; |
||||
|
//关键字
|
||||
|
gKey?:string; |
||||
|
//描述
|
||||
|
gDescribe?:string; |
||||
|
//父级
|
||||
|
gParent?:number; |
||||
|
//分类
|
||||
|
gParentSun?:number; |
||||
|
//文档来源(1:原创;2:转载)
|
||||
|
gSource?:number; |
||||
|
//转载地址
|
||||
|
gSourceUrl?:string; |
||||
|
//缩略图
|
||||
|
gThumbnail?:string; |
||||
|
//排序
|
||||
|
gSort?:number; |
||||
|
//评论设置(1:允许评论;2:禁止评论)
|
||||
|
gComment?:number; |
||||
|
//访问权限(1:公开;2:分厂;3:工段;4:自定义)
|
||||
|
gVisitStrat?:number; |
||||
|
//状态(1:草稿;2:发表;3:下架;4:删除)
|
||||
|
gState?:number; |
||||
|
//写入时间
|
||||
|
gAddTime?:number; |
||||
|
//修改时间
|
||||
|
gEiteTime?:number; |
||||
|
//编辑人员
|
||||
|
gUserKey?:number; |
||||
|
//分厂
|
||||
|
gBfId?:number; |
||||
|
//工段
|
||||
|
gWsId?:number; |
||||
|
//班组
|
||||
|
gTeam?:number; |
||||
|
//是否允许下载(1:允许;2:禁止)
|
||||
|
gDownloadState?:number; |
||||
|
//阅读量
|
||||
|
gRead?:number; |
||||
|
//评论数
|
||||
|
gComSum?:number; |
||||
|
//收藏数
|
||||
|
gCollectionSum?:number; |
||||
|
//点赞数
|
||||
|
gLikes?:number; |
||||
|
//推荐(1:推荐,2:不推荐)
|
||||
|
gRecommend?:number; |
||||
|
//图文详情
|
||||
|
gContent?:string; |
||||
|
//踩数量
|
||||
|
gStepOn?:number; |
||||
|
//自定义可见范围
|
||||
|
gRange?:string; |
||||
|
//写入分厂
|
||||
|
gWriteBfid?:number; |
||||
|
//正文文档名称
|
||||
|
gTextName?:string; |
||||
|
//正文文档URL
|
||||
|
gTestUrl?:string; |
||||
|
//物理地址
|
||||
|
gPhysicsPath?:string; |
||||
|
//写入人员组织
|
||||
|
gWriteGroup?:number; |
||||
|
//外部链接
|
||||
|
gOuterLink?:string; |
||||
|
|
||||
|
} |
||||
|
export interface PageParam extends PageQuery{ |
||||
|
total:number; |
||||
|
archivesTypeAtParentId?:string; //知识库or新闻资讯
|
||||
|
gParentSun?:string; //标题分类
|
||||
|
adminorg:string; |
||||
|
key:string; |
||||
|
userkey: string, |
||||
|
usertoken: string, |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 卡片list |
||||
|
*/ |
||||
|
export type graphicformList = PageResultJava<Graphicform[]> |
||||
|
|
||||
|
/** |
||||
|
* 分页响应对象 |
||||
|
*/ |
||||
|
interface PageResultJava<T> { |
||||
|
/** |
||||
|
* 数据列表 |
||||
|
*/ |
||||
|
list: T; |
||||
|
/** |
||||
|
* 数据总数 |
||||
|
*/ |
||||
|
total: number; |
||||
|
//每页条数
|
||||
|
pageSize:number; |
||||
|
//总页数
|
||||
|
pages:number; |
||||
|
//前一页
|
||||
|
prePage:number; |
||||
|
//
|
||||
|
size:number; |
||||
|
startRow:number; |
||||
|
//当前页
|
||||
|
pageNum:number; |
||||
|
|
||||
|
} |
||||
|
After Width: | Height: | Size: 7.3 KiB |
@ -0,0 +1,25 @@ |
|||||
|
<script lang='ts' setup> |
||||
|
import { scrollTo } from '@/api/knowledge/scroll' |
||||
|
const props = defineProps({ |
||||
|
oneli: { |
||||
|
type: Object, |
||||
|
|
||||
|
}, |
||||
|
|
||||
|
index: { |
||||
|
type: Number, |
||||
|
default: 0 |
||||
|
}, |
||||
|
active: { |
||||
|
type: Number, |
||||
|
default: 0 |
||||
|
} |
||||
|
}) |
||||
|
const liIndex = props.index + 1; |
||||
|
</script> |
||||
|
<template> |
||||
|
<li :class="{ active: active === index }" @click="scrollTo(index)"> |
||||
|
{{ oneli?.atTitle }} |
||||
|
</li> |
||||
|
</template> |
||||
|
<style></style> |
||||
@ -0,0 +1,297 @@ |
|||||
|
<script lang='ts' setup> |
||||
|
import { useUserStore } from "@/store/modules/user" |
||||
|
import { ref, watch } from 'vue' |
||||
|
import { getUserDetail, getZxxyNavis, getTuijian } from '@/api/knowledge/index' |
||||
|
|
||||
|
import { UserQuery, UserDetail, NaviQuery, Navi, Graphicform, PageParam } from '@/api/knowledge/types' |
||||
|
import { formatDate } from '@/api/knowledge/scroll' |
||||
|
import { useRouter } from 'vue-router' |
||||
|
import errimg from '@/assets/404_images/imgNotFound.png' |
||||
|
const props = defineProps({ |
||||
|
liContent: { |
||||
|
type: Object, |
||||
|
|
||||
|
}, |
||||
|
routerUrl:{ |
||||
|
type: String, |
||||
|
}, |
||||
|
|
||||
|
index: { |
||||
|
type: Number, |
||||
|
default: 0 |
||||
|
}, |
||||
|
active: { |
||||
|
type: Number, |
||||
|
default: 0 |
||||
|
}, |
||||
|
fatherisReady: { |
||||
|
type: Number, |
||||
|
default: 0 |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const userStore = useUserStore(); |
||||
|
const { userKey, userToken } = userStore; |
||||
|
|
||||
|
|
||||
|
|
||||
|
const userDetail = ref<UserDetail>({ |
||||
|
//证件号码 |
||||
|
idcardno: ["1", "2"], |
||||
|
//姓名 |
||||
|
name: 'a', |
||||
|
//头像url |
||||
|
icon: 'b', |
||||
|
//工号 |
||||
|
wmNumber: '2', |
||||
|
//唯一识别码 |
||||
|
wmKey: 1, |
||||
|
//adminorg |
||||
|
adminorg: 1, |
||||
|
}); |
||||
|
const tuijianPage = ref<Graphicform[]>(); |
||||
|
|
||||
|
/* const naviList = ref<Navi[]>(); */ |
||||
|
/* //用户信息查询参数 |
||||
|
const userQueryParam = reactive<UserQuery>({ |
||||
|
userkey: userKey, |
||||
|
usertoken: userToken, |
||||
|
}); */ |
||||
|
//navi查询参数 |
||||
|
const naviQueryParam = reactive<NaviQuery>({ |
||||
|
atParentId: "",//知识库 |
||||
|
}); |
||||
|
const pageParamTuijian = reactive<PageParam>({ |
||||
|
total: 0, |
||||
|
page: 1, |
||||
|
pagesize: 9, |
||||
|
archivesTypeAtParentId: "", //知识库or新闻资讯 |
||||
|
gParentSun: "", |
||||
|
//唯一识别码 |
||||
|
key: String(userDetail.value.wmKey), |
||||
|
//adminorg |
||||
|
adminorg: String(userDetail.value.adminorg), |
||||
|
userkey: userKey, |
||||
|
usertoken: userToken, |
||||
|
|
||||
|
}) |
||||
|
|
||||
|
function errorImg(e: any) { |
||||
|
e.srcElement.src = errimg; |
||||
|
//这一句没用,如果默认图片的路径错了还是会一直闪屏,在方法的前面加个.once只让它执行一次也没用 |
||||
|
e.srcElement.onerror = null; //防止闪图 |
||||
|
} |
||||
|
onMounted(() => { |
||||
|
|
||||
|
//console.log(props.liContent?.gParentSun) |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
}); |
||||
|
|
||||
|
watch(() => [props.fatherisReady, props.liContent,props.routerUrl], (newVal, oldVal) => { |
||||
|
//console.log(newVal, oldVal); // [11, 22], [1, 2] |
||||
|
const routerUrl = oldVal[2] as String; |
||||
|
const liContent = newVal[1] as any; |
||||
|
//console.log(newVal[1]) |
||||
|
//console.log(oldVal[2]) |
||||
|
|
||||
|
//console.log(routerUrl) |
||||
|
if (routerUrl?.endsWith("index")) {//此时页面为知识库 |
||||
|
naviQueryParam.atParentId = '16213848089876281' |
||||
|
pageParamTuijian.archivesTypeAtParentId = '16213848089876281' |
||||
|
} else if (routerUrl?.endsWith("news")) {//此时页面为新闻资讯 |
||||
|
naviQueryParam.atParentId = '16213847972425134' |
||||
|
pageParamTuijian.archivesTypeAtParentId = '16213847972425134' |
||||
|
} |
||||
|
|
||||
|
pageParamTuijian.gParentSun = liContent.atId; |
||||
|
//console.log(pageParamTuijian.gParentSun) |
||||
|
//推荐 |
||||
|
getTuijian(pageParamTuijian) |
||||
|
.then(({ data }) => { |
||||
|
tuijianPage.value = data.list |
||||
|
pageParamTuijian.page = data.pageNum |
||||
|
pageParamTuijian.total = data.total |
||||
|
// console.log(tuijianPage.value) |
||||
|
}); |
||||
|
|
||||
|
}) |
||||
|
|
||||
|
|
||||
|
|
||||
|
/* watch(props.fatherisReady, (value) => { |
||||
|
console.log(props); |
||||
|
//childList.value = nweProps.listData |
||||
|
let router = useRouter() |
||||
|
let routerUrl = toRaw(router).currentRoute.value.fullPath |
||||
|
console.log(routerUrl) |
||||
|
if (routerUrl.endsWith("index")) {//此时页面为知识库 |
||||
|
naviQueryParam.atParentId = '16213848089876281' |
||||
|
pageParamTuijian.archivesTypeAtParentId = '16213848089876281' |
||||
|
} else if (routerUrl.endsWith("news")) {//此时页面为新闻资讯 |
||||
|
naviQueryParam.atParentId = '16213847972425134' |
||||
|
pageParamTuijian.archivesTypeAtParentId = '16213847972425134' |
||||
|
} |
||||
|
|
||||
|
pageParamTuijian.gParentSun = props.liContent?.gParentSun; |
||||
|
//推荐 |
||||
|
getTuijian(pageParamTuijian) |
||||
|
.then(({ data }) => { |
||||
|
tuijianPage.value = data.list |
||||
|
pageParamTuijian.page = data.pageNum |
||||
|
pageParamTuijian.total = data.total |
||||
|
console.log(tuijianPage.value) |
||||
|
}); |
||||
|
|
||||
|
}) */ |
||||
|
|
||||
|
|
||||
|
function handleCurrentChange() { |
||||
|
|
||||
|
getTuijian(pageParamTuijian) |
||||
|
.then(({ data }) => { |
||||
|
tuijianPage.value = data.list |
||||
|
pageParamTuijian.page = data.pageNum |
||||
|
pageParamTuijian.total = data.total |
||||
|
|
||||
|
console.log(tuijianPage.value) |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
</script> |
||||
|
<template> |
||||
|
<div class="models "> |
||||
|
|
||||
|
<div class="model-title"> |
||||
|
<h3>{{ props.liContent?.atTitle }}</h3> |
||||
|
|
||||
|
</div> |
||||
|
<div class="grid-tuijian"> |
||||
|
|
||||
|
|
||||
|
<div v-for="(item, index) in tuijianPage" :key="index" class="tuijian-card"> |
||||
|
<img style="width: 140px; height: 126px;border-radius:8px;margin-top: 4px; margin-left: 4px;" |
||||
|
referrerpolicy="no-referrer" :src="item.gThumbnail" fit="fill" loading="lazy" @error="errorImg($event)" /> |
||||
|
|
||||
|
<div class="card-right"> |
||||
|
<span class="card-title">{{ item.gTitle }}</span> |
||||
|
<span class="card-text">{{ item.gDescribe }}</span> |
||||
|
|
||||
|
<span class="time-span"><span class="fa fa-clock-o"></span>{{ formatDate(item.gAddTime) }}</span> |
||||
|
|
||||
|
<span class="myicons"> |
||||
|
<span class="fa fa-star-o"></span>收藏(<span>{{ item.gCollectionSum }}</span>) <span |
||||
|
class="fa fa-thumbs-o-up"></span>赞(<span>{{ |
||||
|
item.gLikes }}</span>) <span class="fa fa-thumbs-o-down"></span>踩(<span>{{ item.gStepOn }}</span>) |
||||
|
<span class="fa fa-eye">阅读</span>(<span>{{ item.gRead }}</span>) |
||||
|
</span> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
</div> |
||||
|
<el-pagination class="pagi" v-model:current-page="pageParamTuijian.page" v-if="pageParamTuijian.total > 0" |
||||
|
v-model:page-size="pageParamTuijian.pagesize" layout="prev, pager, next, jumper" :total="pageParamTuijian.total" |
||||
|
@current-change="handleCurrentChange" /> |
||||
|
</div> |
||||
|
</template> |
||||
|
<style> |
||||
|
.models { |
||||
|
width: 100%; |
||||
|
min-height: 500px; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
.model-title { |
||||
|
height: 30px; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
.grid-tuijian { |
||||
|
/* border-top: solid 1px; */ |
||||
|
display: grid; |
||||
|
grid-template-columns: repeat(auto-fill, 415px); |
||||
|
gap: 10px; |
||||
|
grid-auto-flow: row dense; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
.tuijian-card { |
||||
|
display: flex; |
||||
|
width: 412px; |
||||
|
height: 140px; |
||||
|
padding: 3px; |
||||
|
border-radius: 8px; |
||||
|
flex-direction: row; |
||||
|
flex-wrap: wrap; |
||||
|
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px; |
||||
|
} |
||||
|
|
||||
|
.mycarousel { |
||||
|
grid-row-start: 1; |
||||
|
grid-row-end: 3; |
||||
|
border-radius: 15px; |
||||
|
} |
||||
|
|
||||
|
.card-right { |
||||
|
display: flex; |
||||
|
width: 260px; |
||||
|
flex-direction: column; |
||||
|
flex-wrap: wrap; |
||||
|
padding-left: 8px; |
||||
|
} |
||||
|
|
||||
|
.card-title { |
||||
|
height: 1.5em !important; |
||||
|
display: -webkit-box; |
||||
|
-webkit-box-orient: vertical; |
||||
|
overflow: hidden; |
||||
|
-webkit-line-clamp: 1; |
||||
|
} |
||||
|
|
||||
|
.card-text { |
||||
|
margin-top: 2px; |
||||
|
margin-bottom: 2px; |
||||
|
height: 3.1em; |
||||
|
font-size: 14px; |
||||
|
color: #909399; |
||||
|
display: -webkit-box; |
||||
|
-webkit-box-orient: vertical; |
||||
|
overflow: hidden; |
||||
|
-webkit-line-clamp: 2; |
||||
|
} |
||||
|
|
||||
|
.time-span { |
||||
|
height: 1.5em; |
||||
|
align-self: end; |
||||
|
margin-top: auto; |
||||
|
font-size: 13px; |
||||
|
margin-right: 5px; |
||||
|
color: #909399; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
.myicons { |
||||
|
align-self: end; |
||||
|
margin-right: 5px; |
||||
|
font-size: 13px; |
||||
|
color: #909399; |
||||
|
} |
||||
|
|
||||
|
.el-pagination { |
||||
|
margin-top: 20px; |
||||
|
margin-bottom: 10px; |
||||
|
justify-content: center; |
||||
|
|
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,338 @@ |
|||||
|
<script lang='ts' setup> |
||||
|
import { useUserStore } from "@/store/modules/user" |
||||
|
import { ref } from 'vue' |
||||
|
import { getUserDetail, getZxxyNavis, getTuijian } from '@/api/knowledge/index' |
||||
|
import Archivestype from '@/views/knowledge/knowledge/components/archivestype.vue' |
||||
|
import Navili from './components/Navili.vue' |
||||
|
import { UserQuery, UserDetail, NaviQuery, Navi, Graphicform, PageParam } from '@/api/knowledge/types' |
||||
|
import { onScroll, scrollTo, formatDate } from '@/api/knowledge/scroll' |
||||
|
import { useRouter } from 'vue-router' |
||||
|
import errimg from '@/assets/404_images/imgNotFound.png' |
||||
|
|
||||
|
const active = ref(0); // 当前激活的导航索引 |
||||
|
|
||||
|
|
||||
|
const userStore = useUserStore(); |
||||
|
const { userKey, userToken } = userStore; |
||||
|
|
||||
|
|
||||
|
|
||||
|
const userDetail = ref<UserDetail>({ |
||||
|
//证件号码 |
||||
|
idcardno: ["1", "2"], |
||||
|
//姓名 |
||||
|
name: 'a', |
||||
|
//头像url |
||||
|
icon: 'b', |
||||
|
//工号 |
||||
|
wmNumber: '2', |
||||
|
//唯一识别码 |
||||
|
wmKey: 1, |
||||
|
//adminorg |
||||
|
adminorg: 1, |
||||
|
}); |
||||
|
const tuijianPage = ref<Graphicform[]>(); |
||||
|
|
||||
|
const naviList = ref<Navi[]>(); |
||||
|
//用户信息查询参数 |
||||
|
const userQueryParam = reactive<UserQuery>({ |
||||
|
userkey: userKey, |
||||
|
usertoken: userToken, |
||||
|
}); |
||||
|
//navi查询参数 |
||||
|
const naviQueryParam = reactive<NaviQuery>({ |
||||
|
atParentId: "",//知识库 |
||||
|
}); |
||||
|
const pageParamTuijian = reactive<PageParam>({ |
||||
|
total: 0, |
||||
|
page: 1, |
||||
|
pagesize: 7, |
||||
|
archivesTypeAtParentId: "", //知识库or新闻资讯 |
||||
|
gParentSun: "", |
||||
|
//唯一识别码 |
||||
|
key: String(userDetail.value.wmKey), |
||||
|
//adminorg |
||||
|
adminorg: String(userDetail.value.adminorg), |
||||
|
userkey: userKey, |
||||
|
usertoken: userToken, |
||||
|
|
||||
|
}) |
||||
|
function errorImg(e: any) { |
||||
|
e.srcElement.src = errimg; |
||||
|
//这一句没用,如果默认图片的路径错了还是会一直闪屏,在方法的前面加个.once只让它执行一次也没用 |
||||
|
e.srcElement.onerror = null; //防止闪图 |
||||
|
} |
||||
|
const fatherisReady = ref(0); |
||||
|
const router = useRouter() |
||||
|
const routerUrl = toRaw(router).currentRoute.value.fullPath |
||||
|
onBeforeMount(() => { |
||||
|
|
||||
|
}) |
||||
|
|
||||
|
|
||||
|
onMounted(() => { |
||||
|
// 监听滚动事件 |
||||
|
window.addEventListener('scroll', jsScroll, false) |
||||
|
|
||||
|
if (routerUrl.endsWith("index")) {//此时页面为知识库 |
||||
|
naviQueryParam.atParentId = '16213848089876281' |
||||
|
pageParamTuijian.archivesTypeAtParentId = '16213848089876281' |
||||
|
} else if (routerUrl.endsWith("news")) {//此时页面为新闻资讯 |
||||
|
naviQueryParam.atParentId = '16213847972425134' |
||||
|
pageParamTuijian.archivesTypeAtParentId = '16213847972425134' |
||||
|
} |
||||
|
getZxxyNavis(naviQueryParam) |
||||
|
.then(({ data }) => { |
||||
|
naviList.value = data |
||||
|
//console.log(naviList.value) |
||||
|
|
||||
|
}).finally(() => { |
||||
|
fatherisReady.value = 100; |
||||
|
}) |
||||
|
|
||||
|
//当前登录用户详细信息 |
||||
|
getUserDetail(userQueryParam) |
||||
|
.then(({ data }) => { |
||||
|
userDetail.value = data |
||||
|
//console.log(userDetail.value) |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
|
||||
|
//推荐 |
||||
|
getTuijian(pageParamTuijian) |
||||
|
.then(({ data }) => { |
||||
|
tuijianPage.value = data.list |
||||
|
pageParamTuijian.page = data.pageNum |
||||
|
pageParamTuijian.total = data.total |
||||
|
//console.log(tuijianPage.value) |
||||
|
}); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
//setTimeout(function(){ fatherisReady.value = 100;}, 3000); //三秒之后执行函数 |
||||
|
|
||||
|
}); |
||||
|
function jsScroll() { |
||||
|
active.value = onScroll(); |
||||
|
} |
||||
|
onUnmounted(() => { |
||||
|
// 必须移除监听器,不然当该vue组件被销毁了,监听器还在就会出错 |
||||
|
window.removeEventListener('scroll', onScroll) |
||||
|
}); |
||||
|
function handleCurrentChange() { |
||||
|
|
||||
|
getTuijian(pageParamTuijian) |
||||
|
.then(({ data }) => { |
||||
|
tuijianPage.value = data.list |
||||
|
pageParamTuijian.page = data.pageNum |
||||
|
pageParamTuijian.total = data.total |
||||
|
|
||||
|
//console.log(tuijianPage.value) |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
</script> |
||||
|
<template> |
||||
|
<div class="know-main"> |
||||
|
<!-- 内容区域 --> |
||||
|
<div class="content" style="margin-left: 10% ;padding-right: 15%;"> |
||||
|
|
||||
|
<div class="models "> |
||||
|
|
||||
|
<div class="model-title"> |
||||
|
<h3>推荐</h3> |
||||
|
|
||||
|
</div> |
||||
|
<div class="grid-tuijian"> |
||||
|
<el-carousel indicator-position="outside" class="mycarousel" style="width: 412px;height:290px; "> |
||||
|
<el-carousel-item v-for="item in 4" :key="item"> |
||||
|
<h3 text="2xl" justify="center">{{ item }}</h3> |
||||
|
</el-carousel-item> |
||||
|
</el-carousel> |
||||
|
|
||||
|
<div v-for="(item, index) in tuijianPage" :key="index" class="tuijian-card"> |
||||
|
<img style="width: 140px; height: 126px;border-radius:8px;margin-top: 4px; margin-left: 4px;" |
||||
|
referrerpolicy="no-referrer" :src="item.gThumbnail" fit="fill" loading="lazy" @error="errorImg($event)" /> |
||||
|
|
||||
|
<div class="card-right"> |
||||
|
<span class="card-title">{{ item.gTitle }}</span> |
||||
|
<span class="card-text">{{ item.gDescribe }}</span> |
||||
|
|
||||
|
<span class="time-span"><span class="fa fa-clock-o"></span>{{ formatDate(item.gAddTime) }}</span> |
||||
|
|
||||
|
<span class="myicons"> |
||||
|
<span class="fa fa-star-o"></span>收藏(<span>{{ item.gCollectionSum }}</span>) <span |
||||
|
class="fa fa-thumbs-o-up"></span>赞(<span>{{ |
||||
|
item.gLikes }}</span>) <span class="fa fa-thumbs-o-down"></span>踩(<span>{{ item.gStepOn }}</span>) |
||||
|
<span class="fa fa-eye">阅读</span>(<span>{{ item.gRead }}</span>) |
||||
|
</span> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
</div> |
||||
|
<el-pagination class="pagi" v-model:current-page="pageParamTuijian.page" v-if="pageParamTuijian.total > 0" |
||||
|
v-model:page-size="pageParamTuijian.pagesize" layout="prev, pager, next, jumper" :total="pageParamTuijian.total" |
||||
|
@current-change="handleCurrentChange" /> |
||||
|
</div> |
||||
|
<!-- 各知识/新闻分区 --> |
||||
|
<Archivestype v-for="(item, index) in naviList" :liContent=item :index=(index) :fatherisReady="fatherisReady" |
||||
|
:routerUrl="routerUrl"> |
||||
|
</Archivestype> |
||||
|
|
||||
|
|
||||
|
|
||||
|
</div> |
||||
|
<!-- 导航区域 --> |
||||
|
<ul class="navs"> |
||||
|
<li :class="{ active: active === 0 }" @click="scrollTo(0)"> |
||||
|
推荐 |
||||
|
</li> |
||||
|
<Navili v-for="(item, index) in naviList" :class="{ active: active === index+1 }" :oneli=item :index=(index+1) |
||||
|
:active=active @click="scrollTo(index + 1)"></Navili> |
||||
|
|
||||
|
</ul> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
|
||||
|
|
||||
|
<style scoped> |
||||
|
/* 内容区的样式 */ |
||||
|
.content { |
||||
|
background-color: white; |
||||
|
width: 100%; |
||||
|
} |
||||
|
|
||||
|
.models { |
||||
|
width: 100%; |
||||
|
min-height: 500px; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/* 导航栏的样式 */ |
||||
|
.navs { |
||||
|
position: fixed; |
||||
|
top: 100px; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
.navs li { |
||||
|
|
||||
|
padding: 0 40px; |
||||
|
line-height: 2.6; |
||||
|
font-size: 15px; |
||||
|
color: #909399; |
||||
|
} |
||||
|
|
||||
|
.navs li:hover { |
||||
|
cursor: pointer; |
||||
|
} |
||||
|
|
||||
|
/* 当导航被点亮后改变颜色 */ |
||||
|
.navs .active { |
||||
|
color: #409EFF; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
.model-title { |
||||
|
height: 30px; |
||||
|
} |
||||
|
|
||||
|
.grid-tuijian { |
||||
|
display: grid; |
||||
|
grid-template-columns: repeat(auto-fill, 415px); |
||||
|
gap: 10px; |
||||
|
grid-auto-flow: row dense; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
.tuijian-card { |
||||
|
display: flex; |
||||
|
width: 412px; |
||||
|
height: 140px; |
||||
|
padding: 3px; |
||||
|
border-radius: 8px; |
||||
|
flex-direction: row; |
||||
|
flex-wrap: wrap; |
||||
|
/* border:#909399 1px solid; */ |
||||
|
/* box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px; */ |
||||
|
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px; |
||||
|
} |
||||
|
|
||||
|
.mycarousel { |
||||
|
grid-row-start: 1; |
||||
|
grid-row-end: 3; |
||||
|
border-radius: 15px; |
||||
|
} |
||||
|
|
||||
|
.card-right { |
||||
|
display: flex; |
||||
|
width: 260px; |
||||
|
flex-direction: column; |
||||
|
flex-wrap: wrap; |
||||
|
padding-left: 8px; |
||||
|
} |
||||
|
|
||||
|
.card-title { |
||||
|
|
||||
|
/* height: 1.5em !important; |
||||
|
overflow: hidden; |
||||
|
text-overflow: ellipsis; |
||||
|
display: -webkit-box; |
||||
|
-webkit-line-clamp: 3; |
||||
|
-webkit-box-orient: vertical; |
||||
|
line-height: 25px; |
||||
|
height: 85px; */ |
||||
|
|
||||
|
|
||||
|
height: 1.5em !important; |
||||
|
display: -webkit-box; |
||||
|
-webkit-box-orient: vertical; |
||||
|
overflow: hidden; |
||||
|
-webkit-line-clamp: 1; |
||||
|
} |
||||
|
|
||||
|
.card-text { |
||||
|
margin-top: 2px; |
||||
|
margin-bottom: 2px; |
||||
|
height: 3.1em; |
||||
|
font-size: 14px; |
||||
|
color: #909399; |
||||
|
display: -webkit-box; |
||||
|
-webkit-box-orient: vertical; |
||||
|
overflow: hidden; |
||||
|
-webkit-line-clamp: 2; |
||||
|
} |
||||
|
|
||||
|
.time-span { |
||||
|
height: 1.5em; |
||||
|
align-self: end; |
||||
|
margin-top: auto; |
||||
|
font-size: 13px; |
||||
|
margin-right: 5px; |
||||
|
color: #909399; |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
.myicons { |
||||
|
|
||||
|
align-self: end; |
||||
|
margin-right: 5px; |
||||
|
font-size: 13px; |
||||
|
color: #909399; |
||||
|
} |
||||
|
|
||||
|
.el-pagination { |
||||
|
margin-top: 20px; |
||||
|
margin-bottom: 10px; |
||||
|
justify-content: center; |
||||
|
|
||||
|
} |
||||
|
</style> |
||||
|
|
||||
Loading…
Reference in new issue