Merge branch 'dev' of https://gitea.f2b211.com/jsasg/orico-official-website into dev
This commit is contained in:
@@ -226,18 +226,18 @@ if (!function_exists('get_platform')) {
|
|||||||
if (!function_exists('highlight_keywords')) {
|
if (!function_exists('highlight_keywords')) {
|
||||||
/**
|
/**
|
||||||
* 高亮关键词
|
* 高亮关键词
|
||||||
* @param string $item
|
* @param string $text // 要处理的文本
|
||||||
* @param string $keywords
|
* @param string $keyword // 关键词
|
||||||
* @param array $class
|
* @param string|callable $repalce // 替换函数或字符串
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function highlight_keywords(string $text, string $keywords, array $class=[]): string
|
function highlight_keywords(string $text, string $keyword, string|callable $replace): string
|
||||||
{
|
{
|
||||||
return preg_replace_callback('/' . preg_quote($keywords, '/') . '+/i', function($match) use($text, $class) {
|
return preg_replace_callback('/' . preg_quote($keyword, '/') . '+/i', function($match) use($text, $replace) {
|
||||||
if (empty($match)) {
|
if (empty($match)) return $text;
|
||||||
return $text;
|
if (is_string($replace)) return '<strong>' . $match[0] . '</strong>';
|
||||||
}
|
if (is_callable($replace)) return $replace($match[0]);
|
||||||
return '<strong class="' . implode(' ', $class) . '">' . $match[0] . '</strong>';
|
return $match[0];
|
||||||
}, $text);
|
}, $text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,9 +170,9 @@ class Article extends Common
|
|||||||
]);
|
]);
|
||||||
$ret = ArticleLeaveMessageModel::create($data);
|
$ret = ArticleLeaveMessageModel::create($data);
|
||||||
if ($ret->isEmpty()) {
|
if ($ret->isEmpty()) {
|
||||||
return error(lang('留言提交失败'));
|
return error(lang('信息提交失败!'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return success(lang('留言提交成功'));
|
return success(lang('信息已成功提交!'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -299,9 +299,10 @@ class Product extends Common
|
|||||||
'query' => request()->param()
|
'query' => request()->param()
|
||||||
])
|
])
|
||||||
->each(function ($item) use($keywords) {
|
->each(function ($item) use($keywords) {
|
||||||
$item['spu'] = highlight_keywords($item['spu'], $keywords, ['redpoint']);
|
$replace = fn($txt) => '<strong class="redpoint">' . $txt . '</strong>';
|
||||||
$item['name'] = highlight_keywords($item['name'], $keywords, ['redpoint']);
|
$item['spu'] = highlight_keywords($item['spu'], $keywords, $replace);
|
||||||
$item['short_name'] = highlight_keywords($item['short_name'], $keywords, ['redpoint']);
|
$item['name'] = highlight_keywords($item['name'], $keywords, $replace);
|
||||||
|
$item['short_name'] = highlight_keywords($item['short_name'], $keywords, $replace);
|
||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
View::assign('products', $products);
|
View::assign('products', $products);
|
||||||
|
|||||||
@@ -37,6 +37,13 @@
|
|||||||
<img src="{$photo}" alt="" />
|
<img src="{$photo}" alt="" />
|
||||||
</div>
|
</div>
|
||||||
{/volist}
|
{/volist}
|
||||||
|
{if condition="!empty($product.video_img) && !empty($product.video_url) && $idx == 1"}
|
||||||
|
<div class="swiper-slide">
|
||||||
|
<video poster="{$product.video_img}" autoplay="autoplay" muted="muted" loop="loop" id="video" controls>
|
||||||
|
<source src="{$product.video_url}" type="video/mp4"/>
|
||||||
|
</video>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<!-- 如果需要分页器 -->
|
<!-- 如果需要分页器 -->
|
||||||
<div class="swiper-pagination"></div>
|
<div class="swiper-pagination"></div>
|
||||||
|
|||||||
@@ -15,19 +15,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- 顶部菜单-->
|
<!-- 顶部菜单-->
|
||||||
<div class="top-menu">
|
<div class="top-menu">
|
||||||
<div class="it-ct">
|
|
||||||
<div class="it-1"><a href="/">{:lang_i18n('首页')}</a></div>
|
|
||||||
</div>
|
|
||||||
<div class="it-ct">
|
|
||||||
<div class="it-1">
|
|
||||||
<div class="it-1-more">{:lang_i18n('产品列表')}<i class="icon-arrow"></i></div>
|
|
||||||
{notempty name="header_categorys"}
|
|
||||||
{volist name="header_categorys" id="ca"}
|
|
||||||
<div class="it-1-2"><a href="{:url('product/category', ['id' => $ca.id])}">{$ca.name}</a></div>
|
|
||||||
{/volist}
|
|
||||||
{/notempty}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{notempty name="header_navigation"}
|
{notempty name="header_navigation"}
|
||||||
{volist name="header_navigation" id="nav"}
|
{volist name="header_navigation" id="nav"}
|
||||||
<div class="it-ct">
|
<div class="it-ct">
|
||||||
|
|||||||
@@ -37,13 +37,13 @@
|
|||||||
<!-- 小图片预览 -->
|
<!-- 小图片预览 -->
|
||||||
<div id="imageMenu">
|
<div id="imageMenu">
|
||||||
<ul class="image_list">
|
<ul class="image_list">
|
||||||
|
{volist name="sku.photo_album" id="photo"}
|
||||||
|
<li id="onlickImg"><img src="{:thumb($photo)}" data-url="{$photo}" /></li>
|
||||||
|
{/volist}
|
||||||
{if condition="!empty($product.video_img) && !empty($product.video_url) && $idx == 1"}
|
{if condition="!empty($product.video_img) && !empty($product.video_url) && $idx == 1"}
|
||||||
<!-- 产品视频 -->
|
<!-- 产品视频 -->
|
||||||
<li id="onlickImg"><img src="{:thumb($product.video_img)}" data-url="{$product.video_url}" /></li>
|
<li id="onlickImg"><img src="{:thumb($product.video_img)}" data-url="{$product.video_url}" /></li>
|
||||||
{/if}
|
{/if}
|
||||||
{volist name="sku.photo_album" id="photo"}
|
|
||||||
<li id="onlickImg"><img src="{:thumb($photo)}" data-url="{$photo}" /></li>
|
|
||||||
{/volist}
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<!-- 右边切换按钮 -->
|
<!-- 右边切换按钮 -->
|
||||||
@@ -52,16 +52,9 @@
|
|||||||
<!-- 产品大图 -->
|
<!-- 产品大图 -->
|
||||||
<div class="bigImg" id="vertical">
|
<div class="bigImg" id="vertical">
|
||||||
<!-- 主图 -->
|
<!-- 主图 -->
|
||||||
{if condition="!empty($product.video_img) && !empty($product.video_url) && $idx == 1"}
|
|
||||||
<!-- 如果有视频情况下默认先显示视频 -->
|
|
||||||
<video poster="{$product.video_img}" autoplay="autoplay" muted="muted" loop="loop" id="video" controls style="width: 510px;height: 510px; position: relative;z-index: 998;">
|
|
||||||
<source src="{$product.video_url}" type="video/mp4"/>
|
|
||||||
</video>
|
|
||||||
{else/}
|
|
||||||
{notempty name="sku.photo_album[0]"}
|
{notempty name="sku.photo_album[0]"}
|
||||||
<img src="{$sku.photo_album[0]}" id="midimg" />
|
<img src="{$sku.photo_album[0]}" id="midimg" />
|
||||||
{/notempty}
|
{/notempty}
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/volist}
|
{/volist}
|
||||||
@@ -225,7 +218,7 @@
|
|||||||
<textarea name="message" id="message"></textarea>
|
<textarea name="message" id="message"></textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" id="send" class="submit-btn">{:lang_i18n('提交')}</button>
|
<button type="submit" class="submit-btn">{:lang_i18n('提交')}</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -273,21 +266,12 @@
|
|||||||
// 处理表单提交
|
// 处理表单提交
|
||||||
modal.find("form").submit(function(e) {
|
modal.find("form").submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
var form = $(this)
|
||||||
var formData = $(this).serialize();
|
var formData = $(this).serialize();
|
||||||
// 这里可以添加代码将formData发送到服务器
|
|
||||||
// 例如通过AJAX
|
|
||||||
console.log("提交的数据: " + formData);
|
|
||||||
// 提交成功后可以选择关闭模态框
|
|
||||||
modal.hide();
|
|
||||||
});
|
|
||||||
|
|
||||||
// 提交询盘
|
|
||||||
$('#send').click(function() {
|
|
||||||
var form = $(this).parents('form');
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "{:url('product/inquiry')}",
|
url: "{:url('product/inquiry')}",
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: form.serialize(),
|
data: formData,
|
||||||
success: function(r) {
|
success: function(r) {
|
||||||
if (r.code == 0) {
|
if (r.code == 0) {
|
||||||
form[0].reset(); // 重置表单
|
form[0].reset(); // 重置表单
|
||||||
@@ -297,6 +281,7 @@
|
|||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
modal.hide();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<!-- 搜索结果列表-->
|
<!-- 搜索结果列表-->
|
||||||
|
{notempty name="products"}
|
||||||
<ul class="seul">
|
<ul class="seul">
|
||||||
{volist name="products" id="pro"}
|
{volist name="products" id="pro"}
|
||||||
<a href="{:url('product/detail', ['id' => $pro['id']])}">
|
<a href="{:url('product/detail', ['id' => $pro['id']])}">
|
||||||
@@ -32,6 +33,10 @@
|
|||||||
</a>
|
</a>
|
||||||
{/volist}
|
{/volist}
|
||||||
</ul>
|
</ul>
|
||||||
|
<div>{$page|raw}</div>
|
||||||
|
{else/}
|
||||||
|
<div style="text-align: center; padding: 10%;">暂无数据</div>
|
||||||
|
{/notempty}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/block}
|
{/block}
|
||||||
@@ -17,9 +17,10 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
$('.headnav .navitem').each(function(idx, item) {
|
$('.headnav .navitem').each(function(idx, item) {
|
||||||
$(item).removeClass('hover');
|
var _item = $(item);
|
||||||
if (compareUrls(location.href, item.href)) {
|
_item.removeClass('hover');
|
||||||
$(item).addClass('hover').siblings();
|
if (_item.attr('href') && compareUrls(location.href, _item.get(0).href)) {
|
||||||
|
_item.addClass('hover').siblings();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class Product
|
|||||||
*/
|
*/
|
||||||
public function list()
|
public function list()
|
||||||
{
|
{
|
||||||
|
|
||||||
$params = request()->get([
|
$params = request()->get([
|
||||||
'category_id',
|
'category_id',
|
||||||
'language' => 'zh-cn',
|
'language' => 'zh-cn',
|
||||||
@@ -47,7 +48,7 @@ class Product
|
|||||||
->order(['sort' => 'asc', 'id' => 'desc'])
|
->order(['sort' => 'asc', 'id' => 'desc'])
|
||||||
->hidden(['category_id'])
|
->hidden(['category_id'])
|
||||||
->paginate([
|
->paginate([
|
||||||
'list_row' => $params['size'],
|
'list_rows' => $params['size'],
|
||||||
'page' => $params['page']
|
'page' => $params['page']
|
||||||
])
|
])
|
||||||
->each(function($item) {
|
->each(function($item) {
|
||||||
|
|||||||
@@ -103,3 +103,25 @@
|
|||||||
.orico_Page_search .searchMain ::placeholder {
|
.orico_Page_search .searchMain ::placeholder {
|
||||||
color: #737373;
|
color: #737373;
|
||||||
}
|
}
|
||||||
|
.orico_Page_search .searchMain .pagination {
|
||||||
|
zoom: 1;
|
||||||
|
text-align: center;
|
||||||
|
color: #555;
|
||||||
|
clear: both;
|
||||||
|
padding-bottom: 2rem;
|
||||||
|
}
|
||||||
|
.orico_Page_search .searchMain .pagination span {
|
||||||
|
padding: 0px 0px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.orico_Page_search .searchMain .pagination li {
|
||||||
|
display: inline-block;
|
||||||
|
width: 34px;
|
||||||
|
height: 22px;
|
||||||
|
line-height: 22px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.orico_Page_search .searchMain .pagination li.active {
|
||||||
|
background-color: #444444;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user