1 |
- import{_ as e}from"./s-empty.4d7f5239.js";import{s,z as t,c as l,f as o,g as a,w as i,m as c,i as d,k as n,u as r,v as u,l as p,r as f,F as _,G as m,x as k,H as g,n as x,I as h,j as y,J as b,K as v,L as M,M as C}from"./index-a116b7fa.js";import{_ as j}from"./su-number-box.7b9bb097.js";import{_ as S}from"./s-goods-item.e5b69bb0.js";import{a as I,_ as w}from"./s-layout.4ae51839.js";import{f as L}from"./useGoods.6b315a78.js";import{_ as G}from"./_plugin-vue_export-helper.1b428a4d.js";/* empty css */import"./points.c381a8e1.js";/* empty css */import"./phone-international-input.b9f6c8e6.js";const T=G({__name:"cart",setup(G){g((e=>({ead084d6:k(T)})));const T=s.$platform.navbar,A=s.$store("cart"),B=t({editMode:!1,list:l((()=>A.list)),shopList:l((()=>A.shopNameMap)),skuList:l((()=>A.shopSkuMap)),selectedList:[],selectedIds:l((()=>A.selectedIds)),isAllSelected:l((()=>A.isAllSelected)),totalPriceSelected:l((()=>A.totalPriceSelected))}),N=l((()=>{const e={};return B.list.forEach((s=>{const t=Object.keys(B.skuList).find((e=>B.skuList[e].includes(s.sku.id))),l=B.shopList[t]||"未知店铺";e[l]||(e[l]=[]),e[l].push(s)})),e}));function $(e){console.log("单选"),A.selectSingle(e)}function P(){A.selectAll(!B.isAllSelected)}function V(){let e=[],t=[];B.selectedList=B.list.filter((e=>B.selectedIds.includes(e.id))),B.selectedList.map((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,pointStatus:!1,deliveryType:1,spuPayType:1,spuType:1})}):s.$helper.toast("请选择商品")}async function F(){A.delete(B.selectedIds)}return(s,t)=>{const l=c(x("s-empty"),e),g=h,G=y,T=b,U=v,z=M,J=c(x("su-number-box"),j),O=c(x("s-goods-item"),S),E=c(x("su-fixed"),I),H=c(x("s-layout"),w);return o(),a(H,{title:"购物车",tabbar:"/pages/index/cart",bgStyle:{color:"#fff"}},{default:i((()=>[0===B.list.length?(o(),a(l,{key:0,text:"购物车空空如也,快去逛逛吧~",icon:"/static/cart-empty.png"})):d("",!0),B.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(B.list.length),1)])),_:1}),r(" 件商品 ")])),_:1}),n(G,{class:"header-right"},{default:i((()=>[B.editMode?(o(),a(T,{key:0,class:"ss-reset-button",onClick:t[0]||(t[0]=e=>B.editMode=!1)},{default:i((()=>[r(" 取消 ")])),_:1})):(o(),a(T,{key:1,class:"ss-reset-button ui-TC-Main",onClick:t[1]||(t[1]=e=>B.editMode=!0)},{default:i((()=>[r(" 编辑 ")])),_:1}))])),_:1})])),_:1}),n(G,{class:"ss-m-t-70"}),(o(!0),p(_,null,f(N.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(z,{class:"check-box ss-flex ss-col-center ss-p-l-10",onClick:s=>$(e.id)},{default:i((()=>[n(U,{checked:B.selectedIds.includes(e.id),color:"var(--ui-BG-Main)",style:{transform:"scale(0.8)"},onClick:m((s=>$(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},C({_:2},[B.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,A.update({goods_id:l.id,goods_num:t,goods_sku_price_id:l.goods_sku_price_id})):A.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)),B.list.length>0?(o(),a(E,{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(z,{class:"check-box ss-flex ss-col-center ss-p-r-30",onClick:P},{default:i((()=>[n(U,{checked:B.isAllSelected,color:"var(--ui-BG-Main)",style:{transform:"scale(0.8)"},onClick:m(P,["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(L)(B.totalPriceSelected)),1)])),_:1})])),_:1}),n(G,{class:"footer-right"},{default:i((()=>[B.editMode?(o(),a(T,{key:0,class:"ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main",onClick:F},{default:i((()=>[r(" 删除 ")])),_:1})):(o(),a(T,{key:1,class:"ss-reset-button ui-BG-Main-Gradient pay-btn ui-Shadow-Main",onClick:V},{default:i((()=>{var e;return[r(" 去结算 "+u((null==(e=B.selectedIds)?void 0:e.length)?`(${B.selectedIds.length})`:""),1)]})),_:1}))])),_:1})])),_:1})])),_:1})):d("",!0)])),_:1})):d("",!0)])),_:1})}}},[["__scopeId","data-v-52771cc1"]]);export{T as default};
|