回到顶部改为应用实现

This commit is contained in:
devil_gong 2019-02-15 14:06:24 +08:00
parent 60cfc00614
commit 52a3aba57d
19 changed files with 486 additions and 51 deletions

View File

@ -80,8 +80,17 @@ class Common extends Controller
*/
private function CommonPluginsInit()
{
// 公共header内钩子
$this->assign('plugins_view_common_header_data', Hook::listen('plugins_view_common_header', ['hook_name'=>'plugins_view_common_header', 'is_control'=>false, 'user'=>$this->user]));
// 公共页面部钩子
$this->assign('plugins_view_common_page_bottom_data', Hook::listen('plugins_view_common_page_bottom', ['hook_name'=>'plugins_view_common_page_bottom', 'is_control'=>false, 'user'=>$this->user]));
// 公共顶部钩子
$this->assign('plugins_view_common_top_data', Hook::listen('plugins_view_common_top', ['hook_name'=>'plugins_view_common_top', 'is_control'=>false, 'user'=>$this->user]));
// 公共底部钩子
$this->assign('plugins_view_common_bottom_data', Hook::listen('plugins_view_common_bottom', ['hook_name'=>'plugins_view_common_bottom', 'is_control'=>false, 'user'=>$this->user]));
}
/**

View File

@ -4,10 +4,19 @@
{{/if}}
<!-- footer end -->
<!-- go-top start -->
{{include file="public/go_top" /}}
<!-- go-top end -->
<!-- 公共底部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_common_bottom</span>
</div>
{{/if}}
{{if !empty($plugins_view_common_bottom_data) and is_array($plugins_view_common_bottom_data) and (!isset($is_footer) or $is_footer eq 1)}}
{{foreach $plugins_view_common_bottom_data as $hook}}
{{if is_string($hook) or is_int($hook)}}
{{$hook|raw}}
{{/if}}
{{/foreach}}
{{/if}}
</body>
</html>
@ -44,4 +53,18 @@
{{if !empty($module_js)}}
<script type='text/javascript' src="{{$Think.__MY_ROOT_PUBLIC__}}static/{{$module_js}}?v={{:MyC('home_static_cache_version')}}"></script>
{{/if}}
{{:MyC('home_footer_info')}}
{{:MyC('home_footer_info')}}
<!-- 公共页面底部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_common_page_bottom</span>
</div>
{{/if}}
{{if !empty($plugins_view_common_page_bottom_data) and is_array($plugins_view_common_page_bottom_data) and (!isset($is_footer) or $is_footer eq 1)}}
{{foreach $plugins_view_common_page_bottom_data as $hook}}
{{if is_string($hook) or is_int($hook)}}
{{$hook|raw}}
{{/if}}
{{/foreach}}
{{/if}}

View File

@ -1,3 +0,0 @@
<div data-am-smooth-scroll class="am-hide-sm-only">
<a href="javascript:;" title="回到顶部" class="am-icon-btn am-icon-arrow-up" id="my-go-top" style="display:none;"></a>
</div>

View File

@ -36,8 +36,23 @@
var __attachment_host__ = '{{$attachment_host}}';
var __user_id__ = {{if empty($user['id'])}}0{{else /}}{{$user.id}}{{/if}};
</script>
<!-- 公共header内钩子 -->
{{if !empty($plugins_view_common_header_data) and is_array($plugins_view_common_header_data) and (!isset($is_header) or $is_header eq 1)}}
{{foreach $plugins_view_common_header_data as $hook}}
{{if is_string($hook) or is_int($hook)}}
{{$hook|raw}}
{{/if}}
{{/foreach}}
{{/if}}
</head>
<body>
<!-- 公共header内钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_header) or $is_header eq 1)}}
<div class="plugins-tag">
<span>plugins_view_common_header</span>
</div>
{{/if}}
<!-- 公共顶部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_header) or $is_header eq 1)}}

View File

@ -0,0 +1,90 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2018 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\plugins\commongobacktop;
use app\service\PluginsService;
/**
* 回到顶部 - 后台管理
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Admin
{
/**
* 首页
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
*/
public function index($params = [])
{
$ret = PluginsService::PluginsData('commongobacktop', ['images']);
if($ret['code'] == 0)
{
// 数组组装
$data = [
'data' => $ret['data'],
];
return DataReturn('处理成功', 0, $data);
} else {
return $ret;
}
}
/**
* 编辑页面
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
*/
public function saveinfo($params = [])
{
$ret = PluginsService::PluginsData('commongobacktop', ['images']);
if($ret['code'] == 0)
{
// 是否
$is_whether_list = [
0 => array('id' => 0, 'name' => '否'),
1 => array('id' => 1, 'name' => '是', 'checked' => true),
];
// 数组组装
$data = [
'is_whether_list' => $is_whether_list,
'data' => $ret['data'],
];
return DataReturn('处理成功', 0, $data);
} else {
return $ret;
}
}
/**
* 数据保存
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
*/
public function save($params = [])
{
return PluginsService::PluginsDataSave(['plugins'=>'commongobacktop', 'data'=>$params]);
}
}
?>

