724 lines
21 KiB
PHP
724 lines
21 KiB
PHP
{include file="component/head" /}
|
|
{include file="component/header-simple" /}
|
|
<div class="main">
|
|
<div class="main-top">
|
|
<div class="main-top-main">
|
|
<div class="main-title">
|
|
<?php echo $game['title']; ?>
|
|
</div>
|
|
<div class="location">
|
|
<div class="container">
|
|
<div class="location-item">
|
|
<a href="/">首页</a>
|
|
<span>></span>
|
|
<a href="/index/game/list" id="cateLink"><?php echo $cateName; ?></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="detail-main">
|
|
<div class="detail-top">
|
|
<div class="detail-top-card">
|
|
<div class="detail-top-card-left">
|
|
<div class="article-cover">
|
|
<img src="<?php echo $game['icon'] ?: '/static/images/default-game.png'; ?>">
|
|
<!-- <img src="https://www.yunzer.cn/storage/uploads/20250523/b75a51fa606fd3a18261a6ea283d35fe.jpg" alt=""> -->
|
|
</div>
|
|
</div>
|
|
<div class="detail-top-card-right">
|
|
<div class="detail-top-card-right-top">
|
|
<div class="collect-btn">
|
|
<button class="btn btn-primary" id="collectBtn" data-game-id="<?php echo $game['id']; ?>">
|
|
<i class="fa-solid fa-heart"></i> 收藏
|
|
</button>
|
|
</div>
|
|
<div class="report-btn">
|
|
<button class="btn btn-primary" id="reportBtn" style="margin-left: 20px;">
|
|
<i class="fa-solid fa-flag"></i> 举报
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="detail-top-card-right-middle">
|
|
<div class="game-info">
|
|
<div class="title">Free</div>
|
|
<div class="infos">
|
|
<div class="infoitem"><span>更新时间:</span><span
|
|
class="infoitem-value"><?php echo date('Y-m-d', $game['create_time']); ?></span>
|
|
</div>
|
|
<div class="infoitem"><span>所属分类:</span><span
|
|
class="infoitem-value"><?php echo $cateName; ?></span></div>
|
|
<div class="infoitem"><span>程序编号:</span><span
|
|
class="infoitem-value"><?php echo $game['number']; ?></span></div>
|
|
<div class="infoitem"><span>查看:</span><span
|
|
class="infoitem-value"><?php echo $game['views']; ?></span></div>
|
|
<div class="infoitem"><span>下载:</span><span
|
|
class="infoitem-value"><?php echo $game['downloads']; ?></span></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="detail-top-card-right-bottom">
|
|
<div class="game-actions1">
|
|
<div style="display: flex;gap: 30px;}">
|
|
<button id="downloadBtn" class="btn btn-primary">
|
|
<i class="fa-solid fa-download"></i> 立即下载
|
|
</button>
|
|
<button id="codeBtn" class="codebtn">
|
|
<i class="fa-solid fa-download"></i> 分享码:<?php echo $game['code']; ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="detail-middle">
|
|
<div class="detial-middle-left">
|
|
<div class="game-detail">
|
|
<div class="game-info">
|
|
<div class="game-content">
|
|
<div class="game-desc">
|
|
<?php echo $game['content']; ?>
|
|
</div>
|
|
</div>
|
|
<div class="game-actions">
|
|
<div style="display: flex;gap: 30px;}">
|
|
<button id="downloadBtn" class="btn btn-primary">
|
|
<i class="fa-solid fa-download"></i> 立即下载
|
|
</button>
|
|
<button id="codeBtn" class="codebtn">
|
|
<i class="fa-solid fa-download"></i> 分享码:<?php echo $game['code']; ?>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="disclaimers">
|
|
<div class="disclaimer-item">
|
|
<div class="disclaimer-title">免责声明:</div>
|
|
<div class="disclaimer-content">
|
|
<?php echo $config['disclaimers'] ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="game-navigation">
|
|
<div class="prev-game" id="prevGame">
|
|
</div>
|
|
<div class="next-game" id="nextGame">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 相关游戏 -->
|
|
<?php if (!empty($relatedGames)): ?>
|
|
<div class="related-games">
|
|
<h3>相关游戏</h3>
|
|
<div class="game-list">
|
|
<?php foreach ($relatedGames as $related): ?>
|
|
<div class="game-item"
|
|
onclick="window.location.href='/index/game/detail?id=<?php echo $related['id']; ?>'">
|
|
<div class="game-cover">
|
|
<img src="<?php echo $related['icon'] ?: '/static/images/default-game.png'; ?>"
|
|
alt="<?php echo $related['title']; ?>">
|
|
</div>
|
|
<div class="game-info">
|
|
<h4 class="game-title-1"><?php echo $related['title']; ?></h4>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<div class="detial-middle-right">
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- 返回顶部按钮 -->
|
|
<div class="go-to-top" id="goToTop">
|
|
<i class="layui-icon layui-icon-top"></i>
|
|
</div>
|
|
|
|
{include file="component/footer" /}
|
|
|
|
<script>
|
|
// 页面加载完成后执行
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
// 获取游戏ID
|
|
const gameId = new URLSearchParams(window.location.search).get('id');
|
|
if (!gameId) {
|
|
alert('游戏ID不存在');
|
|
return;
|
|
}
|
|
|
|
// 获取游戏详情
|
|
fetch('/index/game/detail?id=' + gameId, {
|
|
headers: {
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
}
|
|
})
|
|
.then(response => response.json())
|
|
.then(result => {
|
|
if (result.code === 1) {
|
|
// 渲染上一篇
|
|
const prevGame = document.getElementById('prevGame');
|
|
if (result.data.prevGame) {
|
|
prevGame.innerHTML = `
|
|
<a href="/index/game/detail?id=${result.data.prevGame.id}">
|
|
<i class="fa fa-arrow-left"></i> 上一篇:${result.data.prevGame.title}
|
|
</a>
|
|
`;
|
|
} else {
|
|
prevGame.innerHTML = '<span class="disabled"><i class="fa fa-arrow-left"></i> 没有上一篇了</span>';
|
|
}
|
|
|
|
// 渲染下一篇
|
|
const nextGame = document.getElementById('nextGame');
|
|
if (result.data.nextGame) {
|
|
nextGame.innerHTML = `
|
|
<a href="/index/game/detail?id=${result.data.nextGame.id}">
|
|
下一篇:${result.data.nextGame.title} <i class="fa fa-arrow-right"></i>
|
|
</a>
|
|
`;
|
|
} else {
|
|
nextGame.innerHTML = '<span class="disabled">没有下一篇了 <i class="fa fa-arrow-right"></i></span>';
|
|
}
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('获取游戏详情失败:', error);
|
|
});
|
|
|
|
// 更新访问次数
|
|
updateGameViews(gameId);
|
|
|
|
// 下载功能
|
|
const downloadBtn = document.getElementById('downloadBtn');
|
|
if (downloadBtn) {
|
|
downloadBtn.addEventListener('click', function () {
|
|
fetch('/index/game/downloadurl?id=' + gameId, {
|
|
method: 'GET',
|
|
headers: {
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
}
|
|
})
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
throw new Error('网络响应失败');
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
if (data.code === 1) {
|
|
const downloadsElement = document.getElementById('gameDownloads');
|
|
if (downloadsElement) {
|
|
let downloads = parseInt(downloadsElement.textContent);
|
|
downloadsElement.textContent = downloads + 1;
|
|
}
|
|
|
|
// 直接使用返回的URL
|
|
if (data.data && data.data.url) {
|
|
window.open(data.data.url, '_blank');
|
|
} else {
|
|
alert('下载地址不存在');
|
|
}
|
|
} else {
|
|
alert('下载失败:' + data.msg);
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('下载请求失败:', error);
|
|
alert('下载请求失败,请稍后重试');
|
|
});
|
|
});
|
|
}
|
|
|
|
//复制分享码
|
|
const codeBtn = document.getElementById('codeBtn');
|
|
if (codeBtn) {
|
|
codeBtn.addEventListener('click', function () {
|
|
const code = '<?php echo $game['code']; ?>';
|
|
if (code) {
|
|
// 创建一个临时输入框
|
|
const tempInput = document.createElement('input');
|
|
tempInput.value = code;
|
|
document.body.appendChild(tempInput);
|
|
tempInput.select();
|
|
|
|
try {
|
|
// 尝试使用传统的复制方法
|
|
document.execCommand('copy');
|
|
layer.msg('分享码已复制到剪贴板');
|
|
} catch (err) {
|
|
console.error('复制失败:', err);
|
|
layer.msg('复制失败,请手动复制');
|
|
} finally {
|
|
// 移除临时输入框
|
|
document.body.removeChild(tempInput);
|
|
}
|
|
} else {
|
|
layer.msg('分享码不存在');
|
|
}
|
|
});
|
|
}
|
|
|
|
// 返回顶部功能
|
|
const goToTop = document.getElementById('goToTop');
|
|
|
|
// 监听滚动事件
|
|
window.addEventListener('scroll', function () {
|
|
if (window.pageYOffset > 300) {
|
|
goToTop.classList.add('show');
|
|
} else {
|
|
goToTop.classList.remove('show');
|
|
}
|
|
});
|
|
|
|
// 点击返回顶部
|
|
goToTop.addEventListener('click', function () {
|
|
window.scrollTo({
|
|
top: 0,
|
|
behavior: 'smooth'
|
|
});
|
|
});
|
|
});
|
|
|
|
// 更新游戏访问次数
|
|
function updateGameViews(gameId) {
|
|
fetch('/index/game/updateViews', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
'X-Requested-With': 'XMLHttpRequest'
|
|
},
|
|
body: 'id=' + gameId
|
|
})
|
|
.then(response => response.json())
|
|
.then(result => {
|
|
if (result.code === 1) {
|
|
const viewsElement = document.querySelector('.game-views');
|
|
if (viewsElement) {
|
|
viewsElement.innerHTML = `<i class="fa-solid fa-eye"></i> ${result.data.views}`;
|
|
}
|
|
}
|
|
})
|
|
.catch(error => {
|
|
console.error('更新访问次数失败:', error);
|
|
});
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.main-top {
|
|
width: 100%;
|
|
height: 400px;
|
|
background-color: #0081ff;
|
|
/* background: url('/static/images/top-bg.jpg') no-repeat center center; */
|
|
position: relative;
|
|
}
|
|
|
|
.main-top-card {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
margin-top: 30px;
|
|
border-radius: 8px;
|
|
background-color: #fff;
|
|
height: 300px;
|
|
}
|
|
|
|
.main-top-main {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
padding-top: 50px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
position: absolute;
|
|
top: 0;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
width: 100%;
|
|
z-index: 1;
|
|
}
|
|
|
|
.main-top-main .main-title {
|
|
font-size: 30px;
|
|
font-weight: 700;
|
|
max-width: 1000px;
|
|
color: #fff;
|
|
}
|
|
|
|
.detail-top {
|
|
max-width: 1400px;
|
|
/* height: 300px; */
|
|
margin: 30px auto;
|
|
position: relative;
|
|
background-color: #fff;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
display: flex;
|
|
}
|
|
|
|
.detail-top-card {
|
|
width: 100%;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
|
|
.detail-top-card img {
|
|
width: 400px;
|
|
height: auto;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.detail-top-card-right {
|
|
/* height: 230px; */
|
|
display: flex;
|
|
width: 100%;
|
|
margin-left: 20px;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.detail-top-card-right-top {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
align-items: center;
|
|
}
|
|
|
|
.detail-top-card-right-middle {}
|
|
|
|
.detail-top-card-right-middle .game-info {
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: space-between;
|
|
height: 100%;
|
|
}
|
|
|
|
.detail-top-card-right-middle .game-info .title {
|
|
font-size: 40px;
|
|
font-weight: 700;
|
|
color: #42d697;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.detail-top-card-right-middle .game-info .infos {
|
|
display: flex;
|
|
}
|
|
|
|
.detail-top-card-right-middle .game-info .infos .infoitem {
|
|
margin-right: 60px;
|
|
}
|
|
|
|
.detail-top-card-right-middle .game-info .infos .infoitem span {
|
|
color: #7d879c;
|
|
}
|
|
|
|
.detail-middle {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.detail-main {
|
|
position: relative;
|
|
top: -200px;
|
|
left: 0;
|
|
width: 100%;
|
|
z-index: 2;
|
|
}
|
|
|
|
.location {
|
|
color: #fff;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.location a {
|
|
color: #fff !important;
|
|
}
|
|
|
|
.game-detail {
|
|
padding: 50px;
|
|
background: #fff;
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.game-header {
|
|
margin-bottom: 30px;
|
|
border-bottom: 1px solid #eee;
|
|
padding-bottom: 20px;
|
|
}
|
|
|
|
.game-title {
|
|
font-size: 30px;
|
|
font-weight: 700;
|
|
color: #333;
|
|
margin-bottom: 15px;
|
|
line-height: 1.4;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.game-title-1 {
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
color: #333;
|
|
margin-bottom: 15px;
|
|
line-height: 1.4;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.game-meta {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 20px;
|
|
color: #666;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.game-meta span {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.game-meta i {
|
|
margin-right: 5px;
|
|
}
|
|
|
|
.game-content {
|
|
line-height: 1.8;
|
|
color: #333;
|
|
font-size: 16px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.game-cover {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.game-cover img {
|
|
width: 100%;
|
|
height: 300px;
|
|
object-fit: cover;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.game-desc {
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.game-actions {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 40px;
|
|
margin: 30px 0;
|
|
padding: 20px 0;
|
|
border-top: 1px solid #eee;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
|
|
.game-actions1 {
|
|
display: flex;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.game-navigation {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin: 30px 0;
|
|
}
|
|
|
|
.prev-game,
|
|
.next-game {
|
|
max-width: 45%;
|
|
}
|
|
|
|
.prev-game a,
|
|
.next-game a {
|
|
color: #333 !important;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.prev-game a:hover,
|
|
.next-game a:hover {
|
|
color: #f57005 !important;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.btn {
|
|
/* background: #f57005; */
|
|
color: #fff;
|
|
padding: 5px 15px;
|
|
border-radius: 8px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.btn:hover {
|
|
/* background: #e66600; */
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.codebtn {
|
|
color: #0d6efd;
|
|
padding: 15px 30px;
|
|
border-radius: 8px;
|
|
border: 1px solid #0d6efd;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
background-color: #fff;
|
|
}
|
|
|
|
.codebtn:hover {
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.related-games {
|
|
margin: 40px 0;
|
|
}
|
|
|
|
.related-games h3 {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
margin-bottom: 20px;
|
|
padding-bottom: 10px;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
|
|
.related-title {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
margin-bottom: 20px;
|
|
padding-bottom: 10px;
|
|
border-bottom: 1px solid #eee;
|
|
}
|
|
|
|
.game-list {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 20px;
|
|
}
|
|
|
|
.game-item {
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
transition: transform 0.3s;
|
|
}
|
|
|
|
.game-item:hover {
|
|
transform: translateY(-5px);
|
|
}
|
|
|
|
.game-item a {
|
|
text-decoration: none;
|
|
color: inherit;
|
|
}
|
|
|
|
.game-cover img {
|
|
width: 100%;
|
|
height: 150px;
|
|
object-fit: cover;
|
|
}
|
|
|
|
.game-info {
|
|
padding: 10px;
|
|
}
|
|
|
|
.go-to-top {
|
|
position: fixed;
|
|
right: 30px;
|
|
bottom: 30px;
|
|
width: 40px;
|
|
height: 40px;
|
|
background: #f57005;
|
|
color: #fff;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
opacity: 0;
|
|
visibility: hidden;
|
|
transition: all 0.3s ease;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
|
z-index: 1000;
|
|
}
|
|
|
|
.go-to-top.show {
|
|
opacity: 1;
|
|
visibility: visible;
|
|
}
|
|
|
|
.go-to-top:hover {
|
|
background: #e66600;
|
|
transform: translateY(-3px);
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.game-title {
|
|
font-size: 24px;
|
|
}
|
|
|
|
.game-list {
|
|
grid-template-columns: repeat(1, 1fr);
|
|
}
|
|
|
|
.game-meta {
|
|
gap: 10px;
|
|
}
|
|
|
|
.go-to-top {
|
|
right: 20px;
|
|
bottom: 20px;
|
|
width: 36px;
|
|
height: 36px;
|
|
}
|
|
}
|
|
|
|
.disclaimers {
|
|
color: #b1b1b1;
|
|
width: 80%;
|
|
margin: 20px auto;
|
|
margin-bottom: 60px;
|
|
}
|
|
|
|
.disclaimer-title {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.disclaimer-content {
|
|
font-size: 14px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.disclaimer-content p {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.infoitem-value {
|
|
border: 1px #0d6efd dashed;
|
|
padding: 3px 6px;
|
|
font-size: 13px;
|
|
background-color: #0081ff12;
|
|
border-radius: 5px;
|
|
}
|
|
</style>
|
|
|
|
{include file="component/foot" /}
|