// import 'css/bootstrap.less'; // import 'bootstrap/dist/js/bootstrap.js'; import 'css/newMenu/public.css'; import 'css/newMenu/header.css' import 'css/newMenu/shopList.css'; import 'js/public.js'; $(function(){ var shopData={}; init(); function init(){ listData(); add(); selectFun() }; function listData(){ var data = localStorage.getItem('shopList'); if(data){ let shops = JSON.parse(data); shopData.data=shops.data list(shops.data); if((shops.data).length){ $('.totalFooter').show(); $('.shopNull').hide(); }else{ $('.totalFooter').hide(); $('.shopNull').show(); } }else{ $('.totalFooter').hide(); $('.shopNull').show(); } }; function list(data){ let divs=[]; data.map((item)=>{ divs.push(`
  • ${item.companyName?item.companyName:''}

    ${unescape(item.name)}

    ${parseInt(item.price)>0?parseInt(item.price).toFixed(2)+'万元':'面议'}

    ${parseInt(item.price)>0?(parseInt(item.price)*parseInt(item.number)).toFixed(2)+'万元':'面议'}

    删除
  • ` ) }) $('.shopLists').html(divs); } //数量加减; var nub=0; function add(){ $('.add').click(function(){ nub = $(this).siblings('.number').val(); nub++; if(nub>99){ nub=99 } $(this).siblings('.number').val(nub); let price = $(this).parents('.shopBox').find('.price').text(); $(this).parents('.shopBox').find('.priceTotal').text(parseInt(nub)*parseInt(price)>0?(parseInt(nub)*parseInt(price)).toFixed(2)+'万元':'面议') let index=$(this).parents('li').index(); shopData.data[index].number=nub; nubTol(); lacStor(); }) $('.reduce').click(function(){ nub = $(this).siblings('.number').val(); nub--; if(nub<1){ nub=1 } $(this).siblings('.number').val(nub); let price = $(this).parents('.shopBox').find('.price').text(); $(this).parents('.shopBox').find('.priceTotal').text(parseInt(nub)*parseInt(price)>0?(parseInt(nub)*parseInt(price)).toFixed(2)+'万元':'面议') let index=$(this).parents('li').index(); shopData.data[index].number=nub; nubTol(); lacStor(); }) $('.number').keyup(function(){ let val = $(this).val(); if(isNaN(val)){ $(this).val(1) }; if(val>99){ $(this).val(99) }; if(val<1){ $(this).val(1) }; let price = $(this).parents('.shopBox').find('.price').text(); let vals = $(this).val(); $(this).parents('.shopBox').find('.priceTotal').text(parseInt(vals)*parseInt(price)>0?(parseInt(vals)*parseInt(price)).toFixed(2)+'万元':'面议') }) } //单选图像处理 $('.checkSingle').prop('checked',false); $('.checkboxAll').prop('checked',false); var nub=0; function selectFun(){ let checkArr =[]; $('.checkSingle').click(function(){ let checks = $(this).prop('checked'); let checkList = $('.shopBox .checkSingle:checked'); if(checks){ checkArr.push(checks); $(this).parents('li').addClass('active') $(this).siblings('.checkImg').removeClass('checkNoImg'); }else{ checkArr.pop(); $(this).parents('li').removeClass('active') $(this).siblings('.checkImg').addClass('checkNoImg'); } if(checkArr.length==$('.shopLists li').length){ $('.checkboxAll').prop('checked',true); $('.checkboxAll').siblings('.checkImg').removeClass('checkNoImg') }else{ $('.checkboxAll').prop('checked',false); $('.checkboxAll').siblings('.checkImg').addClass('checkNoImg') } if(checkList.length>0){ $('.orderOk').addClass('active'); }else{ $('.orderOk').removeClass('active'); } nubTol(); }) //全选 $('.checkboxAll').click(function(){ let checkS = $(this).prop('checked'); if(checkS){ $('.shopLists li').addClass('active'); $('.checkSingle').prop('checked',true); $('.checkImg').removeClass('checkNoImg'); $('.orderOk').addClass('active'); }else{ checkArr=[]; $('.checkSingle').prop('checked',false); $('.checkImg').addClass('checkNoImg'); $('.shopLists li').removeClass('active'); $('.orderOk').removeClass('active'); } nubTol() }) } //数量计算 function nubTol(){ let liCheck = $('.shopLists li.active'),nub=0, licheckOk = $('.shopLists li'),totalNub=0; for(let i =0;i{ list.push(`

    订单号 : ${item.orderNo}

    `) }) $('.orderNoList').html(list.join('')); }else{ $('.shopMarsk').show(); $('.shopMarsk .shopOrderOk').hide(); $('.orderNumber').text(data); }; var t=3; var time =setInterval(()=>{ t--; $('.shopTime span').text(t); if(t<=0){ clearInterval(time); $('.shopMarsk').hide(); } },1000); $('.shopClose').click(function(){ clearInterval(time); $('.shopMarsk').hide(); }) } //提示框渐隐函数 function msg(txt) { if($('.smg').hasClass('active')){ return ; } $('.smg').addClass('active'); var lit = $('#msg').val(txt); setTimeout(function () { $('.smg').removeClass('active'); $('#msg').val(''); }, 2000) } })