修复 分类页价格筛选

This commit is contained in:
pushuo 2023-01-13 16:14:06 +08:00 committed by Edward Yang
parent 7e569330d7
commit e41d366f60
4 changed files with 29 additions and 10 deletions

View File

@ -3,6 +3,7 @@
use Beike\Models\AdminUser;
use Beike\Models\Customer;
use Beike\Models\Language;
use Beike\Models\Currency;
use Beike\Repositories\BrandRepo;
use Beike\Repositories\CategoryRepo;
use Beike\Repositories\CurrencyRepo;
@ -340,6 +341,19 @@ function currency_format($price, string $currency = '', string $value = '', bool
return CurrencyService::getInstance()->format($price, $currency, $value, $format);
}
/**
* 获取指定货币汇率
*
* @return string
*/
function current_currency_rate(): float
{
$currency = current_currency_code();
return Currency::query()->where('code', $currency)->value('value') ?? 1;
}
/**
* 时间格式化
*

View File

@ -169,7 +169,8 @@
</div>
<div v-if="mail_engine == 'sendmail'">
<x-admin-form-input name="sendmail[path]" required title="{{ __('admin/setting.sendmail_path') }}" value="{{ old('path', system_setting('base.sendmail.path', '')) }}">
<x-admin-form-input name="sendmail[path]" :placeholder="222" required title="{{ __('admin/setting.sendmail_path') }}" value="{{ old('path', system_setting('base.sendmail.path', '')) }}">
<div class="help-text font-size-12 lh-base">系统 sendmail 执行路径, 一般为 /usr/sbin/sendmail -bs</div>
</x-admin-form-input>
</div>

View File

@ -87,7 +87,7 @@
function filterProductData() {
let url = bk.removeURLParameters(window.location.href, 'attr', 'price', 'sort', 'order');
let [priceMin, priceMax] = [$('.price-min').val(), $('.price-max').val()];
let [psMin, psMax, pMin, pMax] = [$('.price-select-min').val(), $('.price-select-max').val(), $('.price-min').val(), $('.price-max').val()];
let order = $('.order-select').val();
let perpage = $('.perpage-select').val();
let styleList = $('input[name="style_list"]:checked').val();
@ -98,8 +98,8 @@
url = bk.updateQueryStringParameter(url, 'attr', filterAttrChecked(filterAttr));
}
if (priceMin || priceMax) {
url = bk.updateQueryStringParameter(url, 'price', `${priceMin}-${priceMax}`);
if ((psMin != pMin) || (psMax != pMax)) {
url = bk.updateQueryStringParameter(url, 'price', `${psMin}-${psMax}`);
}
if (order) {

View File

@ -42,8 +42,10 @@
<span class="max">{{ currency_format($filter_data['price']['select_max'], current_currency_code()) }}</span>
</div>
</div>
<input value="{{ $filter_data['price']['select_min'] }}" class="price-min d-none">
<input value="{{ $filter_data['price']['select_max'] }}" class="price-max d-none">
<input value="{{ $filter_data['price']['select_min'] }}" class="price-select-min d-none">
<input value="{{ $filter_data['price']['select_max'] }}" class="price-select-max d-none">
<input value="{{ $filter_data['price']['min'] }}" class="price-min d-none">
<input value="{{ $filter_data['price']['max'] }}" class="price-max d-none">
</div>
</div>
@endif
@ -68,6 +70,8 @@
@push('add-scripts')
<script>
const currencyRate = {{ current_currency_rate() }};
$("#price-slider").slider({
range: true,
step: 0.01,
@ -75,15 +79,15 @@
max: {{ $filter_data['price']['max'] ?? 0 }},
values: [{{ $filter_data['price']['select_min'] }}, {{ $filter_data['price']['select_max'] }}],
change: function(event, ui) {
$('input.price-min').val(ui.values[0])
$('input.price-max').val(ui.values[1])
$('input.price-select-min').val(ui.values[0])
$('input.price-select-max').val(ui.values[1])
filterProductData();
},
slide: function(event, ui) {
let min = $('.price-range .min').html();
let max = $('.price-range .max').html();
$('.price-range .min').html(min.replace(min.replace(/[^0-9.]/g, ''), ui.values[0]));
$('.price-range .max').html(max.replace(max.replace(/[^0-9.]/g, ''), ui.values[1]));
$('.price-range .min').html(min.replace(min.replace(/[^0-9.,]/g, ''), (ui.values[0] * currencyRate).toFixed(2)));
$('.price-range .max').html(max.replace(max.replace(/[^0-9.,]/g, ''), (ui.values[1] * currencyRate).toFixed(2)));
}
});
</script>