1 |
- import{B as e,u as s,s as t,v as l,c as o,a6 as a,l as r,m as c,e as u,f as n,w as d,j as f,p as i,t as p,k as g,F as m,r as _,z as y,g as b,q as k,i as x,D as h,S}from"./index-9880b451.js";import{_ as v}from"./su-number-box.8b58381a.js";import{d as w}from"./s-layout.dfc5b0b5.js";import{c as A,f as I}from"./useGoods.bdd1c2ea.js";import{_ as P}from"./_plugin-vue_export-helper.1b428a4d.js";const j=P({__name:"s-select-groupon-sku",props:{show:{type:Boolean,default:!1},goodsInfo:{type:Object,default(){}},grouponAction:{type:String,default:"create"},grouponNum:{type:[Number,String],default:0}},emits:["change","addCart","buy","close","ladder"],setup(P,{emit:j}){const O=P;e((e=>({"30e1f842":s(C)})));const C=t.$url.css("/static/img/shop/goods/groupon-btn-long.png"),N=l({selectedSku:{},currentPropertyArray:[],grouponNum:O.grouponNum}),$=A(O.goodsInfo.skus),E=o((()=>{let e=O.goodsInfo.skus;for(let s of e)s.value_id_array=s.properties.map((e=>e.valueId));return e}));function U(){!N.selectedSku.id||N.selectedSku.id<=0?t.$helper.toast("请选择规格"):N.selectedSku.stock<=0?t.$helper.toast("库存不足"):j("buy",N.selectedSku)}function V(e=!1,s=0,t=0){let l=[];if(e)for(let r of E.value)r.stock<=0||r.value_id_array.indexOf(t)>=0&&l.push(r);else l=B();let o=[];for(let r of l)o=o.concat(r.value_id_array);if(o=Array.from(new Set(o)),e){let e=o.indexOf(t);o.splice(e,1)}else N.currentPropertyArray.forEach((e=>{if(""!==e.toString())return;let s=o.indexOf(e);s>=0&&o.splice(s,1)}));let a=[];e?a=[s]:N.currentPropertyArray.forEach(((e,s)=>{""!==e&&a.push(s)}));for(let r in $)if(!(a.indexOf($[r].id)>=0))for(let e in $[r].values)$[r].values[e].disabled=o.indexOf($[r].values[e].id)<0}function B(){let e=[];for(let s of E.value){if(s.stock<=0)continue;let t=!0;N.currentPropertyArray.forEach((e=>{""!==e.toString()&&s.value_id_array.indexOf(e)<0&&(t=!1)})),t&&e.push(s)}return e}return a((()=>N.selectedSku),(e=>{j("change",e)}),{immediate:!0,deep:!0}),V(!1),(e,l)=>{const o=k,a=x,A=h,O=r(c("su-number-box"),v),C=S,E=r(c("su-popup"),w);return u(),n(E,{show:P.show,round:"10",onClose:l[2]||(l[2]=e=>j("close"))},{default:d((()=>[f(a,{class:"ss-modal-box bg-white ss-flex-col"},{default:d((()=>[f(a,{class:"modal-header ss-flex ss-col-center"},{default:d((()=>[f(a,{class:"header-left ss-m-r-30"},{default:d((()=>[f(o,{class:"sku-image",src:s(t).$url.cdn(N.selectedSku.picUrl||P.goodsInfo.picUrl),mode:"aspectFill"},null,8,["src"])])),_:1}),f(a,{class:"header-right ss-flex-col ss-row-between ss-flex-1"},{default:d((()=>[f(a,{class:"goods-title ss-line-2"},{default:d((()=>[f(a,{class:"tig ss-flex ss-col-center"},{default:d((()=>[f(a,{class:"tig-icon ss-flex ss-col-center ss-row-center"},{default:d((()=>[f(a,{class:"groupon-tag"},{default:d((()=>[f(o,{src:s(t).$url.static("/static/img/shop/goods/groupon-tag-white.png")},null,8,["src"])])),_:1})])),_:1}),f(a,{class:"tig-title"},{default:d((()=>[i("拼团价")])),_:1})])),_:1}),f(a,{class:"info-title"},{default:d((()=>[i(p(P.goodsInfo.name),1)])),_:1})])),_:1}),f(a,{class:"header-right-bottom ss-flex ss-col-center ss-row-between"},{default:d((()=>[f(a,{class:"price-text"},{default:d((()=>[i(p(s(I)(P.goodsInfo.price)),1)])),_:1}),f(a,{class:"stock-text ss-m-l-20"},{default:d((()=>[i(" 库存"+p(N.selectedSku.stock||P.goodsInfo.stock)+"件 ",1)])),_:1})])),_:1})])),_:1})])),_:1}),f(a,{class:"modal-content ss-flex-1"},{default:d((()=>[f(C,{"scroll-y":"true",class:"modal-content-scroll"},{default:d((()=>[(u(!0),g(m,null,_(s($),(e=>(u(),n(a,{class:"sku-item ss-m-b-20",key:e.id},{default:d((()=>[f(a,{class:"label-text ss-m-b-20"},{default:d((()=>[i(p(e.name),1)])),_:2},1024),f(a,{class:"ss-flex ss-col-center ss-flex-wrap"},{default:d((()=>[(u(!0),g(m,null,_(e.values,(s=>(u(),n(A,{class:y(["ss-reset-button spec-btn",[{"checked-btn":N.currentPropertyArray[e.id]===s.id},{"disabled-btn":!0===s.disabled}]]),key:s.id,disabled:!0===s.disabled,onClick:t=>function(e,s){let t=!0;void 0!==N.currentPropertyArray[e]&&N.currentPropertyArray[e]===s?(t=!1,N.currentPropertyArray.splice(e,1,"")):N.currentPropertyArray[e]=s;let l=[];N.currentPropertyArray.forEach((e=>{""!==e&&l.push(e)}));let o=B();l.length===$.length&&o.length?(o[0].count=N.selectedSku.count||1,N.selectedSku=o[0]):N.selectedSku={},V(t,e,s)}(e.id,s.id)},{default:d((()=>[i(p(s.name),1)])),_:2},1032,["class","disabled","onClick"])))),128))])),_:2},1024)])),_:2},1024)))),128)),f(a,{class:"buy-num-box ss-flex ss-col-center ss-row-between"},{default:d((()=>[f(a,{class:"label-text"},{default:d((()=>[i("购买数量")])),_:1}),f(O,{min:1,max:N.selectedSku.stock,step:1,modelValue:N.selectedSku.count,"onUpdate:modelValue":l[0]||(l[0]=e=>N.selectedSku.count=e),onChange:l[1]||(l[1]=e=>{var s;0!==(s=e)&&N.selectedSku.count!==s&&(N.selectedSku.count=s)}),activity:"groupon"},null,8,["max","modelValue"])])),_:1})])),_:1})])),_:1}),f(a,{class:"modal-footer ss-p-y-20"},{default:d((()=>[f(a,{class:"buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center"},{default:d((()=>[f(a,{class:"ss-flex"},{default:d((()=>[f(A,{class:"ss-reset-button origin-price-btn ss-flex-col"},{default:d((()=>[f(a,{class:"btn-title"},{default:d((()=>[i(p(P.grouponNum+"人团"),1)])),_:1})])),_:1}),f(A,{class:"ss-reset-button btn-tox ss-flex-col",onClick:U},{default:d((()=>[f(a,{class:"btn-price"},{default:d((()=>[i(p(s(I)(P.goodsInfo.price)),1)])),_:1}),"create"===P.grouponAction?(u(),n(a,{key:0},{default:d((()=>[i("立即开团")])),_:1})):"join"===P.grouponAction?(u(),n(a,{key:1},{default:d((()=>[i("参与拼团")])),_:1})):b("",!0)])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-96278e19"]]);export{j as _};
|