init
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Shopping cart template
|
||||
*
|
||||
* @var $block \Magento\Checkout\Block\Cart
|
||||
*/
|
||||
|
||||
if ($block->getItemsCount()) {
|
||||
// phpcs:ignore Magento2.Security.LanguageConstruct.DirectOutput
|
||||
echo $block->getChildHtml('with-items');
|
||||
} else {
|
||||
// phpcs:ignore Magento2.Security.LanguageConstruct.DirectOutput
|
||||
echo $block->getChildHtml('no-items');
|
||||
}
|
||||
?>
|
||||
|
||||
<script>
|
||||
require([
|
||||
'jquery'
|
||||
], function($){
|
||||
$('#shopping-cart-table .cart.item').first().addClass('first-item');
|
||||
|
||||
// 购物车选择销售
|
||||
$('.xiaos_list').change(function(){
|
||||
if($(this).val()){
|
||||
$('.yi_list,.hidden-lab-id').val('');
|
||||
$(this).removeClass('has-error');
|
||||
$('.sale-error-tip').hide();
|
||||
var salespersonId = $(this).val();
|
||||
$.ajax({
|
||||
url: BASE_URL+'stemcell_checkout/cart/getLabsFromSalesperson',
|
||||
data: {salesperson_id: salespersonId},
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
|
||||
/** @inheritdoc */
|
||||
success: function (res) {
|
||||
var labAccountHtml = '';
|
||||
if(res.labs && res.labs.length > 0){
|
||||
res.labs.forEach(item => {
|
||||
labAccountHtml += '<li data-lab="'+item.lab_id+'" data-lab-id="'+item.lab_code+'">'+item.booking_account+'</li>';
|
||||
});
|
||||
}
|
||||
$('.yi-list-select').html(labAccountHtml);
|
||||
},
|
||||
|
||||
/** @inheritdoc */
|
||||
error: function (res) {
|
||||
console.log('error res', res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 购物车产品详细信息Lab选择点击
|
||||
$('.yi_list').click(function(){
|
||||
if($('.yi-list-select').html()){
|
||||
$(this).next().show();
|
||||
}
|
||||
});
|
||||
$('body').click(function (e) {
|
||||
var target = $(e.target);
|
||||
if(!target.is('.yi_list,.yi-list-select-box,.yi-list-select-search')){
|
||||
$('.yi-list-select-box').hide();
|
||||
}
|
||||
});
|
||||
|
||||
// 购物车产品详细信息Lab选择输入后过滤结果列表
|
||||
$('.yi-list-select-search').keyup(function(){
|
||||
const typeLab = $(this).val();
|
||||
$(this).next().children('li').each(function(){
|
||||
const labListText = $(this).text();
|
||||
if(labListText.indexOf(typeLab) != -1){
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".yi-list-select li", function() {
|
||||
const labText = $(this).text();
|
||||
const labId = $(this).attr('data-lab-id');
|
||||
//const salespersonId = $(this).attr('data-salesperson-id');
|
||||
const lab = $(this).attr('data-lab');
|
||||
//const salesperson = $(this).attr('data-salesperson');
|
||||
$(this).parents('div.yi-list-select-box').prev().val(labText);
|
||||
$(this).parents('div.yi-list-select-box').siblings('.hidden-lab-id').val(lab);
|
||||
//$(this).parent().siblings('.hidden-salesperson-id').val(salespersonId);
|
||||
$(this).parents('.details-section').siblings().children('.lab-id.input').val(labId);
|
||||
//$(this).parents('.details-section').siblings('.item-salesperson').children('.salesperson').html(salesperson);
|
||||
});
|
||||
|
||||
// 详细信息同上
|
||||
$('.details_same_btn').click(function(){
|
||||
const labInput = $(this).parents('.cart.item').prev().children().find('.yi_list').val();
|
||||
const labIdHiddenInput = $(this).parents('.cart.item').prev().children().find('.hidden-lab-id').val();
|
||||
const labIdInput = $(this).parents('.cart.item').prev().children().find('.lab-id').val();
|
||||
const cdInput = $(this).parents('.cart.item').prev().children().find('.cd-id').val();
|
||||
const qInput = $(this).parents('.cart.item').prev().children().find('.q-id').val();
|
||||
const personText = $(this).parents('.cart.item').prev().children().find('.salesperson').text();
|
||||
const useTypeRadio = $(this).parents('.cart.item').prev().children().find('.np:checked').val();
|
||||
const discountInput = $(this).parents('.cart.item').prev().children().find('.discount').val();
|
||||
const beizhuText = $(this).parents('.cart.item').prev().children().find('.beizhu').val();
|
||||
|
||||
$(this).parent().children().find('.yi_list').val(labInput);
|
||||
$(this).parent().children().find('.hidden-lab-id').val(labIdHiddenInput);
|
||||
$(this).parent().children().find('.salesperson').text(personText);
|
||||
$(this).parent().children().find('.lab-id').val(labIdInput);
|
||||
$(this).parent().children().find('.cd-id').val(cdInput);
|
||||
$(this).parent().children().find('.q-id').val(qInput);
|
||||
$(this).parent().children().find('.discount').val(discountInput);
|
||||
$(this).parent().children().find('input.np[value='+useTypeRadio+']').prop('checked', true);
|
||||
$(this).parent().children().find('.beizhu').val(beizhuText);
|
||||
});
|
||||
|
||||
// 修改数量更新购物车
|
||||
$('.cart.table-wrapper .col.qty .input-text').change(function(){
|
||||
$('.form.form-cart button.update').trigger('click');
|
||||
});
|
||||
// 修改折扣更新购物车
|
||||
$('.cart.table-wrapper .discount_off input').change(function(){
|
||||
if($(this).val()>0){
|
||||
$('.form.form-cart button.update').trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
//订单备注
|
||||
$(document).on("change", "#customer_note", function() {
|
||||
var textareaContent = $(this).val();
|
||||
$('#cart-customer-note').val(textareaContent);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user