修复分类锁的bug

This commit is contained in:
2026-05-29 23:41:58 +08:00
parent 26e42dd2a4
commit 5abb8277e3
11 changed files with 251 additions and 28 deletions
+2 -2
View File
@@ -14,11 +14,11 @@
<div class="text-error mt-4">error</div>
<h1 class="text-uppercase text-danger mt-3">{{ $content }}</h1>
@if(!$url)
<a class="btn btn-info mt-3" href="javascript:history.back(-1);"><i class="mdi mdi-reply"></i> {{ __('hyper.error_back_btn') }}</a>
<a class="btn btn-info mt-3" href="{{ url('/') }}"><i class="mdi mdi-reply"></i> {{ __('hyper.error_back_btn') }}</a>
@else
<a class="btn btn-info mt-3" href="{{ $url }}"><i class="mdi mdi-reply"></i> {{ __('hyper.error_back_btn') }}</a>
@endif
</div> <!-- end /.text-center-->
</div> <!-- end col-->
</div>
@stop
@stop
@@ -6,7 +6,7 @@
<div class="page-title-right">
<div class="app-search">
<div class="position-relative">
<input type="text" class="form-control" id="search" placeholder="{{ __('hyper.home_search_box') }}">
<input type="text" class="form-control" id="search" name="goods_search_{{ time() }}" value="" autocomplete="off" placeholder="{{ __('hyper.home_search_box') }}">
<span class="uil-search"></span>
</div>
</div>
@@ -142,6 +142,11 @@
$('#notice-open').click(function() {
$('#notice-modal').modal();
});
var groupPasswordPassed = false;
clearSearchInput();
setTimeout(clearSearchInput, 300);
$("#search").on("input",function(e){
var txt = $("#search").val();
if($.trim(txt)!="") {
@@ -150,27 +155,110 @@
$(".category").show();
}
});
$('.group-password-link').click(function() {
$('.tab-link:not(.group-password-link)').click(function() {
resetPasswordGroups();
forgetAllPasswordGroupAccess();
clearSearchInput();
});
$(document).on('click', '.group-password-link', function() {
$('#group-password-id').val($(this).data('group-id'));
$('#group-password-name').text($(this).data('group-name'));
$('#group-password-input').val('');
$('#group-password-modal').modal();
});
$('#group-password-modal').on('hidden.bs.modal', function() {
if (!groupPasswordPassed) {
resetPasswordGroups();
forgetAllPasswordGroupAccess();
clearSearchInput();
showAllGroup();
}
groupPasswordPassed = false;
});
$('#group-password-submit').click(function() {
var groupId = $('#group-password-id').val();
$.post("{{ url('verify-group-password') }}", {
_token: "{{ csrf_token() }}",
group_id: $('#group-password-id').val(),
group_id: groupId,
password: $('#group-password-input').val()
}, function(res) {
if (res.code === 200) {
window.location.reload();
groupPasswordPassed = true;
unlockGroup(groupId, res.data);
clearSearchInput();
$('#group-password-modal').modal('hide');
} else {
$.NotificationApp.send("{{ __('hyper.home_tip') }}", res.msg, "top-center", "rgba(0,0,0,0.2)", "error");
}
});
});
function unlockGroup(groupId, group) {
resetPasswordGroups(groupId);
var $link = $('.group-password-link[data-group-id="' + groupId + '"]');
$('#group-' + groupId + ' .hyper-wrapper').html(renderGroupGoods(group.goods || []));
$('.tab-link').removeClass('active');
$('.tab-pane').removeClass('active show');
$link.addClass('active');
$('#group-' + groupId).addClass('active show');
}
function resetPasswordGroups(exceptGroupId) {
$('.group-password-link').each(function() {
var groupId = String($(this).data('group-id'));
if (exceptGroupId && groupId === String(exceptGroupId)) {
return;
}
$('#group-' + groupId + ' .hyper-wrapper').empty();
$(this).removeClass('active');
});
}
function forgetAllPasswordGroupAccess() {
$('.group-password-link').each(function() {
$.post("{{ url('forget-group-password-access') }}", {
_token: "{{ csrf_token() }}",
group_id: $(this).data('group-id')
});
});
}
function showAllGroup() {
$('.tab-link').removeClass('active');
$('.tab-pane').removeClass('active show');
$('.tab-link[href="#group-all"]').addClass('active');
$('#group-all').addClass('active show');
}
function clearSearchInput() {
$('#search').val('');
$('.category').show();
}
function renderGroupGoods(goodsList) {
var html = '';
$.each(goodsList, function(index, goods) {
if (parseInt(goods.in_stock) > 0) {
html += '<a href="/buy/' + goods.id + '" class="home-card category">';
} else {
html += '<a href="javascript:void(0);" onclick="sell_out_tip()" class="home-card category ribbon-box">';
html += '<div class="ribbon-two ribbon-two-danger"><span>{{ __('hyper.home_out_of_stock') }}</span></div>';
}
html += '<img class="home-img" src="' + goods.picture_url + '">';
html += '<div class="flex"><p class="name">' + goods.gd_name + '</p>';
html += '<div class="price">{{ __('hyper.global_currency') }}<b>' + goods.actual_price + '</b></div></div></a>';
});
return html;
}
function sell_out_tip() {
$.NotificationApp.send("{{ __('hyper.home_tip') }}","{{ __('hyper.home_sell_out_tip') }}","top-center","rgba(0,0,0,0.2)","info");
}
+1 -3
View File
@@ -14,7 +14,7 @@
<div class="err_content">{{ $content }}</div>
@if(!$url)
<div class="btn">
<a href="javascript:history.back(-1);">
<a href="{{ url('/') }}">
<span>{{ __('dujiaoka.callback') }}</span>
</a>
</div>
@@ -48,5 +48,3 @@
</div>
</body>
@endsection
@@ -21,7 +21,7 @@
</div>
<div class="col-12 mt-3 text-center">
@if(!$url)
<a href="javascript:history.back(-1);" class="btn btn-outline-dark">{{ __('dujiaoka.callback') }}</a>
<a href="{{ url('/') }}" class="btn btn-outline-dark">{{ __('dujiaoka.callback') }}</a>
@else
<a href="{{ $url }}" class="btn btn-outline-dark">{{ __('dujiaoka.callback') }}</a>
@endif
@@ -226,17 +226,73 @@
});
$('#group-password-submit').click(function() {
var groupId = $('#group-password-id').val();
$.post("{{ url('verify-group-password') }}", {
_token: "{{ csrf_token() }}",
group_id: $('#group-password-id').val(),
group_id: groupId,
password: $('#group-password-input').val()
}, function(res) {
if (res.code === 200) {
window.location.reload();
unlockGroup(groupId, res.data);
hideGroupPasswordModal();
} else {
alert(res.msg);
}
});
});
function hideGroupPasswordModal() {
var modalEl = document.getElementById('group-password-modal');
if (typeof bootstrap !== 'undefined' && bootstrap.Modal) {
bootstrap.Modal.getOrCreateInstance(modalEl).hide();
} else {
$('#group-password-modal').modal('hide');
}
}
function unlockGroup(groupId, group) {
var $link = $('.group-password-link[data-group-id="' + groupId + '"]');
$link.removeClass('group-password-link')
.attr('href', '#group-' + groupId)
.attr('data-bs-toggle', 'tab')
.find('.ali-icon')
.remove();
$('#group-' + groupId + ' .row').html(renderGroupGoods(group.goods || []));
if (typeof bootstrap !== 'undefined' && bootstrap.Tab) {
bootstrap.Tab.getOrCreateInstance($link[0]).show();
} else if (typeof $link.tab === 'function') {
$link.tab('show');
} else {
$('.category-menus a').removeClass('active');
$('.tab-pane').removeClass('active show');
$link.addClass('active');
$('#group-' + groupId).addClass('active show');
}
}
function renderGroupGoods(goodsList) {
var html = '';
$.each(goodsList, function(index, goods) {
html += '<div class="col"><div class="card position-relative">';
if (parseInt(goods.type) === {{ \App\Models\Goods::AUTOMATIC_DELIVERY }}) {
html += '<span class="badge bg-success position-absolute top-0 start-0"><i class="ali-icon">&#xe7db;</i> {{ __('goods.fields.automatic_delivery') }}</span>';
} else {
html += '<span class="badge bg-warning position-absolute top-0 start-0"><i class="ali-icon">&#xe74b;</i> {{ __('goods.fields.manual_processing') }}</span>';
}
html += '<img src="' + goods.picture_url + '" class="card-img-top" alt="' + goods.gd_name + '">';
html += '<div class="card-body"><h6 class="card-title text-truncate">' + goods.gd_name + '</h6>';
html += '<button type="button" class="btn btn-sm btn-outline-success"><i class="ali-icon">&#xe703;</i> <strong>' + goods.actual_price + '</strong></button>';
if (goods.wholesale_price_cnf) {
html += ' <button type="button" class="btn btn-sm btn-outline-warning"><i class="ali-icon">&#xe77d;</i> {{ __('dujiaoka.home_discount') }}</button>';
}
html += '<h6 class="mt-2"><small class="text-muted">{{ __('goods.fields.in_stock') }}' + goods.in_stock + '</small></h6>';
html += '<a href="/buy/' + goods.id + '" class="btn btn-primary fr"><i class="ali-icon">&#xe7d8;</i> {{ __('dujiaoka.order_now') }}</a>';
html += '</div></div></div>';
});
return html;
}
</script>
@stop