pages-index-cart.eefafa5f.js 5.5 KB

1
  1. import{_ as e}from"./s-empty.6d3471cc.js";import{s,y as t,c as l,e as o,f as a,w as i,l as c,g as d,j as n,t as r,u,k as p,r as f,F as _,C as m,v as k,D as g,m as h,E as x,i as b,G as y,H as v,I as C,J as M}from"./index-b48a414d.js";import{_ as S}from"./su-number-box.64465b76.js";import{_ as j}from"./s-goods-item.13120f93.js";import{f as I,a as w,_ as L}from"./s-layout.d6dcdc81.js";import{_ as G}from"./_plugin-vue_export-helper.1b428a4d.js";/* empty css */import"./points.c381a8e1.js";/* empty css */import"./phone-international-input.feef99c7.js";const A=G({__name:"cart",setup(G){g((e=>({13408786:k(A)})));const A=s.$platform.navbar,N=s.$store("cart"),T=t({editMode:!1,list:l((()=>N.list)),shopList:l((()=>N.shopNameMap)),skuList:l((()=>N.shopSkuMap)),selectedList:[],selectedIds:l((()=>N.selectedIds)),isAllSelected:l((()=>N.isAllSelected)),totalPriceSelected:l((()=>N.totalPriceSelected))}),$=l((()=>{const e={};return T.list.forEach((s=>{const t=Object.keys(T.skuList).find((e=>T.skuList[e].includes(s.sku.id))),l=T.shopList[t]||"未知店铺";e[l]||(e[l]=[]),e[l].push(s)})),e}));function B(e){console.log("单选"),N.selectSingle(e)}function V(){N.selectAll(!T.isAllSelected)}function F(){let e=[],t=[];T.selectedList=T.list.filter((e=>T.selectedIds.includes(e.id))),T.selectedList.map((s=>{console.log(s,"便利"),e.push({skuId:s.sku.id,count:s.count,cartId:s.id}),t.push({goods_id:s.spu.id,goods_num:s.count})})),0!==t.length?s.$router.go("/pages/order/confirm",{data:JSON.stringify({items:e,deliveryType:1,pointStatus:!1})}):s.$helper.toast("请选择商品")}async function P(){N.delete(T.selectedIds)}return(s,t)=>{const l=c(h("s-empty"),e),g=x,G=b,A=y,U=v,E=C,J=c(h("su-number-box"),S),O=c(h("s-goods-item"),j),D=c(h("su-fixed"),w),H=c(h("s-layout"),L);return o(),a(H,{title:"购物车",tabbar:"/pages/index/cart",bgStyle:{color:"#fff"}},{default:i((()=>[0===T.list.length?(o(),a(l,{key:0,text:"购物车空空如也,快去逛逛吧~",icon:"/static/cart-empty.png"})):d("",!0),T.list.length?(o(),a(G,{key:1,class:"cart-box ss-flex ss-flex-col ss-row-between"},{default:i((()=>[n(G,{class:"cart-header ss-flex ss-col-center ss-row-between ss-p-x-30"},{default:i((()=>[n(G,{class:"header-left ss-flex ss-col-center ss-font-26"},{default:i((()=>[r(" 共 "),n(g,{class:"goods-number ui-TC-Main ss-flex"},{default:i((()=>[r(u(T.list.length),1)])),_:1}),r(" 件商品 ")])),_:1}),n(G,{class:"header-right"},{default:i((()=>[T.editMode?(o(),a(A,{key:0,class:"ss-reset-button",onClick:t[0]||(t[0]=e=>T.editMode=!1)},{default:i((()=>[r(" 取消 ")])),_:1})):(o(),a(A,{key:1,class:"ss-reset-button ui-TC-Main",onClick:t[1]||(t[1]=e=>T.editMode=!0)},{default:i((()=>[r(" 编辑 ")])),_:1}))])),_:1})])),_:1}),n(G,{class:"ss-m-t-70"}),(o(!0),p(_,null,f($.value,((e,s,t)=>(o(),a(G,{class:"cart-content ss-flex-1 ss-p-x-30",key:s},{default:i((()=>[n(G,{class:"ss-m-b-14 bg-white goods-box"},{default:i((()=>[n(G,{class:"title-text ss-p-x-10 ss-p-t-20 ss-flex ss-col-center"},{default:i((()=>[n(g,{class:"ss-m-l-10"},{default:i((()=>[r(u(s),1)])),_:2},1024)])),_:2},1024),(o(!0),p(_,null,f(e,((e,s)=>(o(),a(G,{class:"ss-r-10",key:e.id},{default:i((()=>[n(G,{class:"ss-flex ss-col-center"},{default:i((()=>[n(E,{class:"check-box ss-flex ss-col-center ss-p-l-10",onClick:s=>B(e.id)},{default:i((()=>[n(U,{checked:T.selectedIds.includes(e.id),color:"var(--ui-BG-Main)",style:{transform:"scale(0.8)"},onClick:m((s=>B(e.id)),["stop"])},null,8,["checked","onClick"])])),_:2},1032,["onClick"]),n(O,{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},[T.editMode?void 0:{name:"tool",fn:i((()=>[n(J,{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,N.update({goods_id:l.id,goods_num:t,goods_sku_price_id:l.goods_sku_price_id})):N.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))])),_:2},1024)])),_:2},1024)))),128)),T.list.length>0?(o(),a(D,{key:0,bottom:"",val:48,placeholder:"",isInset:!1},{default:i((()=>[n(G,{class:"cart-footer ss-flex ss-col-center ss-row-between ss-p-x-30 border-bottom"},{default:i((()=>[n(G,{class:"footer-left ss-flex ss-col-center"},{default:i((()=>[n(E,{class:"check-box ss-flex ss-col-center ss-p-r-30",onClick:V},{default:i((()=>[n(U,{checked:T.isAllSelected,color:"var(--ui-BG-Main)",style:{transform:"scale(0.8)"},onClick:m(V,["stop"])},null,8,["checked"]),n(G,{class:"ss-m-l-8"},{default:i((()=>[r(" 全选 ")])),_:1})])),_:1}),n(g,null,{default:i((()=>[r("合计:")])),_:1}),n(G,{class:"text-price price-text"},{default:i((()=>[r(u(k(I)(T.totalPriceSelected)),1)])),_:1})])),_:1}),n(G,{class:"footer-right"},{default:i((()=>[T.editMode?(o(),a(A,{key:0,class:"ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main",onClick:P},{default:i((()=>[r(" 删除 ")])),_:1})):(o(),a(A,{key:1,class:"ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main",onClick:F},{default:i((()=>{var e;return[r(" 去结算 "+u((null==(e=T.selectedIds)?void 0:e.length)?`(${T.selectedIds.length})`:""),1)]})),_:1}))])),_:1})])),_:1})])),_:1})):d("",!0)])),_:1})):d("",!0)])),_:1})}}},[["__scopeId","data-v-abe88574"]]);export{A as default};