2 lines
3.2 KiB
JavaScript
2 lines
3.2 KiB
JavaScript
|
"use strict";const e=require("../../../common/vendor.js"),t=require("../../../sheep/index.js"),s=require("../../../sheep/hooks/useGoods.js");if(!Array){(e.resolveComponent("s-empty")+e.resolveComponent("su-number-box")+e.resolveComponent("s-goods-item")+e.resolveComponent("su-fixed")+e.resolveComponent("s-layout")+e.resolveComponent("layout-default-uni"))()}Math||((()=>"../../../sheep/components/s-empty/s-empty.js")+(()=>"../../../sheep/ui/su-number-box/su-number-box.js")+(()=>"../../../sheep/components/s-goods-item/s-goods-item.js")+(()=>"../../../sheep/ui/su-fixed/su-fixed.js")+(()=>"../../../sheep/components/s-layout/s-layout.js"))();const o={__name:"cart",setup(o){e.useCssVars((t=>({e0c4ad22:e.unref(d)})));const d=t.sheep.$platform.navbar,i=t.sheep.$store("cart"),l=e.reactive({editMode:!1,list:e.computed((()=>i.list)),selectedList:[],selectedIds:e.computed((()=>i.selectedIds)),isAllSelected:e.computed((()=>i.isAllSelected)),totalPriceSelected:e.computed((()=>i.totalPriceSelected))});function n(e){i.selectSingle(e)}function r(){i.selectAll(!l.isAllSelected)}function u(){const e=[],s=[];l.selectedList=l.list.filter((e=>l.selectedIds.includes(e.id))),l.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.sheep.$router.go("/modules/mall/order/confirm",{data:JSON.stringify({items:e})}):t.sheep.$helper.toast("请选择商品")}function c(){return e=this,t=null,s=function*(){i.delete(l.selectedIds)},new Promise(((o,d)=>{var i=e=>{try{n(s.next(e))}catch(t){d(t)}},l=e=>{try{n(s.throw(e))}catch(t){d(t)}},n=e=>e.done?o(e.value):Promise.resolve(e.value).then(i,l);n((s=s.apply(e,t)).next())}));var e,t,s}return(t,o)=>{var d;return e.e({a:0===l.list.length},0===l.list.length?{b:e.p({text:"购物车空空如也,快去逛逛吧~",icon:"/static/cart-empty.png"})}:{},{c:l.list.length},l.list.length?e.e({d:e.t(l.list.length),e:l.editMode},l.editMode?{f:e.o((e=>l.editMode=!1))}:{g:e.o((e=>l.editMode=!0))},{h:e.f(l.list,((t,s,o)=>e.e({a:l.selectedIds.includes(t.id),b:e.o((e=>n(t.id)),t.id),c:e.o((e=>n(t.id)),t.id)},l.editMode?{}:{d:e.o((e=>{return o=t,void(0!==(s=e)?o.goods_num!==s&&(o.goods_num=s,i.update({goods_id:o.id,goods_num:s,goods_sku_price_id:o.goods_sku_price_id})):i.delete(o.id));var s,o}),t.id),e:"0e655965-4-"+o+",0e655965-3-"+o,f:e.o((e=>t.count=e),t.id),g:e.p({min:0,max:t.sku.stock,step:1,modelValue:t.count})},{h:"0e655965-3-"+o+",0e655965-1",i:e.p({title:t.spu.name,img:t.spu.picUrl||t.goods.image,price:t.sku.price,skuText:t.sku.properties.length>1?t.sku.properties.reduce(((e,t)=>e.valueName+" "+t.valueName)):t.sku.properties[0].valueName,priceColor:"#FF3000",titleWidth:400}),j:t.id}))),i:!l.editMode,j:l.list.length>0},l.list.length>0?e.e({k:l.isAllSelected,l:e.o(r),m:e.o(r),n:e.t(e.unref(s.fen2yuan)(l.totalPriceSelected)),o:l.editMode},l.editMode?{p:e.o(c)}:{q:e.t((null==(d=l.selectedIds)?void 0:d.length)?`(${l.selectedIds.length})`:""),r:e.o(u)},{s:e.p({bottom:!0,val:48,placeholder:!0,isInset:!1})}):{}):{},{t:e.p({title:"购物车",tabbar:"/modules/mall/index/cart",bgStyle:{color:"#fff"}}),v:e.s(t.__cssVars())})}}},d=e._export_sfc(o,[["__scopeId","data-v-0e655965"]]);wx.createPage(d);
|