diff --git a/app/index/common.php b/app/index/common.php index 81d3df13..63d2a364 100644 --- a/app/index/common.php +++ b/app/index/common.php @@ -226,18 +226,18 @@ if (!function_exists('get_platform')) { if (!function_exists('highlight_keywords')) { /** * 高亮关键词 - * @param string $item - * @param string $keywords - * @param array $class + * @param string $text // 要处理的文本 + * @param string $keyword // 关键词 + * @param string|callable $repalce // 替换函数或字符串 * @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) { - if (empty($match)) { - return $text; - } - return '' . $match[0] . ''; + return preg_replace_callback('/' . preg_quote($keyword, '/') . '+/i', function($match) use($text, $replace) { + if (empty($match)) return $text; + if (is_string($replace)) return '' . $match[0] . ''; + if (is_callable($replace)) return $replace($match[0]); + return $match[0]; }, $text); } } diff --git a/app/index/controller/Article.php b/app/index/controller/Article.php index edbb3869..a0c4f7fc 100644 --- a/app/index/controller/Article.php +++ b/app/index/controller/Article.php @@ -170,9 +170,9 @@ class Article extends Common ]); $ret = ArticleLeaveMessageModel::create($data); if ($ret->isEmpty()) { - return error(lang('留言提交失败')); + return error(lang('信息提交失败!')); } - return success(lang('留言提交成功')); + return success(lang('信息已成功提交!')); } } diff --git a/app/index/controller/Product.php b/app/index/controller/Product.php index b16ded89..1dcd0921 100644 --- a/app/index/controller/Product.php +++ b/app/index/controller/Product.php @@ -299,9 +299,10 @@ class Product extends Common 'query' => request()->param() ]) ->each(function ($item) use($keywords) { - $item['spu'] = highlight_keywords($item['spu'], $keywords, ['redpoint']); - $item['name'] = highlight_keywords($item['name'], $keywords, ['redpoint']); - $item['short_name'] = highlight_keywords($item['short_name'], $keywords, ['redpoint']); + $replace = fn($txt) => '' . $txt . ''; + $item['spu'] = highlight_keywords($item['spu'], $keywords, $replace); + $item['name'] = highlight_keywords($item['name'], $keywords, $replace); + $item['short_name'] = highlight_keywords($item['short_name'], $keywords, $replace); return $item; }); View::assign('products', $products); diff --git a/app/index/view/mobile/product/detail.html b/app/index/view/mobile/product/detail.html index 323f8c66..3ea3fc49 100644 --- a/app/index/view/mobile/product/detail.html +++ b/app/index/view/mobile/product/detail.html @@ -37,6 +37,13 @@ {/volist} + {if condition="!empty($product.video_img) && !empty($product.video_url) && $idx == 1"} +
+ +
+ {/if}
diff --git a/app/index/view/mobile/public/nas_header.html b/app/index/view/mobile/public/nas_header.html index 7722b738..369d9d36 100644 --- a/app/index/view/mobile/public/nas_header.html +++ b/app/index/view/mobile/public/nas_header.html @@ -15,19 +15,6 @@
-
- -
-
-
-
{:lang_i18n('产品列表')}
- {notempty name="header_categorys"} - {volist name="header_categorys" id="ca"} - - {/volist} - {/notempty} -
-
{notempty name="header_navigation"} {volist name="header_navigation" id="nav"}
diff --git a/app/index/view/pc/product/detail.html b/app/index/view/pc/product/detail.html index 38cbe4b4..87f8250f 100644 --- a/app/index/view/pc/product/detail.html +++ b/app/index/view/pc/product/detail.html @@ -37,13 +37,13 @@
    + {volist name="sku.photo_album" id="photo"} +
  • + {/volist} {if condition="!empty($product.video_img) && !empty($product.video_url) && $idx == 1"}
  • {/if} - {volist name="sku.photo_album" id="photo"} -
  • - {/volist}
@@ -52,16 +52,9 @@
- {if condition="!empty($product.video_img) && !empty($product.video_url) && $idx == 1"} - - - {else/} {notempty name="sku.photo_album[0]"} {/notempty} - {/if}
{/volist} @@ -225,7 +218,7 @@
- + @@ -273,21 +266,12 @@ // 处理表单提交 modal.find("form").submit(function(e) { e.preventDefault(); + var form = $(this) var formData = $(this).serialize(); - // 这里可以添加代码将formData发送到服务器 - // 例如通过AJAX - console.log("提交的数据: " + formData); - // 提交成功后可以选择关闭模态框 - modal.hide(); - }); - - // 提交询盘 - $('#send').click(function() { - var form = $(this).parents('form'); $.ajax({ url: "{:url('product/inquiry')}", type: 'POST', - data: form.serialize(), + data: formData, success: function(r) { if (r.code == 0) { form[0].reset(); // 重置表单 @@ -297,6 +281,7 @@ }, error: function(e) { console.error(e); + modal.hide(); } }) }); diff --git a/app/index/view/pc/product/search.html b/app/index/view/pc/product/search.html index 2356987d..be4a115f 100644 --- a/app/index/view/pc/product/search.html +++ b/app/index/view/pc/product/search.html @@ -14,6 +14,7 @@ + {notempty name="products"} +
{$page|raw}
+ {else/} +
暂无数据
+ {/notempty} {/block} \ No newline at end of file diff --git a/app/index/view/pc/public/nas_header.html b/app/index/view/pc/public/nas_header.html index 0f35079a..1fac09bb 100644 --- a/app/index/view/pc/public/nas_header.html +++ b/app/index/view/pc/public/nas_header.html @@ -17,9 +17,10 @@