View File

@ -0,0 +1,169 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2018 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\plugins\commongobacktop;
use app\service\PluginsService;
/**
* 回到顶部 - 钩子入口
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class Hook
{
/**
* 应用响应入口
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-09T14:25:44+0800
* @param [array] $params [输入参数]
*/
public function run($params = [])
{
// 是否控制器钩子
// is_control 当前为控制器业务处理
// hook_name 钩子名称
if(isset($params['is_control']) && $params['is_control'] === true && !empty($params['hook_name']))
{
// 参数一 描述
// 参数二 0 为处理成功, 负数为失败
// 参数三 返回数据
return DataReturn('返回描述', 0);
// 默认返回视图
} else {
if(!empty($params['hook_name']))
{
switch($params['hook_name'])
{
case 'plugins_view_common_bottom' :
$ret = $this->html($params);
break;
case 'plugins_view_common_page_bottom' :
$ret = $this->js($params);
break;
case 'plugins_view_common_header' :
$ret = $this->css($params);
break;
default :
$ret = '';
}
return $ret;
} else {
return '';
}
}
}
/**
* css
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-06T16:16:34+0800
* @param [array] $params [输入参数]
*/
public function css($params = [])
{
return '<style type="text/css">
#plugins-commongobacktop {
display:none;
position: fixed;
right: 50px;
bottom: 100px;
z-index: 100;
cursor: pointer;
}
</style>';
}
/**
* js
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-06T16:16:34+0800
* @param [array] $params [输入参数]
*/
public function js($params = [])
{
return '<script type="text/javascript">
// 回顶部监测
$(window).scroll(function()
{
if($(window).scrollTop() > 100)
{
$("#plugins-commongobacktop").fadeIn(1000);
} else {
$("#plugins-commongobacktop").fadeOut(1000);
}
});
</script>';
}
/**
* 视图
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2019-02-06T16:16:34+0800
* @param [array] $params [输入参数]
*/
public function html($params = [])
{
// 当前模块/控制器/方法
$module_name = strtolower(request()->module());
$controller_name = strtolower(request()->controller());
$action_name = strtolower(request()->action());
// 获取应用数据
$ret = PluginsService::PluginsData('commongobacktop', ['images']);
// html拼接
$html = '<div data-am-smooth-scroll class="am-hide-sm-only">';
$content = '';
if($ret['code'] == 0)
{
// 图片是否为空
if(empty($ret['data']['images']))
{
return '';
}
// 非全局
if($ret['data']['is_overall'] != 1)
{
// 非首页则空
if($module_name.$controller_name.$action_name != 'indexindexindex')
{
return '';
}
}
$content = '<div id="plugins-commongobacktop" title="回到顶部">';
$content .= '<img src="'.$ret['data']['images'].'" />';
$content .= '</div>';
} else {
$content = $ret['msg'];
}
$html .= $content;
$html .= '</div>';
return $html;
}
}
?>

View File

@ -0,0 +1,30 @@
{
"base":{
"plugins":"commongobacktop",
"name":"回到顶部",
"logo":"\/static\/upload\/images\/plugins_commongobacktop\/2019\/02\/15\/1550200927239565.png",
"author":"Devil",
"author_url":"https:\/\/shopxo.net\/",
"version":"1.0.0",
"desc":"当滚动到底部的时候出现回到顶部操作",
"apply_terminal":[
"pc",
"h5"
],
"apply_version":[
"1.3.0"
],
"is_home":false
},
"hook":{
"plugins_view_common_bottom":[
"app\\plugins\\commongobacktop\\Hook"
],
"plugins_view_common_page_bottom":[
"app\\plugins\\commongobacktop\\Hook"
],
"plugins_view_common_header":[
"app\\plugins\\commongobacktop\\Hook"
]
}
}

View File

