import{_ as e}from"./s-empty.Bcpb-H16.js";import{A as s,s as t,v as l,c as o,r as a,e as d,f as c,w as i,u as r,j as n,g as u,k as f,p,t as m,l as _,m as g,F as k,B as x,C as h,i as b,D as y,E as C,G as v,H as M}from"./index-CWyPMHxb.js";import{_ as I}from"./su-number-box.BG1CDAQw.js";import{_ as S}from"./s-goods-item.DVomrksC.js";import{_ as j,S as w}from"./s-layout.CUgh1tQ8.js";import{f as G}from"./useGoods.BQLkjza8.js";import{_ as A}from"./_plugin-vue_export-helper.BCo6x5W8.js";import"./index.gxKvznCa.js";const B=A({__name:"cart",setup(A){s((e=>({"18724c9f":r(B)})));const B=t.$platform.navbar,$=t.$store("cart"),N=l({editMode:!1,list:o((()=>$.list)),selectedList:[],selectedIds:o((()=>$.selectedIds)),isAllSelected:o((()=>$.isAllSelected)),totalPriceSelected:o((()=>$.totalPriceSelected))});function T(e){$.selectSingle(e)}function V(){$.selectAll(!N.isAllSelected)}function F(){let e=[],s=[];N.selectedList=N.list.filter((e=>N.selectedIds.includes(e.id))),N.selectedList.map((t=>{e.push({skuId:t.sku.id,count:t.count,cartId:t.id,categoryId:t.spu.categoryId}),s.push({goods_id:t.spu.id,goods_num:t.count})})),0!==s.length?t.$router.go("/pages/order/confirm",{data:JSON.stringify({items:e})}):t.$helper.toast("请选择商品")}async function L(){$.delete(N.selectedIds)}return(s,t)=>{const l=a(d("s-empty"),e),o=h,A=b,B=y,P=C,U=v,D=a(d("su-number-box"),I),E=a(d("s-goods-item"),S),H=a(d("su-fixed"),j),J=a(d("s-layout"),w);return n(),c(J,{title:"购物车",tabbar:"/pages/index/cart",bgStyle:{color:"#fff"}},{default:i((()=>[0===N.list.length?(n(),c(l,{key:0,text:"购物车空空如也,快去逛逛吧~",icon:"/static/cart-empty.png"})):u("",!0),N.list.length?(n(),c(A,{key:1,class:"cart-box ss-flex ss-flex-col ss-row-between"},{default:i((()=>[f(A,{class:"cart-header ss-flex ss-col-center ss-row-between ss-p-x-30"},{default:i((()=>[f(A,{class:"header-left ss-flex ss-col-center ss-font-26"},{default:i((()=>[p(" 共 "),f(o,{class:"goods-number ui-TC-Main ss-flex"},{default:i((()=>[p(m(N.list.length),1)])),_:1}),p(" 件商品 ")])),_:1}),f(A,{class:"header-right"},{default:i((()=>[N.editMode?(n(),c(B,{key:0,class:"ss-reset-button",onClick:t[0]||(t[0]=e=>N.editMode=!1)},{default:i((()=>[p(" 取消 ")])),_:1})):(n(),c(B,{key:1,class:"ss-reset-button ui-TC-Main",onClick:t[1]||(t[1]=e=>N.editMode=!0)},{default:i((()=>[p(" 编辑 ")])),_:1}))])),_:1})])),_:1}),f(A,{class:"cart-content ss-flex-1 ss-p-x-30 ss-m-b-40"},{default:i((()=>[(n(!0),_(k,null,g(N.list,(e=>(n(),c(A,{class:"goods-box ss-r-10 ss-m-b-14",key:e.id},{default:i((()=>[f(A,{class:"ss-flex ss-col-center"},{default:i((()=>[f(U,{class:"check-box ss-flex ss-col-center ss-p-l-10",onClick:s=>T(e.id)},{default:i((()=>[f(P,{checked:N.selectedIds.includes(e.id),color:"var(--ui-BG-Main)",style:{transform:"scale(0.8)"},onClick:x((s=>T(e.id)),["stop"])},null,8,["checked","onClick"])])),_:2},1032,["onClick"]),f(E,{title:e.spu.name,img:e.spu.picUrl||e.goods.image,price:e.sku.price,skuText:e.sku.properties.length>1?e.sku.properties.reduce(((e,s)=>e.valueName+" "+s.valueName)):e.sku.properties[0].valueName,priceColor:"#FF3000",titleWidth:400},M({_:2},[N.editMode?void 0:{name:"tool",fn:i((()=>[f(D,{min:0,max:e.sku.stock,step:1,modelValue:e.count,"onUpdate:modelValue":s=>e.count=s,onChange:s=>{return l=e,void(0!==(t=s)?l.goods_num!==t&&(l.goods_num=t,$.update({goods_id:l.id,goods_num:t,goods_sku_price_id:l.goods_sku_price_id})):$.delete(l.id));var t,l}},null,8,["max","modelValue","onUpdate:modelValue","onChange"])])),key:"0"}]),1032,["title","img","price","skuText"])])),_:2},1024)])),_:2},1024)))),128))])),_:1}),N.list.length>0?(n(),c(H,{key:0,bottom:"",val:48,placeholder:"",isInset:!1},{default:i((()=>[f(A,{class:"cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom"},{default:i((()=>[f(A,{class:"footer-left ss-flex ss-col-center"},{default:i((()=>[f(U,{class:"check-box ss-flex ss-col-center ss-p-r-30",onClick:V},{default:i((()=>[f(P,{checked:N.isAllSelected,color:"var(--ui-BG-Main)",style:{transform:"scale(0.8)"},onClick:x(V,["stop"])},null,8,["checked"]),f(A,{class:"ss-m-l-8"},{default:i((()=>[p(" 全选 ")])),_:1})])),_:1}),f(o,null,{default:i((()=>[p("合计：")])),_:1}),f(A,{class:"text-price price-text"},{default:i((()=>[p(m(r(G)(N.totalPriceSelected)),1)])),_:1})])),_:1}),f(A,{class:"footer-right"},{default:i((()=>[N.editMode?(n(),c(B,{key:0,class:"ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main",onClick:L},{default:i((()=>[p(" 删除 ")])),_:1})):(n(),c(B,{key:1,class:"ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main",onClick:F},{default:i((()=>{var e;return[p(" 去结算 "+m((null==(e=N.selectedIds)?void 0:e.length)?`(${N.selectedIds.length})`:""),1)]})),_:1}))])),_:1})])),_:1})])),_:1})):u("",!0)])),_:1})):u("",!0)])),_:1})}}},[["__scopeId","data-v-edf1cdfb"]]);export{B as default};
