This commit is contained in:
gongfuxiang 2019-04-22 23:55:57 +08:00
parent f28ffe7ea1
commit 4854e571e9
10 changed files with 66 additions and 114 deletions

View File

@ -12,6 +12,7 @@ namespace app\plugins\homemiddleadv;
use think\Controller;
use app\plugins\homemiddleadv\Service;
use app\service\PluginsService;
/**
* 首页中间广告插件 - 钩子入口
* @author Devil
@ -37,7 +38,7 @@ class Hook extends Controller
{
// style css
case 'plugins_common_header' :
$ret = $this->Css($params);
$ret = $this->StyleCss($params);
break;
// 楼层数据上面
@ -61,6 +62,30 @@ class Hook extends Controller
*/
public function HomeFloorTopAdv($params = [])
{
// 获取应用数据
$ret = PluginsService::PluginsData('homemiddleadv');
if($ret['code'] == 0)
{
// 有效时间
if(!empty($ret['data']['time_start']))
{
// 是否已开始
if(strtotime($ret['data']['time_start']) > time())
{
return '';
}
}
if(!empty($ret['data']['time_end']))
{
// 是否已结束
if(strtotime($ret['data']['time_end']) < time())
{
return '';
}
}
}
// 获取图片列表
$ret = Service::DataList();
if($ret['code'] == 0 && !empty($ret['data']))
{
@ -78,7 +103,7 @@ class Hook extends Controller
* @datetime 2019-02-06T16:16:34+0800
* @param [array] $params [输入参数]
*/
public function Css($params = [])
public function StyleCss($params = [])
{
return '<style type="text/css">
@media only screen and (min-width:640px) {
@ -87,6 +112,19 @@ class Hook extends Controller
margin-left: -10px;
margin-top: 10px;
}
.plugins-homemiddleadv-home-adv ul.am-gallery img {
-webkit-transition: transform .2s ease-in;
-moz-transition: transform .2s ease-in;
-ms-transition: transform .2s ease-in;
-o-transition: transform .2s ease-in;
transition: transform .2s ease-in;
}
.plugins-homemiddleadv-home-adv ul.am-gallery img:hover {
-ms-transform: translate3d(0px, -3px, 0px);
-webkit-transform: translate3d(0px, -3px, 0px);
-o-transform: translate3d(0px, -3px, 0px);
transform: translate3d(0px, -3px, 0px);
}
}
</style>';
}

View File

@ -34,7 +34,7 @@ class Service
*/
public static function DataList($params = [])
{
$ret = PluginsService::PluginsData('homemiddleadv', null, false);
$ret = PluginsService::PluginsData('homemiddleadv');
$data = (empty($ret['data']) || empty($ret['data']['data_list'])) ? [] : $ret['data']['data_list'];
if(!empty($data))

View File

@ -13,42 +13,23 @@
<div class="am-panel am-panel-secondary homemiddleadv-middle-banner">
<div class="am-panel-hd">
<span class="am-panel-title">基础数据</span>
<a class="am-fr" href="{{:PluginsAdminUrl('homemiddleadv', 'admin', 'baseinfo')}}">编辑</a>
<a class="am-fr" href="{{:PluginsAdminUrl('homemiddleadv', 'admin', 'saveinfo')}}">编辑</a>
</div>
<div class="am-panel-bd">
<div class="items">
<label>应用导航名称</label>
<label>有效时间</label>
<div>
{{if empty($data['application_name'])}}
未设置应用导航名称
{{if !empty($data['time_start']) and !empty($data['time_end'])}}
{{$data.time_start}} ~ {{$data.time_end}}
{{elseif !empty($data['time_start']) and empty($data['time_end'])}}
{{$data.time_start}} ~ 长期有效
{{elseif empty($data['time_start']) and !empty($data['time_end'])}}
立即生效 ~ {{$data.time_end}}
{{else /}}
{{$data.application_name}}
无限制
{{/if}}
</div>
</div>
<div class="items">
<label>右侧推荐问答名称</label>
<div>
{{if empty($data['right_top_rec_name'])}}
推荐问答
{{else /}}
{{$data.right_top_rec_name}}
{{/if}}
</div>
</div>
<div class="items">
<label>中间最新问答名称</label>
<div>
{{if empty($data['middle_new_name'])}}
最新问答
{{else /}}
{{$data.middle_new_name}}
{{/if}}
</div>
</div>
</div>
</div>
@ -65,7 +46,7 @@
<li>
<div class="am-gallery-item">
<a href="{{if empty($v['url'])}}javascript:;{{else /}}{{$v.url}}{{/if}}" {{if isset($v['is_new_window_open']) and $v['is_new_window_open'] eq 1}}target="_blank"{{/if}}>
<img src="{{$v.images_url}}" alt="{{$v.name}}" />
<img src="{{$v.images_url}}" alt="{{$v.name}}" title="{{$v.name}}" />
</a>
</div>
</li>

View File

@ -9,86 +9,7 @@
<span class="fs-16">首页中间广告</span>
<a href="{{:PluginsAdminUrl('homemiddleadv', 'admin', 'index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-alert am-alert-secondary" data-am-alert>
<div class="am-form-group am-form-file">
<label class="block">广告1-图片<span class="am-form-group-label-tips">建议290像数X150像数</span></label>
<ul class="plug-file-upload-view plugins-ad1_images-view" data-form-name="ad1_images" data-max-number="1" data-delete="0" data-dialog-type="images">
<li>
<input type="text" name="ad1_images" value="{{if !empty($data['ad1_images_old'])}}{{$data.ad1_images_old}}{{/if}}" data-validation-message="请上传图片" required />
<img src="{{if !empty($data['ad1_images'])}}{{$data.ad1_images}}{{else /}}{{$attachment_host}}/static/plugins/images/homemiddleadv/default-images.jpg{{/if}}" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.plugins-ad1_images-view">+上传图片</div>
</div>
<div class="am-form-group">
<label>广告1-链接地址<span class="am-form-group-label-tips">带http://或https://</span></label>
<input type="url" placeholder="广告1-链接地址" name="ad1_url" data-validation-message="广告1-链接地址格式有误" class="am-radius" {{if !empty($data)}} value="{{$data.ad1_url}}"{{/if}} />
</div>
</div>
<div class="am-alert am-alert-secondary" data-am-alert>
<div class="am-form-group am-form-file">
<label class="block">广告2-图片<span class="am-form-group-label-tips">建议290像数X150像数</span></label>
<ul class="plug-file-upload-view plugins-ad2_images-view" data-form-name="ad2_images" data-max-number="1" data-delete="0" data-dialog-type="images">
<li>
<input type="text" name="ad2_images" value="{{if !empty($data['ad2_images_old'])}}{{$data.ad2_images_old}}{{/if}}" data-validation-message="请上传图片" required />
<img src="{{if !empty($data['ad2_images'])}}{{$data.ad2_images}}{{else /}}{{$attachment_host}}/static/plugins/images/homemiddleadv/default-images.jpg{{/if}}" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.plugins-ad2_images-view">+上传图片</div>
</div>
<div class="am-form-group">
<label>广告2-链接地址<span class="am-form-group-label-tips">带http://或https://</span></label>
<input type="url" placeholder="广告2-链接地址" name="ad2_url" data-validation-message="广告2-链接地址格式有误" class="am-radius" {{if !empty($data)}} value="{{$data.ad2_url}}"{{/if}} />
</div>
</div>
<div class="am-alert am-alert-secondary" data-am-alert>
<div class="am-form-group am-form-file">
<label class="block">广告3-图片<span class="am-form-group-label-tips">建议290像数X150像数</span></label>
<ul class="plug-file-upload-view plugins-ad3_images-view" data-form-name="ad3_images" data-max-number="1" data-delete="0" data-dialog-type="images">
<li>
<input type="text" name="ad3_images" value="{{if !empty($data['ad3_images_old'])}}{{$data.ad3_images_old}}{{/if}}" data-validation-message="请上传图片" required />
<img src="{{if !empty($data['ad3_images'])}}{{$data.ad3_images}}{{else /}}{{$attachment_host}}/static/plugins/images/homemiddleadv/default-images.jpg{{/if}}" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.plugins-ad3_images-view">+上传图片</div>
</div>
<div class="am-form-group">
<label>广告3-链接地址<span class="am-form-group-label-tips">带http://或https://</span></label>
<input type="url" placeholder="广告3-链接地址" name="ad3_url" data-validation-message="广告3-链接地址格式有误" class="am-radius" {{if !empty($data)}} value="{{$data.ad3_url}}"{{/if}} />
</div>
</div>
<div class="am-alert am-alert-secondary" data-am-alert>
<div class="am-form-group am-form-file">
<label class="block">广告4-图片<span class="am-form-group-label-tips">建议290像数X150像数</span></label>
<ul class="plug-file-upload-view plugins-ad4_images-view" data-form-name="ad4_images" data-max-number="1" data-delete="0" data-dialog-type="images">
<li>
<input type="text" name="ad4_images" value="{{if !empty($data['ad4_images_old'])}}{{$data.ad4_images_old}}{{/if}}" data-validation-message="请上传图片" required />
<img src="{{if !empty($data['ad4_images'])}}{{$data.ad4_images}}{{else /}}{{$attachment_host}}/static/plugins/images/homemiddleadv/default-images.jpg{{/if}}" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.plugins-ad4_images-view">+上传图片</div>
</div>
<div class="am-form-group">
<label>广告4-链接地址<span class="am-form-group-label-tips">带http://或https://</span></label>
<input type="url" placeholder="广告4-链接地址" name="ad4_url" data-validation-message="广告4-链接地址格式有误" class="am-radius" {{if !empty($data)}} value="{{$data.ad4_url}}"{{/if}} />
</div>
</div>
<div class="am-form-group">
<label>是否新窗口打开</label>
<div>
{{foreach $is_whether_list as $v}}
<label class="am-radio-inline m-r-10">
<input type="radio" name="is_new_window_open" value="{{$v.id}}" {{if isset($data['is_new_window_open']) and $data['is_new_window_open'] eq $v['id']}}checked="checked"{{else /}}{{if !isset($data['is_new_window_open']) and isset($v['checked']) and $v['checked'] eq true}}checked="checked"{{/if}}{{/if}} data-am-ucheck /> {{$v.name}}
</label>
{{/foreach}}
</div>
</div>
<div class="am-form-group">
<label>有效时间<span class="am-form-group-label-tips">留空则不限制</span></label>
<div class="form-date">

View File

@ -5,7 +5,7 @@
<li>
<div class="am-gallery-item">
<a href="{{if empty($v['url'])}}javascript:;{{else /}}{{$v.url}}{{/if}}" {{if isset($v['is_new_window_open']) and $v['is_new_window_open'] eq 1}}target="_blank"{{/if}}>
<img src="{{$v.images_url}}" alt="{{$v.name}}" />
<img src="{{$v.images_url}}" alt="{{$v.name}}" title="{{$v.name}}" />
</a>
</div>
</li>

View File

@ -30,10 +30,22 @@
}
}
/**
* 编辑页面
*/
.form-date input {
width: 30% !important;
display: -webkit-inline-box !important;
}
.form-date span {
vertical-align: middle;
}
/**
* 幻灯片编辑
*/
ul.plug-file-upload-view li {
width: 300px;
width: 160px;
height: auto;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB