From d8f9eaf90fb476a3f64302c3fdc40278aa60a606 Mon Sep 17 00:00:00 2001 From: devil_gong Date: Mon, 11 Mar 2019 17:57:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E7=AD=94=E7=B3=BB=E7=BB=9F=E5=A2=9E?= =?UTF-8?q?=E5=BC=BA=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Answer.php | 3 + .../admin/view/default/answer/index.html | 42 ++++++- application/index/controller/Article.php | 3 +- application/index/controller/Category.php | 5 + application/index/controller/Common.php | 29 +---- application/index/controller/Customview.php | 3 +- application/index/controller/Goods.php | 6 +- application/index/controller/Search.php | 4 + application/index/controller/User.php | 22 ++++ application/plugins/answers/Hook.php | 26 +++- application/plugins/answers/Index.php | 89 +++++++++++++ application/plugins/answers/Service.php | 30 +++-- application/plugins/answers/config.json | 8 +- .../plugins/view/answers/admin/baseinfo.html | 17 ++- .../plugins/view/answers/admin/index.html | 11 ++ .../view/answers/admin/sliderinfo.html | 2 +- .../plugins/view/answers/index/detail.html | 11 +- .../plugins/view/answers/index/index.html | 33 ++--- .../plugins/view/answers/index/operation.html | 17 +++ .../plugins/view/answers/index/search.html | 117 ++++++++++++++++++ .../view/commongobacktop/admin/saveinfo.html | 4 +- .../commononlineservice/admin/saveinfo.html | 6 +- .../commonrightnavigation/admin/saveinfo.html | 10 +- .../commontopmaxpicture/admin/saveinfo.html | 8 +- .../view/commontopnotice/admin/saveinfo.html | 6 +- .../usercentertopnotice/admin/saveinfo.html | 4 +- .../admin/saveinfo.html | 4 +- .../admin/index.html | 2 +- .../admin/saveinfo.html | 2 +- application/service/AnswerService.php | 2 +- application/service/NavigationService.php | 34 ++++- application/service/SeoService.php | 56 +++++++++ application/tags.php | 4 + public/static/admin/default/css/answer.css | 7 +- .../static/admin/default/css/pluginsadmin.css | 2 +- public/static/common/css/common.css | 3 +- public/static/index/default/css/common.css | 11 +- public/static/plugins/css/answers/index.css | 56 +++++---- route/route.config | 3 - 39 files changed, 564 insertions(+), 138 deletions(-) create mode 100644 application/plugins/view/answers/index/operation.html create mode 100644 application/plugins/view/answers/index/search.html create mode 100644 application/service/SeoService.php diff --git a/application/admin/controller/Answer.php b/application/admin/controller/Answer.php index 67a3f0065..c1946c450 100755 --- a/application/admin/controller/Answer.php +++ b/application/admin/controller/Answer.php @@ -84,6 +84,9 @@ class Answer extends Common // 状态 $this->assign('common_is_show_list', lang('common_is_show_list')); + // 是否 + $this->assign('common_is_text_list', lang('common_is_text_list')); + // 参数 $this->assign('params', $params); return $this->fetch(); diff --git a/application/admin/view/default/answer/index.html b/application/admin/view/default/answer/index.html index c270f2c02..1f9c9e5d7 100755 --- a/application/admin/view/default/answer/index.html +++ b/application/admin/view/default/answer/index.html @@ -21,6 +21,14 @@ {{/foreach}} +
~ @@ -37,10 +45,12 @@ 用户信息 联系信息 - 内容 - 是否显示 + 标题 + 内容 回复内容 + 回复时间 创建时间 + 是否显示 更多 操作 @@ -79,12 +89,20 @@ 未填写 {{/if}} - {{$v.content}} + {{$v.title}} + {{$v.content}} + + {{if $v['is_reply'] eq 1}} + {{$v.reply}} + {{else /}} + 未回复 + {{/if}} + + {{$v.reply_time}} + {{$v.add_time}} - {{$v.reply}} - {{$v.add_time}} 查看更多
@@ -130,6 +148,9 @@ {{/if}} +
标题
+
{{if empty($v['title'])}}未填写{{else /}}{{$v.title}}{{/if}}
+
内容
{{$v.content}}
@@ -137,7 +158,16 @@
{{if empty($v['is_show_text'])}}未填写{{else /}}{{$v.is_show_text}}{{/if}}
回复内容
-
{{if empty($v['reply'])}}未填写{{else /}}{{$v.reply}}{{/if}}
+
+ {{if $v['is_reply'] eq 1}} + {{$v.reply}} + {{else /}} + 未回复 + {{/if}} +
+ +
回复时间
+
{{$v.reply_time}}
创建时间
{{$v.add_time}}
diff --git a/application/index/controller/Article.php b/application/index/controller/Article.php index 617ade41b..754e616f9 100755 --- a/application/index/controller/Article.php +++ b/application/index/controller/Article.php @@ -11,6 +11,7 @@ namespace app\index\controller; use app\service\ArticleService; +use app\service\SeoService; /** * 文章详情 @@ -64,7 +65,7 @@ class Article extends Common } // 浏览器标题 - $this->assign('home_seo_site_title', $this->GetBrowserSeoTitle($article['data'][0]['title'], 1)); + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($article['data'][0]['title'])); // 获取分类和文字 $article_category_content = ArticleService::ArticleCategoryListContent(); diff --git a/application/index/controller/Category.php b/application/index/controller/Category.php index fe46204ba..e12ce71b5 100755 --- a/application/index/controller/Category.php +++ b/application/index/controller/Category.php @@ -10,6 +10,8 @@ // +---------------------------------------------------------------------- namespace app\index\controller; +use app\service\SeoService; + /** * 商品分类 * @author Devil @@ -41,6 +43,9 @@ class Category extends Common */ public function Index() { + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('商品分类', 1)); + return $this->fetch(); } } diff --git a/application/index/controller/Common.php b/application/index/controller/Common.php index 613c887b3..74d7fdc34 100755 --- a/application/index/controller/Common.php +++ b/application/index/controller/Common.php @@ -255,38 +255,11 @@ class Common extends Controller */ private function NavInit() { - $navigation = NavigationService::Home(); + $navigation = NavigationService::Nav(); $this->nav_header = $navigation['header']; $this->nav_footer = $navigation['footer']; } - /** - * [GetBrowserSeoTitle 获取浏览器seo标题] - * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2017-02-25T14:21:21+0800 - * @param [string] $title [标题] - * @param [int] $type [页面类型 0, 1, 2] - * @return [string] [浏览器seo标题] - */ - protected function GetBrowserSeoTitle($title, $type) - { - switch($type) - { - case 0: - break; - - case 1: - $site_name = MyC('home_site_name'); - break; - - default: - $site_name = MyC('home_seo_site_title'); - } - return empty($title) ? $site_name : $title.' - '.$site_name; - } - /** * [_empty 空方法操作] * @author Devil diff --git a/application/index/controller/Customview.php b/application/index/controller/Customview.php index 5387e4914..532811110 100755 --- a/application/index/controller/Customview.php +++ b/application/index/controller/Customview.php @@ -11,6 +11,7 @@ namespace app\index\controller; use app\service\CustomViewService; +use app\service\SeoService; /** * 自定义页面 @@ -58,7 +59,7 @@ class CustomView extends Common CustomViewService::CustomViewAccessCountInc(['id'=>$id]); // 浏览器标题 - $this->assign('home_seo_site_title', $this->GetBrowserSeoTitle($data['data'][0]['title'], 1)); + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($data['data'][0]['title'])); $this->assign('data', $data['data'][0]); $this->assign('is_header', $data['data'][0]['is_header']); diff --git a/application/index/controller/Goods.php b/application/index/controller/Goods.php index 1e68569d1..ddb2da5bc 100755 --- a/application/index/controller/Goods.php +++ b/application/index/controller/Goods.php @@ -11,6 +11,7 @@ namespace app\index\controller; use app\service\GoodsService; +use app\service\SeoService; /** * 商品详情 @@ -68,8 +69,11 @@ class Goods extends Common // 商品收藏总数 $ret['data'][0]['favor_count'] = GoodsService::GoodsFavorTotal(['goods_id'=>$id]); + // 商品数据 $this->assign('goods', $ret['data'][0]); - $this->assign('home_seo_site_title', $ret['data'][0]['title']); + + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($ret['data'][0]['title'])); // 二维码 $this->assign('qrcode_url', MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode(MyUrl('index/goods/index', ['id'=>$id], true, true)))])); diff --git a/application/index/controller/Search.php b/application/index/controller/Search.php index 252260bc6..12bb426cd 100755 --- a/application/index/controller/Search.php +++ b/application/index/controller/Search.php @@ -12,6 +12,7 @@ namespace app\index\controller; use app\service\SearchService; use app\service\BrandService; +use app\service\SeoService; /** * 搜索 @@ -82,6 +83,9 @@ class Search extends Common // 参数 $this->assign('params', $this->params); + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('商品搜索', 1)); + return $this->fetch(); } } diff --git a/application/index/controller/User.php b/application/index/controller/User.php index 768f14ce9..a68ed8f8e 100755 --- a/application/index/controller/User.php +++ b/application/index/controller/User.php @@ -15,6 +15,7 @@ use app\service\OrderService; use app\service\GoodsService; use app\service\UserService; use app\service\BuyService; +use app\service\SeoService; /** * 用户 @@ -139,6 +140,9 @@ class User extends Common // 用户中心顶部钩子 $this->assign('plugins_view_user_center_top_data', Hook::listen('plugins_view_user_center_top', ['hook_name'=>'plugins_view_user_center_top', 'is_backend'=>false, 'user'=>$this->user])); + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('用户中心', 1)); + return $this->fetch(); } @@ -153,6 +157,9 @@ class User extends Common { if(empty($this->user)) { + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('密码找回', 1)); + return $this->fetch(); } else { $this->assign('msg', '已经登录了,如要重置密码,请先退出当前账户'); @@ -174,6 +181,9 @@ class User extends Common { if(empty($this->user)) { + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('用户注册', 1)); + return $this->fetch(); } else { $this->assign('msg', '已经登录了,如要注册新账户,请先退出当前账户'); @@ -198,6 +208,9 @@ class User extends Common { if(empty($this->user)) { + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('用户邮箱注册', 1)); + $this->assign('referer_url', $this->GetrefererUrl()); return $this->fetch(); } else { @@ -223,6 +236,9 @@ class User extends Common { if(empty($this->user)) { + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('用户短信注册', 1)); + $this->assign('referer_url', $this->GetrefererUrl()); return $this->fetch(); } else { @@ -248,6 +264,9 @@ class User extends Common { if(empty($this->user)) { + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('用户登录', 1)); + $this->assign('referer_url', $this->GetrefererUrl()); return $this->fetch(); } else { @@ -277,6 +296,9 @@ class User extends Common { if(empty($this->user)) { + // 浏览器名称 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('用户登录', 1)); + $this->assign('referer_url', $this->GetrefererUrl()); return $this->fetch(); } else { diff --git a/application/plugins/answers/Hook.php b/application/plugins/answers/Hook.php index 2fa9566ca..d4e8ac633 100644 --- a/application/plugins/answers/Hook.php +++ b/application/plugins/answers/Hook.php @@ -11,6 +11,7 @@ namespace app\plugins\answers; use think\Controller; +use app\service\PluginsService; /** * 问答 - 钩子入口 @@ -36,8 +37,31 @@ class Hook extends Controller // 默认返回视图 } else { - return 'hello world!'; + // 大导航前面添加问答地址 + if(!empty($params['hook_name']) && $params['hook_name'] == 'plugins_service_navigation_header_handle') + { + if(is_array($params['header'])) + { + // 获取应用数据 + $ret = PluginsService::PluginsData('answers', ['images']); + if($ret['code'] == 0 && !empty($ret['data']['application_name'])) + { + $nav = [ + 'id' => 0, + 'pid' => 0, + 'name' => $ret['data']['application_name'], + 'url' => PluginsHomeUrl('answers', 'index', 'index'), + 'data_type' => 'custom', + 'is_show' => 1, + 'is_new_window_open' => 0, + 'items' => [], + ]; + array_unshift($params['header'], $nav); + } + } + } } + return DataReturn('无需处理', 0); } } ?> \ No newline at end of file diff --git a/application/plugins/answers/Index.php b/application/plugins/answers/Index.php index 621e4a329..9d8a49a56 100644 --- a/application/plugins/answers/Index.php +++ b/application/plugins/answers/Index.php @@ -14,6 +14,7 @@ use think\Controller; use app\service\PluginsService; use app\service\AnswerService; use app\service\UserService; +use app\service\SeoService; use app\plugins\answers\Service; /** @@ -65,6 +66,10 @@ class Index extends Controller $this->assign('plugins_answers_rc_list', []); } + // 浏览器标题 + $seo_name = empty($base['data']['application_name']) ? '问答' : $base['data']['application_name']; + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($seo_name, 1)); + return $this->fetch('../../../plugins/view/answers/index/index'); } @@ -100,9 +105,93 @@ class Index extends Controller $detail = Service::AnswerRow($params); $this->assign('plugins_answers_detail', $detail); + // 浏览器标题 + if(!empty($detail['data']['title'])) + { + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($detail['data']['title'])); + } else if(!empty($detail['data']['content'])) + { + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($detail['data']['content'])); + } + return $this->fetch('../../../plugins/view/answers/index/detail'); } + /** + * 搜索 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-03-11 + * @desc description + * @param [array] $params [输入参数] + */ + public function search($params = []) + { + if(input('post.answers_keywords')) + { + $answers_keywords = str_replace(['?', ' ', '+', '-'], '', trim(input('post.answers_keywords'))); + return redirect(PluginsHomeUrl('answers', 'index', 'search', ['answers_keywords'=>$answers_keywords])); + } else { + // 基础数据 + $base = PluginsService::PluginsData('answers', ['images']); + $this->assign('plugins_answers_data', isset($base['data']) ? $base['data'] : []); + + // 商品数据 + $goods = Service::GoodsList(); + $this->assign('plugins_answers_goods_list', $goods['data']['goods']); + + // 推荐问答 + if(!empty($base['data']['category_ids'])) + { + $answers = Service::AnswerList(['n'=>100, 'category_ids'=> $base['data']['category_ids']]); + $this->assign('plugins_answers_rc_list', $answers['data']); + } else { + $this->assign('plugins_answers_rc_list', []); + } + + // 获取搜索数据 + // 分页 + $number = 10; + + // 条件 + $keywords_arr = empty($params['answers_keywords']) ? [] : ['keywords'=>$params['answers_keywords']]; + $where = Service::AnswerListWhere(array_merge($params, $keywords_arr)); + + // 获取总数 + $total = AnswerService::AnswerTotal($where); + + // 分页 + $page_params = array( + 'number' => $number, + 'total' => $total, + 'where' => $params, + 'page' => isset($params['page']) ? intval($params['page']) : 1, + 'url' => PluginsHomeUrl('answers', 'index', 'search'), + ); + $page = new \base\Page($page_params); + $this->assign('page_html', $page->GetPageHtml()); + + // 获取列表 + $data_params = array( + 'm' => $page->GetPageStarNumber(), + 'n' => $number, + 'where' => $where, + 'field' => 'id,title,content,add_time', + ); + $data = AnswerService::AnswerList($data_params); + $this->assign('plugins_answers_data_list', $data['data']); + + // 参数 + $this->assign('params', $params); + + // 浏览器标题 + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('问答搜索', 1)); + + return $this->fetch('../../../plugins/view/answers/index/search'); + } + } + /** * 提问 * @author Devil diff --git a/application/plugins/answers/Service.php b/application/plugins/answers/Service.php index e62f6c55e..10adc5cbe 100644 --- a/application/plugins/answers/Service.php +++ b/application/plugins/answers/Service.php @@ -310,14 +310,15 @@ class Service } /** - * 问答列表 + * 条件 * @author Devil - * @blog http://gong.gg/ - * @version 0.0.1 - * @datetime 2016-12-06T21:31:53+0800 - * @param [array] $params [输入参数] + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2019-03-11 + * @desc description + * @param [array] $params [输入参数] */ - public static function AnswerList($params = []) + public static function AnswerListWhere($params = []) { // 条件 $where = [ @@ -328,7 +329,7 @@ class Service // 搜索关键字 if(!empty($params['keywords'])) { - $where[] = ['content', 'like', '%'.$params['keywords'].'%']; + $where[] = ['title|content', 'like', '%'.$params['keywords'].'%']; } // 指定问答id @@ -337,6 +338,19 @@ class Service $where[] = ['id', 'in', explode(',', $params['category_ids'])]; } + return $where; + } + + /** + * 问答列表 + * @author Devil + * @blog http://gong.gg/ + * @version 0.0.1 + * @datetime 2016-12-06T21:31:53+0800 + * @param [array] $params [输入参数] + */ + public static function AnswerList($params = []) + { // 字段 $field = empty($params['field']) ? 'id,name,title,content,reply,is_reply,reply_time,add_time' : $params['field']; @@ -344,7 +358,7 @@ class Service $data_params = array( 'm' => 0, 'n' => isset($params['n']) ? intval($params['n']) : 10, - 'where' => $where, + 'where' => self::AnswerListWhere($params), 'field' => $field, ); return AnswerService::AnswerList($data_params); diff --git a/application/plugins/answers/config.json b/application/plugins/answers/config.json index a73d7f7cd..aee1534c9 100644 --- a/application/plugins/answers/config.json +++ b/application/plugins/answers/config.json @@ -1,12 +1,12 @@ { "base":{ "plugins":"answers", - "name":"问答", + "name":"问答增强版", "logo":"\/static\/upload\/images\/plugins_answers\/2019\/03\/06\/1551853529634743.png", "author":"Devil", "author_url":"https:\/\/shopxo.net\/", "version":"1.0.0", - "desc":"问答系统", + "desc":"问答系统增强、独立首页、详情、搜索、可配置推荐问答及商品", "apply_terminal":[ "pc", "h5" @@ -17,6 +17,8 @@ "is_home":true }, "hook":{ - + "plugins_service_navigation_header_handle":[ + "app\\plugins\\answers\\Hook" + ] } } \ No newline at end of file diff --git a/application/plugins/view/answers/admin/baseinfo.html b/application/plugins/view/answers/admin/baseinfo.html index 38480c36b..308e06056 100755 --- a/application/plugins/view/answers/admin/baseinfo.html +++ b/application/plugins/view/answers/admin/baseinfo.html @@ -10,8 +10,13 @@ 返回 +
+ + +
+
- +
    {{if !empty($data['images_old'])}}
  • @@ -25,7 +30,7 @@
- +
@@ -41,22 +46,22 @@
- +
- +
- +
- +
diff --git a/application/plugins/view/answers/admin/index.html b/application/plugins/view/answers/admin/index.html index 287c6c091..a8b9a5dfc 100644 --- a/application/plugins/view/answers/admin/index.html +++ b/application/plugins/view/answers/admin/index.html @@ -16,6 +16,17 @@ 编辑
+
+ +
+ {{if empty($data['application_name'])}} + 未设置应用导航名称 + {{else /}} + {{$data.application_name}} + {{/if}} +
+
+
diff --git a/application/plugins/view/answers/admin/sliderinfo.html b/application/plugins/view/answers/admin/sliderinfo.html index 10f9e5c45..0d2f6f03a 100644 --- a/application/plugins/view/answers/admin/sliderinfo.html +++ b/application/plugins/view/answers/admin/sliderinfo.html @@ -23,7 +23,7 @@
- +
diff --git a/application/plugins/view/answers/index/detail.html b/application/plugins/view/answers/index/detail.html index cfef4c142..d4a96fc74 100644 --- a/application/plugins/view/answers/index/detail.html +++ b/application/plugins/view/answers/index/detail.html @@ -14,7 +14,7 @@
- +
{{if isset($plugins_answers_detail['code']) and $plugins_answers_detail['code'] eq 0}} {{if !empty($plugins_answers_detail['data']['content'])}} @@ -46,11 +46,8 @@
- - + + {{include file="../../../plugins/view/answers/index/operation" /}}
@@ -62,6 +59,7 @@ {{$plugins_answers_data.right_top_rec_name}} {{/if}} + 更多 »
{{if !empty($plugins_answers_rc_list)}} @@ -93,6 +91,7 @@ {{$plugins_answers_data.right_top_goods_name}} {{/if}} + 更多 »
{{if !empty($plugins_answers_goods_list)}}
@@ -39,11 +40,8 @@
- - + + {{include file="../../../plugins/view/answers/index/operation" /}}
@@ -55,6 +53,7 @@ {{$plugins_answers_data.right_top_rec_name}} {{/if}} + 更多 »
{{if !empty($plugins_answers_rc_list)}} @@ -89,7 +88,7 @@
-
+

{{if empty($plugins_answers_data['middle_new_name'])}} @@ -98,20 +97,21 @@ {{$plugins_answers_data.middle_new_name}} {{/if}}

+ 更多 »
{{if !empty($plugins_answers_middle_answer_list)}} @@ -132,6 +132,7 @@ {{$plugins_answers_data.right_top_goods_name}} {{/if}} + 更多 »
{{if !empty($plugins_answers_goods_list)}}