提交 00837624 编写于 作者: D devil_gong

商品新增seo

上级 cf411547
......@@ -36,6 +36,9 @@
<li>
<a href="#goods-nav-web">电脑端详情</a>
</li>
<li>
<a href="#goods-nav-seo">SEO</a>
</li>
</ul>
</nav>
......@@ -362,6 +365,19 @@
</div>
</div>
<!-- seo -->
<div id="goods-nav-seo" class="division-block">
<label class="block nav-detail-title">SEO</label>
<div class="am-form-group">
<label>SEO关键字<span class="am-form-group-label-tips">一般不超过100个字符,多个关键字以半圆角逗号 [ , ] 隔开</span></label>
<input type="text" name="seo_keywords" placeholder="SEO关键字" maxlength="130" data-validation-message="SEO关键字格式 最多130个字符" class="am-radius" {{if !empty($data)}} value="{{$data.seo_keywords}}"{{/if}} />
</div>
<div class="am-form-group">
<label>SEO描述<span class="am-form-group-label-tips">一般不超过200个字符</span></label>
<textarea rows="4" name="seo_desc" maxlength="230" class="am-radius" placeholder="SEO描述" data-validation-message="SEO描述格式 最多230个字符">{{if !empty($data)}}{{$data.seo_desc}}{{/if}}</textarea>
</div>
</div>
<div class="am-form-group am-form-group-refreshing">
<input type="hidden" name="id" {{if !empty($data)}} value="{{$data.id}}"{{/if}} />
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm w100" data-am-loading="{loadingText:'处理中...'}">保存</button>
......
......@@ -245,8 +245,10 @@ class Common extends Controller
// 图片host地址
$this->assign('attachment_host', config('shopxo.attachment_host'));
// 标题
// seo
$this->assign('home_seo_site_title', MyC('home_seo_site_title'));
$this->assign('home_seo_site_keywords', MyC('home_seo_site_keywords'));
$this->assign('home_seo_site_description', MyC('home_seo_site_description'));
// 页面最大宽度
$max_width = MyC('home_content_max_width', 0, true);
......
......@@ -76,8 +76,16 @@ class Goods extends Common
// 商品数据
$this->assign('goods', $ret['data'][0]);
// 浏览器名称
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($ret['data'][0]['title']));
// seo
$this->assign('home_seo_site_title', SeoService::BrowserSeoTitle($ret['data'][0]['title'], 2));
if(!empty($ret['data'][0]['seo_keywords']))
{
$this->assign('home_seo_site_keywords', SeoService::BrowserSeoTitle($ret['data'][0]['seo_keywords'], 2));
}
if(!empty($ret['data'][0]['seo_desc']))
{
$this->assign('home_seo_site_description', SeoService::BrowserSeoTitle($ret['data'][0]['seo_desc'], 2));
}
// 二维码
$this->assign('qrcode_url', MyUrl('index/qrcode/index', ['content'=>urlencode(base64_encode(MyUrl('index/goods/index', ['id'=>$id], true, true)))]));
......
......@@ -3,8 +3,8 @@
<head>
<meta charset="{{:config('shopxo.default_charset', 'utf-8')}}" />
<title>{{$home_seo_site_title}}</title>
<meta name="keywords" content="{{:MyC('home_seo_site_keywords')}}" />
<meta name="description" content="{{:MyC('home_seo_site_description')}}" />
<meta name="keywords" content="{{$home_seo_site_keywords}}" />
<meta name="description" content="{{$home_seo_site_description}}" />
<meta name="generator" content="{{:__MY_URL__}}" />
<meta name="application-name" content="{{$home_seo_site_title}}" />
<meta name="msapplication-tooltip" content="{{$home_seo_site_title}}" />
......
......@@ -1012,6 +1012,20 @@ class GoodsService
'key_name' => 'buy_min_number',
'error_msg' => '请填写有效的最低起购数量',
],
[
'checked_type' => 'length',
'key_name' => 'seo_keywords',
'checked_data' => '130',
'is_checked' => 1,
'error_msg' => 'SEO关键字格式 最多130个字符',
],
[
'checked_type' => 'length',
'key_name' => 'seo_desc',
'checked_data' => '230',
'is_checked' => 1,
'error_msg' => 'SEO描述格式 最多230个字符',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
......@@ -1070,6 +1084,8 @@ class GoodsService
'home_recommended_images' => $attachment['data']['home_recommended_images'],
'brand_id' => isset($params['brand_id']) ? intval($params['brand_id']) : 0,
'video' => $attachment['data']['video'],
'seo_keywords' => empty($params['seo_keywords']) ? '' : $params['seo_keywords'],
'seo_desc' => empty($params['seo_desc']) ? '' : $params['seo_desc'],
];
// 启动事务
......
......@@ -27,7 +27,7 @@ class SeoService
* @date 2019-03-11
* @desc description
* @param [string] $title [标题]
* @param [int] $type [模式0 使用站点名称, 模式1 使用SEO名称]
* @param [int] $type [模式0 使用站点名称, 模式1 使用SEO名称, 模式2 标题, ]
* @return [string] [浏览器seo标题]
*/
public static function BrowserSeoTitle($title, $type = 0)
......@@ -41,15 +41,21 @@ class SeoService
// 模式
switch($type)
{
// 模式0 使用站点名称
case 0 :
return $title.' - '.MyC('home_site_name');
break;
// 模式1 或 默认使用标题加seo名称
case 1 :
default :
return $title.' - '.MyC('home_seo_site_title');
break;
// 模式2 或 默认使用标题加seo名称
case 2 :
return $title;
break;
// 模式0 使用站点名称
// 默认标题
case 0 :
default :
return $title.' - '.MyC('home_site_name');
}
}
}
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册