mirror of https://github.com/1099438829/apeblog
修正轮播图
This commit is contained in:
parent
8a208aa775
commit
b944a03a1a
|
|
@ -155,8 +155,9 @@ class Advert extends AuthController
|
||||||
* @author 木子的忧伤
|
* @author 木子的忧伤
|
||||||
* @date 2021-02-19 11:53
|
* @date 2021-02-19 11:53
|
||||||
*/
|
*/
|
||||||
public function info()
|
public function info($id = '')
|
||||||
{
|
{
|
||||||
|
if (!$id) return app("json")->fail("参数有误,Id为空!");
|
||||||
return $this->fetch();
|
return $this->fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,6 +174,7 @@ class Advert extends AuthController
|
||||||
public function infoList(Request $request)
|
public function infoList(Request $request)
|
||||||
{
|
{
|
||||||
$where = Util::postMore([
|
$where = Util::postMore([
|
||||||
|
['id', ''],
|
||||||
['title', ''],
|
['title', ''],
|
||||||
['start_time', ''],
|
['start_time', ''],
|
||||||
['end_time', ''],
|
['end_time', ''],
|
||||||
|
|
@ -260,12 +262,16 @@ class Advert extends AuthController
|
||||||
if (is_array($data['cover_path'])) $data['cover_path'] = $data['cover_path'][0];
|
if (is_array($data['cover_path'])) $data['cover_path'] = $data['cover_path'][0];
|
||||||
$data['user_id'] = $this->adminId;//默认修改你
|
$data['user_id'] = $this->adminId;//默认修改你
|
||||||
if (filter_var($data['url'], FILTER_VALIDATE_URL) === false) return app("json")->fail("链接地址不合法");
|
if (filter_var($data['url'], FILTER_VALIDATE_URL) === false) return app("json")->fail("链接地址不合法");
|
||||||
|
$info = aModel::find($data['advert_id']);
|
||||||
|
if (!$info){
|
||||||
|
return app("json")->fail("广告组id错误");
|
||||||
|
}
|
||||||
if ($id == "") {
|
if ($id == "") {
|
||||||
$res = tModel::create($data);
|
$res = tModel::create($data);
|
||||||
} else {
|
} else {
|
||||||
$res = tModel::update($data, ['id' => $id]);
|
$res = tModel::update($data, ['id' => $id]);
|
||||||
}
|
}
|
||||||
cache(Data::DATA_ADVERT . '_' . $data['advert_id'], null);//清除缓存
|
cache(Data::DATA_ADVERT . '_' . $info['alias'], null);//清除缓存
|
||||||
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
|
return $res ? app("json")->success("操作成功", 'code') : app("json")->fail("操作失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,6 +15,7 @@ use Psr\SimpleCache\InvalidArgumentException;
|
||||||
use think\db\exception\DataNotFoundException;
|
use think\db\exception\DataNotFoundException;
|
||||||
use think\db\exception\DbException;
|
use think\db\exception\DbException;
|
||||||
use think\db\exception\ModelNotFoundException;
|
use think\db\exception\ModelNotFoundException;
|
||||||
|
use think\facade\Cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统配置
|
* 系统配置
|
||||||
|
|
@ -66,6 +67,7 @@ class SystemConfig extends AuthController
|
||||||
$commonPath = config("cache.runtime") . "/cache/";
|
$commonPath = config("cache.runtime") . "/cache/";
|
||||||
$indexPath = config("cache.runtime") . "/index/";
|
$indexPath = config("cache.runtime") . "/index/";
|
||||||
$apiPath = config("cache.runtime") . "/api/";
|
$apiPath = config("cache.runtime") . "/api/";
|
||||||
|
Cache::clear();
|
||||||
if (remove_cache($adminPath) && remove_cache($indexPath) && remove_cache($apiPath) && remove_cache($commonPath)) return app("json")->success("操作成功");
|
if (remove_cache($adminPath) && remove_cache($indexPath) && remove_cache($apiPath) && remove_cache($commonPath)) return app("json")->success("操作成功");
|
||||||
return app("json")->error("操作失败");
|
return app("json")->error("操作失败");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -68,9 +68,10 @@
|
||||||
</div>
|
</div>
|
||||||
{include file="public/footer"/}
|
{include file="public/footer"/}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
var id = GetQueryString("id");
|
||||||
$('#tb_departments').bootstrapTable({
|
$('#tb_departments').bootstrapTable({
|
||||||
classes: 'table table-bordered table-hover table-striped',
|
classes: 'table table-bordered table-hover table-striped',
|
||||||
url: '/admin/advert/infoList',
|
url: '/admin/advert/infoList?id=' + id,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
|
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
|
||||||
uniqueId: 'id',
|
uniqueId: 'id',
|
||||||
|
|
@ -230,6 +231,12 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function GetQueryString(name) {
|
||||||
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
|
||||||
|
var r = window.location.search.substr(1).match(reg);
|
||||||
|
if (r != null) return unescape(r[2]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -83,7 +83,7 @@
|
||||||
var id = GetQueryString("id");
|
var id = GetQueryString("id");
|
||||||
$('#tb_departments').bootstrapTable({
|
$('#tb_departments').bootstrapTable({
|
||||||
classes: 'table table-bordered table-hover table-striped',
|
classes: 'table table-bordered table-hover table-striped',
|
||||||
url: '/admin/article/commentList?id=' + id,
|
url: '/admin/article/commentList?document_id=' + id,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
|
dataType: 'json', // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
|
||||||
uniqueId: 'id',
|
uniqueId: 'id',
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ class AdvertInfo extends BaseModel
|
||||||
public static function systemPage($where): array
|
public static function systemPage($where): array
|
||||||
{
|
{
|
||||||
$model = new self;
|
$model = new self;
|
||||||
|
if ($where['id'] != '') $model = $model->where("advert_id", "=", $where['id']);
|
||||||
if ($where['title'] != '') $model = $model->where("title|url", "like", "%$where[title]%");
|
if ($where['title'] != '') $model = $model->where("title|url", "like", "%$where[title]%");
|
||||||
if ($where['start_time'] != '') $model = $model->where("create_time", ">", strtotime($where['start_time'] . " 00:00:00"));
|
if ($where['start_time'] != '') $model = $model->where("create_time", ">", strtotime($where['start_time'] . " 00:00:00"));
|
||||||
if ($where['end_time'] != '') $model = $model->where("create_time", "<", strtotime($where['end_time'] . " 23:59:59"));
|
if ($where['end_time'] != '') $model = $model->where("create_time", "<", strtotime($where['end_time'] . " 23:59:59"));
|
||||||
|
|
|
||||||
|
|
@ -567,7 +567,7 @@ function tpl_get_friend_link($type, $row)
|
||||||
/**
|
/**
|
||||||
* 广告
|
* 广告
|
||||||
* @param $type
|
* @param $type
|
||||||
* @param $row
|
* @param int $row
|
||||||
* @return array|mixed|object|App|Collection|Db[]
|
* @return array|mixed|object|App|Collection|Db[]
|
||||||
* @throws DataNotFoundException
|
* @throws DataNotFoundException
|
||||||
* @throws DbException
|
* @throws DbException
|
||||||
|
|
@ -575,9 +575,9 @@ function tpl_get_friend_link($type, $row)
|
||||||
* @author 木子的忧伤
|
* @author 木子的忧伤
|
||||||
* @date 2021-07-26 23:24
|
* @date 2021-07-26 23:24
|
||||||
*/
|
*/
|
||||||
function tpl_get_advert($type, $row)
|
function tpl_get_advert($type, int $row = 5)
|
||||||
{
|
{
|
||||||
$advertList = cache(Data::DATA_ADVERT . '_' . $type .'_'. $row);
|
$advertList = cache(Data::DATA_ADVERT . '_' . $type);
|
||||||
if ($advertList === null) {
|
if ($advertList === null) {
|
||||||
$advertList = (new Advert())->alias("a")
|
$advertList = (new Advert())->alias("a")
|
||||||
->leftJoin("advert_info i",'a.id = i.advert_id')
|
->leftJoin("advert_info i",'a.id = i.advert_id')
|
||||||
|
|
@ -586,8 +586,8 @@ function tpl_get_advert($type, $row)
|
||||||
->where('a.status', 1)
|
->where('a.status', 1)
|
||||||
->where('i.status', 1)
|
->where('i.status', 1)
|
||||||
->order('sort desc')
|
->order('sort desc')
|
||||||
->limit($row)
|
->select()
|
||||||
->select();
|
->toArray();
|
||||||
//处理文件cdn信息
|
//处理文件cdn信息
|
||||||
foreach ($advertList as $key => &$item) {
|
foreach ($advertList as $key => &$item) {
|
||||||
if (empty($item['cover_path'])){
|
if (empty($item['cover_path'])){
|
||||||
|
|
@ -595,9 +595,16 @@ function tpl_get_advert($type, $row)
|
||||||
}
|
}
|
||||||
$item['cover_path'] = file_cdn($item['cover_path']);
|
$item['cover_path'] = file_cdn($item['cover_path']);
|
||||||
}
|
}
|
||||||
cache(Data::DATA_ADVERT . '_' . $type .'_'. $row, $advertList);
|
unset($item);
|
||||||
|
if (!empty($advertList)){
|
||||||
|
cache(Data::DATA_ADVERT . '_' . $type, $advertList);
|
||||||
}
|
}
|
||||||
return $advertList;
|
}
|
||||||
|
//如果获取行数为空则取默认值
|
||||||
|
if (!$row){
|
||||||
|
$row = 5;
|
||||||
|
}
|
||||||
|
return array_slice($advertList,0,$row);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
|
console.log(2222)
|
||||||
var mySwiper = new Swiper('.swiper-container', {
|
var mySwiper = new Swiper('.swiper-container', {
|
||||||
loop: true,
|
loop: true,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
|
|
@ -56,7 +57,7 @@
|
||||||
</style>
|
</style>
|
||||||
<div class="index-top-postcard-plane">
|
<div class="index-top-postcard-plane">
|
||||||
<div class="index-top-postcard-body">
|
<div class="index-top-postcard-body">
|
||||||
{ape:advert row="4" type="2"}
|
{ape:advert row="4" type="INDEX_RECOMMEND"}
|
||||||
<div class="index-top-postcard-item">
|
<div class="index-top-postcard-item">
|
||||||
<div class="index-top-postcard-main">
|
<div class="index-top-postcard-main">
|
||||||
<div class="post-item-thumbnail">
|
<div class="post-item-thumbnail">
|
||||||
|
|
@ -256,7 +257,7 @@
|
||||||
<a class="friend-links-item-card" href="{$field['url']}" target="_blank">
|
<a class="friend-links-item-card" href="{$field['url']}" target="_blank">
|
||||||
{notempty name="$field['image']"}
|
{notempty name="$field['image']"}
|
||||||
<div class="friend-links-item-icon">
|
<div class="friend-links-item-icon">
|
||||||
<img class="img-lazyload" src=" {notempty name="$field['image']"} {$field['title']}{$field['image']}{else /}__IMG__/chrome.png{/notempty}" alt="{$field['title']}" data-original="{$field['image']}" onerror="this.src='__IMG__/chrome.png'">
|
<img class="img-lazyload" src=" {notempty name="$field['image']"}{$field['image']}{else /}__IMG__/chrome.png{/notempty}" alt="{$field['title']}" data-original="{$field['image']}" onerror="this.src='__IMG__/chrome.png'">
|
||||||
</div>
|
</div>
|
||||||
{/notempty}
|
{/notempty}
|
||||||
<div class="friend-links-item-main">
|
<div class="friend-links-item-main">
|
||||||
|
|
|
||||||
|
|
@ -153,9 +153,7 @@ $(document).ready(function () {
|
||||||
}
|
}
|
||||||
//图片延迟加载
|
//图片延迟加载
|
||||||
$("img").lazyload({effect: "fadeIn", container: $("html,body,#app")});
|
$("img").lazyload({effect: "fadeIn", container: $("html,body,#app")});
|
||||||
window.onload = function () {
|
|
||||||
$(window).resize()
|
$(window).resize()
|
||||||
};
|
|
||||||
if (set.module.imglazyload == 1) {
|
if (set.module.imglazyload == 1) {
|
||||||
endloadhtml();
|
endloadhtml();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue