diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index b9a5e6770..acc1cbd36 100755 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -10,6 +10,7 @@ // +---------------------------------------------------------------------- namespace app\index\controller; +use think\facade\Hook; use app\service\BannerService; use app\service\GoodsService; use app\service\ArticleService; @@ -69,8 +70,30 @@ class Index extends Common // 用户订单状态 $user_order_status = OrderService::OrderStatusStepTotal(['user_type'=>'user', 'user'=>$this->user, 'is_comments'=>1]); $this->assign('user_order_status', $user_order_status['data']); + + // 钩子 + $this->PluginsHook(); return $this->fetch(); } + + /** + * 钩子处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-04-22 + * @desc description + * @param [array] $params [输入参数] + */ + private function PluginsHook($params = []) + { + // 楼层数据上面 + $this->assign('plugins_view_home_floor_top_data', Hook::listen('plugins_view_home_floor_top', + [ + 'hook_name' => 'plugins_view_home_floor_top', + 'is_backend' => false, + ])); + } } ?> \ No newline at end of file diff --git a/application/index/view/default/index/index.html b/application/index/view/default/index/index.html index 5f139a0bc..6f9a9210f 100755 --- a/application/index/view/default/index/index.html +++ b/application/index/view/default/index/index.html @@ -21,7 +21,7 @@
- + {{if !empty($navigation)}}
{{foreach $navigation as $nav}} @@ -37,7 +37,7 @@
{{/if}} - +
@@ -99,7 +99,56 @@
- + + + + + + + +{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
+ plugins_view_home_floor_top +
+{{/if}} +{{if !empty($plugins_view_home_floor_top_data) and is_array($plugins_view_home_floor_top_data)}} + {{foreach $plugins_view_home_floor_top_data as $hook}} + {{if is_string($hook) or is_int($hook)}} + {{$hook|raw}} + {{/if}} + {{/foreach}} +{{/if}} + +
{{if !empty($goods_floor_list)}} diff --git a/application/plugins/homemiddleadv/Admin.php b/application/plugins/homemiddleadv/Admin.php new file mode 100755 index 000000000..29c3b4f70 --- /dev/null +++ b/application/plugins/homemiddleadv/Admin.php @@ -0,0 +1,192 @@ +assign('data_list', $list['data']); + + $this->assign('data', $ret['data']); + return $this->fetch('../../../plugins/view/homemiddleadv/admin/index'); + } else { + return $ret['msg']; + } + } + + /** + * 编辑页面 + * @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('homemiddleadv', null, false); + if($ret['code'] == 0) + { + $this->assign('data', $ret['data']); + return $this->fetch('../../../plugins/view/homemiddleadv/admin/saveinfo'); + } else { + return $ret['msg']; + } + } + + /** + * 数据保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function save($params = []) + { + $list = Service::DataList(); + $params['data_list'] = $list['data']; + return PluginsService::PluginsDataSave(['plugins'=>'homemiddleadv', 'data'=>$params]); + } + + + + /** + * 数据列表页面 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function dataindex($params = []) + { + $list = Service::DataList(); + if($list['code'] == 0) + { + $this->assign('data_list', $list['data']); + return $this->fetch('../../../plugins/view/homemiddleadv/admin/dataindex'); + } else { + return $list['msg']; + } + } + + /** + * 数据列表编辑 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function datainfo($params = []) + { + // 数据 + $data = []; + if(!empty($params['id'])) + { + $data_params = [ + 'get_id' => $params['id'], + ]; + $ret = Service::DataList($data_params); + $data = empty($ret['data']) ? [] : $ret['data']; + } + $this->assign('data', $data); + + return $this->fetch('../../../plugins/view/homemiddleadv/admin/datainfo'); + } + + /** + * 数据列表保存 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-07T08:21:54+0800 + * @param [array] $params [输入参数] + */ + public function datasave($params = []) + { + // 是否ajax请求 + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始处理 + return Service::DataSave($params); + } + + /** + * 数据列表删除 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-15T11:03:30+0800 + * @param [array] $params [输入参数] + */ + public function datadelete($params = []) + { + // 是否ajax请求 + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始处理 + return Service::DataDelete($params); + } + + /** + * 数据列表状态更新 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2017-01-12T22:23:06+0800 + * @param [array] $params [输入参数] + */ + public function datastatusupdate($params = []) + { + // 是否ajax请求 + if(!IS_AJAX) + { + return $this->error('非法访问'); + } + + // 开始处理 + return Service::DataStatusUpdate($params); + } +} +?> \ No newline at end of file diff --git a/application/plugins/homemiddleadv/Hook.php b/application/plugins/homemiddleadv/Hook.php new file mode 100755 index 000000000..88310f9e2 --- /dev/null +++ b/application/plugins/homemiddleadv/Hook.php @@ -0,0 +1,68 @@ +HomeFloorTopAdv($params); + break; + default : + $ret = ''; + } + return $ret; + } + } + + /** + * 首页楼层顶部广告 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2019-02-06T16:16:34+0800 + * @param [array] $params [输入参数] + */ + public function HomeFloorTopAdv($params = []) + { + $ret = Service::DataList(); + if($ret['code'] == 0 && !empty($ret['data'])) + { + $this->assign('data_list', $ret['data']); + return $this->fetch('../../../plugins/view/homemiddleadv/index/content'); + } + return ''; + } +} +?> \ No newline at end of file diff --git a/application/plugins/homemiddleadv/Service.php b/application/plugins/homemiddleadv/Service.php new file mode 100644 index 000000000..42d25fbb2 --- /dev/null +++ b/application/plugins/homemiddleadv/Service.php @@ -0,0 +1,225 @@ + 'length', + 'key_name' => 'name', + 'checked_data' => '2,60', + 'error_msg' => '名称长度 2~60 个字符', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'images_url', + 'checked_data' => '255', + 'error_msg' => '请上传图片', + ], + [ + 'checked_type' => 'fun', + 'key_name' => 'url', + 'is_checked' => 1, + 'checked_data' => 'CheckUrl', + 'error_msg' => 'url格式有误', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 附件 + $data_fields = ['images_url']; + $attachment = ResourcesService::AttachmentParams($params, $data_fields); + + // 数据 + $data = [ + 'name' => $params['name'], + 'url' => $params['url'], + 'images_url' => $attachment['data']['images_url'], + 'is_enable' => isset($params['is_enable']) ? intval($params['is_enable']) : 0, + 'is_new_window_open' => isset($params['is_new_window_open']) ? intval($params['is_new_window_open']) : 0, + 'operation_time' => time(), + ]; + + // 原有数据 + $ret = PluginsService::PluginsData('homemiddleadv', null, false); + + // 数据id + $data['id'] = (empty($params['id']) || empty($ret['data']) || empty($ret['data']['data_list'][$params['id']])) ? date('YmdHis').GetNumberCode(6) : $params['id']; + $ret['data']['data_list'][$data['id']] = $data; + + // 保存 + return PluginsService::PluginsDataSave(['plugins'=>'homemiddleadv', 'data'=>$ret['data']]); + } + + /** + * 数据列表删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-18 + * @desc description + * @param [array] $params [输入参数] + */ + public static function DataDelete($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '操作id有误', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 原有数据 + $ret = PluginsService::PluginsData('homemiddleadv', null, false); + $ret['data']['data_list'] = (empty($ret['data']) || empty($ret['data']['data_list'])) ? [] : $ret['data']['data_list']; + + // 删除操作 + if(isset($ret['data']['data_list'][$params['id']])) + { + unset($ret['data']['data_list'][$params['id']]); + } + + // 保存 + return PluginsService::PluginsDataSave(['plugins'=>'homemiddleadv', 'data'=>$ret['data']]); + } + + /** + * 数据列表删除 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-12-18 + * @desc description + * @param [array] $params [输入参数] + */ + public static function DataStatusUpdate($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'id', + 'error_msg' => '操作id有误', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'field', + 'error_msg' => '操作字段有误', + ], + [ + 'checked_type' => 'in', + 'key_name' => 'state', + 'checked_data' => [0,1], + 'error_msg' => '状态有误', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 原有数据 + $ret = PluginsService::PluginsData('homemiddleadv', null, false); + $ret['data']['data_list'] = (empty($ret['data']) || empty($ret['data']['data_list'])) ? [] : $ret['data']['data_list']; + + // 删除操作 + if(isset($ret['data']['data_list'][$params['id']]) && isset($ret['data']['data_list'][$params['id']][$params['field']])) + { + $ret['data']['data_list'][$params['id']][$params['field']] = intval($params['state']); + $ret['data']['data_list'][$params['id']]['operation_time'] = time(); + } + + // 保存 + return PluginsService::PluginsDataSave(['plugins'=>'homemiddleadv', 'data'=>$ret['data']]); + } +} +?> \ No newline at end of file diff --git a/application/plugins/homemiddleadv/config.json b/application/plugins/homemiddleadv/config.json new file mode 100644 index 000000000..deadc44dd --- /dev/null +++ b/application/plugins/homemiddleadv/config.json @@ -0,0 +1,24 @@ +{ + "base":{ + "plugins":"homemiddleadv", + "name":"首页中间广告", + "logo":"\/static\/upload\/images\/plugins_homemiddleadv\/2019\/04\/22\/1555917416820968.jpg", + "author":"Devil", + "author_url":"https:\/\/shopxo.net\/", + "version":"1.0.0", + "desc":"首页中间广告,4个推荐位", + "apply_terminal":[ + "pc", + "h5" + ], + "apply_version":[ + "1.5.0" + ], + "is_home":false + }, + "hook":{ + "plugins_view_home_floor_top":[ + "app\\plugins\\homemiddleadv\\Hook" + ] + } +} \ No newline at end of file diff --git a/application/plugins/view/answers/admin/slider.html b/application/plugins/view/answers/admin/slider.html index 382002e0e..b360ac7f8 100644 --- a/application/plugins/view/answers/admin/slider.html +++ b/application/plugins/view/answers/admin/slider.html @@ -22,8 +22,8 @@ 名称 图片 url地址 - 是否启用 - 创建时间 + 是否启用 + 创建时间 操作 @@ -43,9 +43,9 @@ {{$v.url}} - - - {{$v.add_time_time}} + + + {{$v.add_time_time}} @@ -55,7 +55,7 @@ {{/foreach}} {{else /}} - 没有相关数据 + 没有相关数据 {{/if}} diff --git a/application/plugins/view/homemiddleadv/admin/dataindex.html b/application/plugins/view/homemiddleadv/admin/dataindex.html new file mode 100644 index 000000000..f65b16092 --- /dev/null +++ b/application/plugins/view/homemiddleadv/admin/dataindex.html @@ -0,0 +1,74 @@ +{{include file="public/header" /}} + + +
+
+ + 首页中间广告 + 返回 + + +
+ +
+ 新增 +
+ + + + + + + + + + + + + + + + + {{if !empty($data_list)}} + {{foreach $data_list as $v}} + + + + + + + + + + {{/foreach}} + {{else /}} + + {{/if}} + +
名称图片url地址是否新窗口打开是否启用操作时间操作
{{$v.name}} + {{if !empty($v['images_url'])}} + + + + {{else /}} + 暂无图片 + {{/if}} + {{$v.url}} + + + + {{$v.operation_time_time}} + + + + +
没有相关数据
+ +
+
+
+ + + +{{include file="public/footer" /}} + \ No newline at end of file diff --git a/application/plugins/view/homemiddleadv/admin/datainfo.html b/application/plugins/view/homemiddleadv/admin/datainfo.html new file mode 100644 index 000000000..69d3dfdea --- /dev/null +++ b/application/plugins/view/homemiddleadv/admin/datainfo.html @@ -0,0 +1,64 @@ +{{include file="public/header" /}} + + +
+
+ + + {{if empty($data['id'])}} + 首页中间广告添加 + {{else /}} + 首页中间广告编辑 + {{/if}} + + 返回 + + +
+ +
+
+ + +
+ +
+ + +
+ +
+ +
    +
  • + + +
  • +
+
+上传图片
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+ +
+
+
+ + + +{{include file="public/footer" /}} + \ No newline at end of file diff --git a/application/plugins/view/homemiddleadv/admin/index.html b/application/plugins/view/homemiddleadv/admin/index.html new file mode 100755 index 000000000..ade85988f --- /dev/null +++ b/application/plugins/view/homemiddleadv/admin/index.html @@ -0,0 +1,86 @@ +{{include file="public/header" /}} + + +
+
+ + 首页中间广告 + 返回 + + +
+ +
+
+ 基础数据 + 编辑 +
+
+
+ +
+ {{if empty($data['application_name'])}} + 未设置应用导航名称 + {{else /}} + {{$data.application_name}} + {{/if}} +
+
+ +
+ +
+ {{if empty($data['right_top_rec_name'])}} + 推荐问答 + {{else /}} + {{$data.right_top_rec_name}} + {{/if}} +
+
+ +
+ +
+ {{if empty($data['middle_new_name'])}} + 最新问答 + {{else /}} + {{$data.middle_new_name}} + {{/if}} +
+
+ +
+
+ + +
+
+ 广告图片 + 编辑 +
+
+ {{if !empty($data_list)}} + + {{else /}} + 没有数据 + {{/if}} +
+
+
+
+
+ + + +{{include file="public/footer" /}} + \ No newline at end of file diff --git a/application/plugins/view/homemiddleadv/admin/saveinfo.html b/application/plugins/view/homemiddleadv/admin/saveinfo.html new file mode 100755 index 000000000..fbaf34b2d --- /dev/null +++ b/application/plugins/view/homemiddleadv/admin/saveinfo.html @@ -0,0 +1,112 @@ +{{include file="public/header" /}} + + +
+
+ +
+ + 首页中间广告 + 返回 + + +
+
+ +
    +
  • + + +
  • +
+
+上传图片
+
+
+ + +
+
+ +
+
+ +
    +
  • + + +
  • +
+
+上传图片
+
+
+ + +
+
+ +
+
+ +
    +
  • + + +
  • +
+
+上传图片
+
+
+ + +
+
+ +
+
+ +
    +
  • + + +
  • +
+
+上传图片
+
+
+ + +
+
+ +
+ +
+ {{foreach $is_whether_list as $v}} + + {{/foreach}} +
+
+ +
+ +
+ + ~ + +
+
+ +
+ +
+
+ +
+
+ + + +{{include file="public/footer" /}} + \ No newline at end of file diff --git a/application/plugins/view/homemiddleadv/index/content.html b/application/plugins/view/homemiddleadv/index/content.html new file mode 100755 index 000000000..bae255c42 --- /dev/null +++ b/application/plugins/view/homemiddleadv/index/content.html @@ -0,0 +1,13 @@ +{{if !empty($data_list)}} + +{{/if}} \ No newline at end of file diff --git a/application/service/PluginsService.php b/application/service/PluginsService.php index ad8e826f7..d99691b9e 100755 --- a/application/service/PluginsService.php +++ b/application/service/PluginsService.php @@ -66,7 +66,7 @@ class PluginsService cache($key, $data); } } - return DataReturn('处理成功', 0, $data); + return DataReturn('处理成功', 0, empty($data) ? [] : $data); } /** diff --git a/application/tags.php b/application/tags.php index 4e5edac69..63f37a17a 100755 --- a/application/tags.php +++ b/application/tags.php @@ -132,5 +132,9 @@ return array ( array ( 0 => 'app\\plugins\\share\\Hook', ), + 'plugins_view_home_floor_top' => + array ( + 0 => 'app\\plugins\\homemiddleadv\\Hook', + ), ); ?> \ No newline at end of file diff --git a/public/static/index/default/css/common.css b/public/static/index/default/css/common.css index 47075a774..77ac630e3 100755 --- a/public/static/index/default/css/common.css +++ b/public/static/index/default/css/common.css @@ -58,6 +58,8 @@ h5{float: right;color: #666;padding-right:20px;} input.add,input.min{width:15px} .c-p {cursor:pointer;} .last{border-right:none !important;} +.am-container { margin: 0 auto; } + /*选项卡样式定义*/ .am-nav-tabs,.am-tabs-bd{border-color:transparent ;} .am-nav-tabs > li.am-active > a, .am-nav-tabs > li.am-active > a:hover, .am-nav-tabs > li.am-active > a:focus,.am-nav-tabs > li > a:hover ,.am-nav-tabs > li > a:focus { @@ -432,9 +434,6 @@ background:url(../images/ibar_sprites.png) no-repeat;background-position:0px -23 .am-footer-default a { font-size: 12px; color: #b1b1b1; -} -.am-footer-default .am-container { - } .footer-nav-list { overflow: hidden; diff --git a/public/static/plugins/css/homemiddleadv/admin.css b/public/static/plugins/css/homemiddleadv/admin.css new file mode 100755 index 000000000..78a043567 --- /dev/null +++ b/public/static/plugins/css/homemiddleadv/admin.css @@ -0,0 +1,43 @@ +/** + * 首页 + */ +.homemiddleadv-content .items { + margin: 10px 0 20px 0; + border-bottom: 1px dashed #f1f1f1; + padding-bottom: 20px; +} +.homemiddleadv-content .items .immages-tag { + text-align: left; +} +.homemiddleadv-content .items .immages-tag img { + max-width: 100%; + border: 1px dashed #eee; + padding: 5px; +} +.homemiddleadv-content .edit-submit { + margin-bottom: 20px; +} +.homemiddleadv-content img { + max-width: 100%; +} +.homemiddleadv-content .am-slider-c3 .am-slider-counter { + background-color: #d13a49; +} +@media only screen and (min-width:640px) { + .homemiddleadv-data-list .am-gallery-overlay .am-gallery-item img { + width: auto; + max-height: 150px; + } +} + +@media only screen and (max-width:640px) { + +} + + +/** + * 幻灯片编辑 + */ +ul.plug-file-upload-view li { + width: 300px; +} \ No newline at end of file diff --git a/public/static/plugins/css/homemiddleadv/index.html b/public/static/plugins/css/homemiddleadv/index.html new file mode 100755 index 000000000..0519ecba6 --- /dev/null +++ b/public/static/plugins/css/homemiddleadv/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/static/plugins/images/homemiddleadv/default-images.jpg b/public/static/plugins/images/homemiddleadv/default-images.jpg new file mode 100644 index 000000000..c3eb8295d Binary files /dev/null and b/public/static/plugins/images/homemiddleadv/default-images.jpg differ diff --git a/public/static/plugins/images/homemiddleadv/index.html b/public/static/plugins/images/homemiddleadv/index.html new file mode 100755 index 000000000..0519ecba6 --- /dev/null +++ b/public/static/plugins/images/homemiddleadv/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/static/upload/images/plugins_homemiddleadv/2019/04/22/1555917416820968.jpg b/public/static/upload/images/plugins_homemiddleadv/2019/04/22/1555917416820968.jpg new file mode 100644 index 000000000..aadc09fbb Binary files /dev/null and b/public/static/upload/images/plugins_homemiddleadv/2019/04/22/1555917416820968.jpg differ