Files
zhgh_cqgmy/src/main/resources/views/layouts/v4/home/entry.js
T

273 lines
8.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const entry = {
template: /*language=HTML*/ `
<div class="entry-wrapper">
<div class="portal-entry-header">
<div class="portal-entry-tabs" role="tablist" aria-label="推荐入口">
<button v-for="section in entrySections" :key="section.key"
type="button" role="tab" :aria-selected="activeSection === section.key"
:class="{active: activeSection === section.key}" @click="$set(this, 'activeSection', section.key)">{{ section.title }}</button>
</div>
<a class="portal-more" href="/platform/v4/apps">全部应用 <i class="fa fa-arrow-right" aria-hidden="true"></i></a>
</div>
<div :class="['entry-section', 'entry-section-' + section.key]" v-for="section in entrySections" :key="section.key" v-show="activeSection === section.key" role="tabpanel">
<div class="apps-container">
<div class="app-grid" tabindex="0" :aria-label="section.title + ',可横向滚动浏览'">
<button type="button" class="app-item"
v-for="(item, index) in section.list"
:key="item.id || index"
@click="openService(item, section.key)">
<div class="app-icon">
<img v-if="item.picIcon" class="app-icon-img" :src="item.picIcon" alt="" />
<i v-else class="fa fa-cube app-icon-fallback"></i>
</div>
<div class="app-name" :title="item.name">{{ item.name }}</div>
</button>
<el-empty class="app-empty"
v-if="!section.list || section.list.length === 0"
description="暂无数据"
:image-size="72">
</el-empty>
</div>
</div>
</div>
<slot></slot>
</div>
`,
data() {
return {
activeSection: 'serv',
hasMore: true,
entries: {
serv: [],
app: [],
fav: []
},
}
},
computed: {
entrySections() {
return [
{ key: 'serv', title: '推荐服务', icon: 'fa fa-star', list: this.entries.serv },
{ key: 'app', title: '推荐应用', icon: 'fa fa-fire', list: this.entries.app },
{ key: 'fav', title: '我的收藏', icon: 'fa fa-heart', list: this.entries.fav }
];
}
},
created() {
this.getRecommendService()
this.getRecommendApp()
this.getFavorite()
},
methods: {
// platform 固定传 PC;Result.data 为当前用户有权限的推荐服务数组。
getRecommendService() {
this.$axios.post('/platform/home/listRecommendService', {platform: "PC"}).then(res => {
if (res.code === 0) {
this.entries.serv = res.data
}
})
},
// platform 固定传 PC;Result.data 为当前用户可进入的推荐应用数组。
getRecommendApp() {
this.$axios.post('/platform/home/listRecommendApp', {platform: "PC"}).then(res => {
if (res.code === 0) {
this.entries.app = res.data
}
})
},
// platform 固定传 PC;Result.data 为当前用户收藏且有权限的菜单数组。
getFavorite() {
this.$axios.post('/platform/home/listFavorite', {platform: "PC"}).then(res => {
if (res.code === 0) {
this.entries.fav = res.data
}
})
},
// 点击服务或应用
openService(service, category) {
if (category === 'serv') {
if (!service.href) {
this.$message.error('无效的链接地址')
return
}
window.open(service.href)
return
}
if (category === 'app') {
window.sessionStorage.setItem("zhgh_sub_app", JSON.stringify(service))
window.open("/platform/v4/subApp?appId=" + service.id, "_blank")
return
}
if (category === 'fav') {
if (service.href) {
window.open(service.href)
return
}
if (!service.parentId) {
window.sessionStorage.setItem("zhgh_sub_app", JSON.stringify(service))
window.open("/platform/v4/subApp?appId=" + service.id, "_blank")
return
}
this.$message.error('无效的链接地址')
}
}
},
style: /*language=CSS*/ `
.entry-wrapper {
width: 100%;
box-sizing: border-box;
}
.entry-section + .entry-section {
margin-top: 22px;
}
.entry-section-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10px;
}
.entry-section-title {
display: inline-flex;
align-items: baseline;
gap: 6px;
color: #19324d;
font-size: 18px;
font-weight: 700;
}
.entry-section-title i {
color: #409eff;
font-size: 16px;
}
.entry-section-title em {
color: #b5c0d6;
font-size: 14px;
font-style: normal;
font-weight: 500;
}
.apps-container {
display: flex;
flex-direction: column;
gap: 20px;
}
.app-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
justify-items: center;
justify-content: start;
gap: 12px 18px;
min-height: 116px;
padding: 18px 20px;
background: #fff;
border: 1px solid #edf1f7;
border-radius: 8px;
box-shadow: 0 4px 12px rgba(0,0,0,0.06);
overflow-x: hidden;
}
.app-item {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-start;
border-radius: 8px;
background: #fff;
width: 100%;
max-width: 108px;
min-width: 0;
box-sizing: border-box;
padding: 6px;
cursor: pointer;
transition: transform 0.2s ease, box-shadow 0.2s ease;
overflow: hidden;
}
.app-item:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.app-icon {
width: 56px;
height: 56px;
margin-bottom: 8px;
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 56px;
overflow: hidden;
border-radius: 8px;
background: #f5f8ff;
}
.app-icon img,
.app-icon-img {
display: block;
width: 56px !important;
height: 56px !important;
max-width: 56px !important;
max-height: 56px !important;
object-fit: contain !important;
border-radius: 8px;
}
.app-icon-fallback {
color: #409eff;
font-size: 24px;
}
.app-name {
min-height: 34px;
width: 100%;
font-size: 12px;
color: #333;
line-height: 1.4;
word-break: break-word;
text-align: center;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.app-empty {
grid-column: 1 / -1;
width: 100%;
}
@media (max-width: 768px) {
.app-grid {
grid-template-columns: repeat(3, minmax(72px, 1fr));
gap: 12px;
padding: 14px 10px;
}
.app-item {
padding: 8px 4px;
}
}
@media (max-width: 480px) {
.app-grid {
grid-template-columns: repeat(2, minmax(72px, 1fr));
gap: 12px;
}
}
`
};