@ -65,6 +65,12 @@ class Hook
$content = '';
if($ret['code'] == 0)
{
// 图片是否为空
if(empty($ret['data']['images']))
{
return '';
}
// 有效时间
if(!empty($ret['data']['time_start']))
{

View File

@ -0,0 +1,36 @@
{{include file="public/header" /}}
<!-- right content start -->
<div class="content-right">
<div class="content">
<legend>
<span class="fs-16">回到顶部</span>
<a href="{{:MyUrl('admin/pluginsadmin/index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
</legend>
<div class="commongobacktop-content">
<div class="items">
<label>图片</label>
<div class="immages-tag">
<img src="{{if !empty($data['images_old'])}}{{$data.images_old}}{{else /}}{{$attachment_host}}/static/plugins/images/commongobacktop/default-images.png{{/if}}" />
</div>
</div>
<div class="items">
<label>是否全局</label>
<div>
{{if isset($data['is_overall']) and $data['is_overall'] eq 1}}
{{else /}}
{{/if}}
</div>
</div>
<a href="{{:PluginsAdminUrl('commongobacktop', 'admin', 'saveinfo')}}" class="am-btn am-btn-secondary am-radius btn-loading-example am-btn-sm am-btn-block edit-submit">编辑</a>
</div>
</div>
</div>
<!-- right content end -->
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

View File

@ -0,0 +1,46 @@
{{include file="public/header" /}}
<!-- right content start -->
<div class="content-right">
<div class="content">
<!-- form start -->
<form class="am-form form-validation view-save" action="{{:PluginsAdminUrl('commongobacktop', 'admin', 'save')}}" method="POST" request-type="ajax-url" request-value="{{:PluginsAdminUrl('commongobacktop', 'admin', 'index')}}" enctype="multipart/form-data">
<legend>
<span class="fs-16">回到顶部</span>
<a href="{{:PluginsAdminUrl('commongobacktop', 'admin', 'index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-form-group am-form-file">
<label class="block">图片<span class="fs-12 fw-100 cr-999">建议50像数X50像数</span></label>
<ul class="plug-file-upload-view plugins-images-view" data-form-name="images" data-max-number="1" data-delete="0" data-dialog-type="images">
<li>
<input type="text" name="images" value="{{if !empty($data['images'])}}{{$data.images}}{{/if}}" data-validation-message="请上传图片" required />
<img src="{{if !empty($data['images_old'])}}{{$data.images_old}}{{else /}}{{$attachment_host}}/static/plugins/images/commongobacktop/default-images.png{{/if}}" />
</li>
</ul>
<div class="plug-file-upload-submit" data-view-tag="ul.plugins-images-view">+上传图片</div>
</div>
<div class="am-form-group">
<label>是否全局<span class="fs-12 fw-100 cr-999">(否则只在首页显示,是则全局展示)</span></label>
<div>
{{foreach $is_whether_list as $v}}
<label class="am-radio-inline m-r-10">
<input type="radio" name="is_overall" value="{{$v.id}}" {{if isset($data['is_overall']) and $data['is_overall'] eq $v['id']}}checked="checked"{{else /}}{{if !isset($data['is_overall']) 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">
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">保存</button>
</div>
</form>
<!-- form end -->
</div>
</div>
<!-- right content end -->
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

View File

@ -45,5 +45,17 @@ return array (
array (
0 => 'app\\plugins\\userloginrewardintegral\\Hook',
),
'plugins_view_common_bottom' =>
array (
0 => 'app\\plugins\\commongobacktop\\Hook',
),
'plugins_view_common_page_bottom' =>
array (
0 => 'app\\plugins\\commongobacktop\\Hook',
),
'plugins_view_common_header' =>
array (
0 => 'app\\plugins\\commongobacktop\\Hook',
),
);
?>

File diff suppressed because one or more lines are too long

View File

@ -743,16 +743,6 @@ button { outline: none !important; }
.common-cropper-popup .preview-sm { width:50px; height:50px; }
}
/**
* 回到顶部
*/
#my-go-top {
position: fixed;
right: 50px;
bottom: 100px;
}
/**
* 插件标记
*/

View File

@ -2,17 +2,6 @@ console.log("%c\u5b89\u5168\u8b66\u544a\uff01","font-size:50px;color:red;-webkit
console.log("%c\u6b64\u6d4f\u89c8\u5668\u529f\u80fd\u4e13\u4f9b\u5f00\u53d1\u8005\u4f7f\u7528\u3002\u8bf7\u4e0d\u8981\u5728\u6b64\u7c98\u8d34\u6267\u884c\u4efb\u4f55\u5185\u5bb9\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u60a8\u7684\u8d26\u6237\u53d7\u5230\u653b\u51fb\uff0c\u7ed9\u60a8\u5e26\u6765\u635f\u5931 \uff01","font-size: 20px;color:#333");
console.log("\u6280\u672f\u652f\u6301\uff1a\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0073\u0068\u006f\u0070\u0078\u006f\u002e\u006e\u0065\u0074\u002f");
// 回顶部监测
$(window).scroll(function()
{
if($(window).scrollTop() > 100)
{
$("#my-go-top").fadeIn(1000);
} else {
$("#my-go-top").fadeOut(1000);
}
});
var store = $.AMUI.store;
if(!store.enabled)
{

View File

@ -0,0 +1,20 @@
/**
* 首页
*/
.commongobacktop-content .items {
margin: 10px 0 20px 0;
border-bottom: 1px dashed #f1f1f1;
padding-bottom: 20px;
}
.commongobacktop-content .items .immages-tag {
border: 1px solid #eee;
text-align: center;
max-width: 100px;
padding: 5px;
}
.commongobacktop-content .items .immages-tag img {
max-width: 100%;
}
.commongobacktop-content .edit-submit {
margin-bottom: 20px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

View File

@ -0,0 +1 @@

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB