1 |
- import{c as e,s,z as o,Z as t,a0 as l,m as a,n,f as d,g as u,w as c,k as i,u as r,v as f,i as p,x as g,G as k,l as y,F as m,r as _,E as I,a1 as h,a2 as b,y as S,j as x,I as w,J as v,a3 as P,D as T,e as C,o as j,a4 as A,q as $,a5 as F,S as V,a6 as M,U as O,t as U,a7 as L}from"./index-ba48620e.js";import{_ as D}from"./s-empty.a75760f9.js";import{_ as E}from"./su-swiper.e0d6d17f.js";import{_ as B}from"./su-number-box.45a74a8f.js";import{_ as G}from"./phone-international-input.dd3ca29e.js";import{_ as Q}from"./points.c381a8e1.js";import{c as q,a as z,f as J,b as H,p as N,d as W}from"./useGoods.edb8879f.js";import{_ as Z}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as K}from"./s-layout.04b95866.js";import{d as R,a as X,_ as Y,b as ee,c as se,e as oe}from"./detail-content-card.14f775e9.js";/* empty css */import"./comment-item.f8c71369.js";import"./uni-rate.57225bc8.js";import"./su-image.d4b7cd31.js";import"./mp-html.c71b528b.js";const te=Z({__name:"s-select-sku",props:{goodsInfo:{type:Object,default(){}},show:{type:Boolean,default:!1}},emits:["change","addCart","buy","close"],setup(C,{emit:j}){const A=j,$=C,F=e((()=>s.$store("user").userWallet)),V=o({selectedSku:{},currentPropertyArray:[]}),M=q($.goodsInfo.skus),O=e((()=>{let e=$.goodsInfo.skus;for(let s of e)s.value_id_array=s.properties.map((e=>e.valueId));return e}));function U(){$.goodsInfo.highPrecision?V.selectedSku.goods_num=parseInt(V.selectedSku.use_points/(V.selectedSku.highPrecisionPrice/100)):V.selectedSku.goods_num=parseInt(V.selectedSku.use_points/J(V.selectedSku.price))}async function L(){const{code:e,data:s}=await h.getDuserInfo(),o=parseFloat(N(s.integralDO.currentQuota));console.log(o),V.selectedSku.use_points=parseInt(o),U()}function D(e){const o=e.detail.value;if(console.log(typeof o),""==o)return!1;const t=parseFloat(N(F.value.integralDO.currentQuota));U(),b((()=>{V.selectedSku.use_points=parseInt(o),U()})),o<=0&&(s.$helper.toast("最低使用1积分"),b(t>=1?()=>{V.selectedSku.use_points=1,U()}:()=>{V.selectedSku.use_points=0,U()})),o>t&&(s.$helper.toast("可用积分不足"),b((()=>{V.selectedSku.use_points=parseInt(t),U()})))}function E(){V.selectedSku.id<=0?s.$helper.toast("请选择规格"):V.selectedSku.stock<=0?s.$helper.toast("库存不足"):A("addCart",V.selectedSku)}async function W(){if(2==$.goodsInfo.spuPayType){const{code:e,data:o}=await h.getDuserInfo();if(parseFloat(N(o.integralDO.currentQuota))<V.selectedSku.use_points)return s.$helper.toast("可用积分不足"),!1;if(V.selectedSku.goods_num<1||!V.selectedSku.use_points)return void s.$helper.toast("输入金额少于可购买数量");V.selectedSku.goods_num>V.selectedSku.stock&&(V.selectedSku.use_points=(V.selectedSku.stock*J(V.selectedSku.price)).toFixed(2),V.selectedSku.goods_num=V.selectedSku.stock)}V.selectedSku.id<=0?s.$helper.toast("请选择规格"):V.selectedSku.stock<=0?s.$helper.toast("库存不足"):(A("buy",V.selectedSku),V.selectedSku.use_points=0)}function Z(e=!1,s=0,o=0){let t=[];if(e)for(let n of O.value)n.stock<=0||n.value_id_array.indexOf(o)>=0&&t.push(n);else t=K();let l=[];for(let n of t)l=l.concat(n.value_id_array);if(l=Array.from(new Set(l)),e){let e=l.indexOf(o);l.splice(e,1)}else V.currentPropertyArray.forEach((e=>{if(""!==e.toString())return;let s=l.indexOf(e);s>=0&&l.splice(s,1)}));let a=[];e?a=[s]:V.currentPropertyArray.forEach(((e,s)=>{""!==e&&a.push(s)}));for(let n in M)if(!(a.indexOf(M[n].id)>=0))for(let e in M[n].values)M[n].values[e].disabled=l.indexOf(M[n].values[e].id)<0}function K(){let e=[];for(let s of O.value){if(s.stock<=0)continue;let o=!0;V.currentPropertyArray.forEach((e=>{""!==e.toString()&&s.value_id_array.indexOf(e)<0&&(o=!1)})),o&&e.push(s)}return e}function R(e,s){V.selectedSku.use_points=0;let o=!0;void 0!==V.currentPropertyArray[e]&&V.currentPropertyArray[e]===s?(o=!1,V.currentPropertyArray.splice(e,1,"")):V.currentPropertyArray[e]=s;let t=[];V.currentPropertyArray.forEach((e=>{""!==e&&t.push(e)}));let l=K();t.length===M.length&&l.length?(l[0].goods_num=V.selectedSku.goods_num||1,V.selectedSku=l[0]):V.selectedSku={},Z(o,e,s)}return t((()=>V.selectedSku),(e=>{A("change",e)}),{immediate:!0,deep:!0}),Z(!1),l((()=>{1==M.length&&1==M[0].values.length&&R(0,0)})),(e,s)=>{const o=S,t=x,l=w,h=v,b=P,j=a(n("su-number-box"),B),$=T,O=a(n("su-popup"),G);return d(),u(O,{show:C.show,round:"10",onClose:s[4]||(s[4]=e=>A("close"))},{default:c((()=>[i(t,{class:"ss-modal-box bg-white ss-flex-col"},{default:c((()=>[i(t,{class:"modal-header ss-flex ss-col-center"},{default:c((()=>[i(t,{class:"header-left ss-m-r-30"},{default:c((()=>[i(o,{class:"sku-image",src:V.selectedSku.picUrl||C.goodsInfo.picUrl,mode:"aspectFill"},null,8,["src"])])),_:1}),i(t,{class:"header-right ss-flex-col ss-row-between ss-flex-1"},{default:c((()=>[i(t,{class:"goods-title ss-line-2"},{default:c((()=>[r(f(C.goodsInfo.name),1)])),_:1}),i(t,{class:"header-right-bottom ss-flex ss-col-center ss-row-between"},{default:c((()=>[i(t,{class:"ss-flex"},{default:c((()=>[i(t,{class:"price-text"},{default:c((()=>[2==C.goodsInfo.spuPayType?(d(),u(o,{key:0,src:Q,style:{width:"30rpx",height:"30rpx"}})):p("",!0),C.goodsInfo.highPrecision?(d(),u(l,{key:1},{default:c((()=>[r(f(g(z)(V.selectedSku.highPrecisionPrice||C.goodsInfo.highPrecisionPrice)),1)])),_:1})):(d(),u(l,{key:2},{default:c((()=>[r(f(g(J)(V.selectedSku.price||C.goodsInfo.price)),1)])),_:1}))])),_:1}),V.selectedSku.promotionFee>=0||C.goodsInfo.promotionFee>=0?(d(),u(t,{key:0,class:"origin-price-text ss-m-l-10"},{default:c((()=>[r(" 积分:"+f(g(J)(V.selectedSku.promotionFee||C.goodsInfo.promotionFee)),1)])),_:1})):p("",!0)])),_:1}),i(t,{class:"stock-text ss-m-l-20"},{default:c((()=>[r(f(g(H)("exact",V.selectedSku.stock||C.goodsInfo.stock)),1)])),_:1})])),_:1})])),_:1})])),_:1}),i(t,{class:"modal-content ss-flex-1"},{default:c((()=>[i($,{"scroll-y":"true",class:"modal-content-scroll",onTouchmove:s[3]||(s[3]=k((()=>{}),["stop"]))},{default:c((()=>[(d(!0),y(m,null,_(g(M),(e=>(d(),u(t,{class:"sku-item ss-m-b-20",key:e.id},{default:c((()=>[i(t,{class:"label-text ss-m-b-20"},{default:c((()=>[r(f(e.name),1)])),_:2},1024),i(t,{class:"ss-flex ss-col-center ss-flex-wrap"},{default:c((()=>[(d(!0),y(m,null,_(e.values,(s=>(d(),u(h,{class:I(["ss-reset-button spec-btn",[{"ui-BG-Main-Gradient":V.currentPropertyArray[e.id]===s.id},{"disabled-btn":!0===s.disabled}]]),key:s.id,disabled:!0===s.disabled,onClick:o=>R(e.id,s.id)},{default:c((()=>[r(f(s.name),1)])),_:2},1032,["class","disabled","onClick"])))),128))])),_:2},1024)])),_:2},1024)))),128)),2==C.goodsInfo.spuPayType?(d(),u(t,{key:0,class:"buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40"},{default:c((()=>[i(t,{class:"label-text"},{default:c((()=>[r("购买金额 (当前可用积分:"+f(g(N)(F.value.integralDO.currentQuota))+")",1)])),_:1}),i(t,{class:"ss-flex ss-col-center"},{default:c((()=>[i(h,{class:"ss-reset-button all-btn",onClick:L},{default:c((()=>[r("全部")])),_:1}),2==C.goodsInfo.spuPayType?(d(),u(o,{key:0,src:Q,style:{width:"30rpx",height:"30rpx"}})):p("",!0),i(b,{modelValue:V.selectedSku.use_points,"onUpdate:modelValue":s[0]||(s[0]=e=>V.selectedSku.use_points=e),class:"uni-input input-points",style:{width:"100rpx","text-align":"center"},type:"number",placeholder:"0",onInput:D,disabled:!V.selectedSku.id},null,8,["modelValue","disabled"])])),_:1})])),_:1})):(d(),u(t,{key:1,class:"buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40"},{default:c((()=>[i(t,{class:"label-text"},{default:c((()=>[r("购买数量")])),_:1}),i(j,{min:1,max:V.selectedSku.stock,step:1,modelValue:V.selectedSku.goods_num,"onUpdate:modelValue":s[1]||(s[1]=e=>V.selectedSku.goods_num=e),onChange:s[2]||(s[2]=e=>{var s;0!==(s=e)&&V.selectedSku.goods_num!==s&&(V.selectedSku.goods_num=s)})},null,8,["max","modelValue"])])),_:1}))])),_:1})])),_:1}),i(t,{class:"modal-footer border-top"},{default:c((()=>[C.goodsInfo.spuType&&1==C.goodsInfo.spuPayType?(d(),u(t,{key:0,class:"buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center"},{default:c((()=>[i(h,{class:"ss-reset-button add-btn ui-Shadow-Main",onClick:E},{default:c((()=>[r("加入购物车")])),_:1}),i(h,{class:"ss-reset-button buy-btn ui-Shadow-Main",onClick:W},{default:c((()=>[r("立即购买")])),_:1})])),_:1})):(d(),u(t,{key:1,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[i(h,{class:"ss-reset-button disabled-btn one-buy-btn ui-Shadow-Main",onClick:W},{default:c((()=>[1==C.goodsInfo.spuPayType||C.goodsInfo.spuType?C.goodsInfo.spuType?(d(),y(m,{key:2},[r(" 立即兑换 ")],64)):(d(),y(m,{key:1},[r(" 立即购买 ")],64)):(d(),y(m,{key:0},[r(" 立即兑换 ")],64))])),_:1})])),_:1}))])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-ce78878e"]]),le=Z({__name:"index",setup(l){C((()=>{}));const k=o({goodsId:0,skeletonLoading:!0,goodsInfo:{},showSelectSku:!1,selectedSku:{},showModel:!1,couponInfo:[],showActivityModel:!1,activityInfo:[],activityList:[],linkId:0});function I(e){k.selectedSku=e}function h(e){e.id?G.value?s.$store("cart").add(e):U():s.$helper.toast("请选择商品规格")}function b(e){k.selectedSku.id?s.$router.go("/pages/order/confirm",{data:JSON.stringify({items:[{skuId:e.id,count:e.goods_num}],spuType:k.goodsInfo.spuType,spuPayType:k.goodsInfo.spuPayType,highPrecision:k.goodsInfo.highPrecision,deliveryType:1,pointStatus:!1})}):s.$helper.toast("请选择商品规格")}function P(){k.showActivityModel=!0}const T=e((()=>L.isEmpty(k.goodsInfo)?{}:s.$platform.share.getShareInfo({title:k.goodsInfo.name,image:s.$url.cdn(k.goodsInfo.image),desc:k.goodsInfo.subtitle,params:{page:"2"}},{type:"goods",title:k.goodsInfo.name,introduction:k.goodsInfo.introduction,image:s.$url.cdn(k.goodsInfo.picUrl),price:J(k.goodsInfo.price),original_price:J(k.goodsInfo.maretPrice)})));async function B(e){V.getSpuDetail(e).then((e=>{0===e.code&&e.data?(k.skeletonLoading=!1,k.goodsInfo=e.data,console.log(k.goodsInfo),G.value&&M.isFavoriteExists(k.goodsId,"goods").then((e=>{0===e.code&&(k.goodsInfo.favorite=e.data)}))):k.goodsInfo=null}))}const G=e((()=>s.$store("user").isLogin));return t((()=>G.value),(e=>{e&&B(k.goodsId)})),j((e=>{if(e.id||e.linkId){if(k.goodsId=e.id||0,!e.id&&e.linkId){console.log("如果只是没有spuId有linkId的话 要去linkId对应的spuId");const s=e.linkId.toString();A.getObjectIdByLinkId(s).then((e=>{0===e.code&&(k.goodsId=e.data,B(k.goodsId),async function(){A.getLinkId(3,k.goodsId).then((e=>{0===e.code&&(k.linkId=e.data.linkId)}))}())})),$("linkId",e.linkId)}else B(k.goodsId);F.getActivityListBySpuId(k.goodsId).then((e=>{0===e.code&&e.data.forEach((e=>{[1,2,3].includes(e.type)?k.activityList.push(e):5===e.type?k.activityInfo.push(e):console.log("待实现!优先级不高")}))}))}else k.goodsInfo=null})),(e,s)=>{const o=a(n("s-empty"),D),t=a(n("su-swiper"),E),l=S,C=w,j=x,A=a(n("s-select-sku"),te),$=v,F=a(n("s-layout"),K);return d(),u(j,null,{default:c((()=>[i(F,{onShareAppMessage:T.value,navbar:"goods"},{default:c((()=>[i(R,{modelValue:k.goodsInfo,"onUpdate:modelValue":s[0]||(s[0]=e=>k.goodsInfo=e)},null,8,["modelValue"]),k.skeletonLoading?(d(),u(X,{key:0})):null===k.goodsInfo?(d(),u(o,{key:1,text:"商品不存在或已下架",icon:"/static/soldout-empty.png",showAction:"",actionText:"再逛逛",actionUrl:"/pages/goods/list"})):(d(),y(m,{key:2},[i(j,{class:"detail-swiper-selector"},{default:c((()=>[i(t,{class:"ss-m-b-14",isPreview:"",list:g(W)(k.goodsInfo.sliderPicUrls),otStyle:"tag",imageMode:"widthFix",dotCur:"bg-mask-40",seizeHeight:750},null,8,["list"]),i(j,{class:"title-card detail-card ss-p-y-40 ss-p-x-20"},{default:c((()=>[i(j,{class:"ss-flex ss-row-between ss-col-center ss-m-b-26"},{default:c((()=>[i(j,{class:"price-box ss-flex ss-col-center"},{default:c((()=>[i(j,{class:"price-text ss-m-r-16 ss-flex ss-col-center"},{default:c((()=>[2==k.goodsInfo.spuPayType?(d(),u(l,{key:0,src:Q,class:"ss-m-r-10",style:{width:"40rpx",height:"40rpx"}})):(d(),u(C,{key:1},{default:c((()=>[r("¥")])),_:1})),k.goodsInfo.highPrecision?(d(),u(C,{key:2},{default:c((()=>[r(f(g(z)(k.selectedSku.highPrecisionPrice||k.goodsInfo.highPrecisionPrice)),1)])),_:1})):(d(),u(C,{key:3},{default:c((()=>[r(f(g(J)(k.selectedSku.price||k.goodsInfo.price)),1)])),_:1}))])),_:1}),k.goodsInfo.promotionFee>=0?(d(),u(j,{key:0,class:"origin-price-text"},{default:c((()=>[r(" 积分:"+f(g(J)(k.selectedSku.promotionFee||k.goodsInfo.promotionFee)),1)])),_:1})):p("",!0)])),_:1}),i(j,{class:"sales-text"})])),_:1}),i(j,{class:"discounts-box ss-flex ss-row-between ss-m-b-28"},{default:c((()=>[O("div",{class:"tag-content"},[i(j,{class:"tag-box ss-flex"},{default:c((()=>[(d(!0),y(m,null,_(k.activityInfo,(e=>(d(),u(j,{class:"tag ss-m-r-10",key:e.id,onClick:P},{default:c((()=>[r(f(e.name),1)])),_:2},1024)))),128))])),_:1})]),k.couponInfo.length?(d(),u(j,{key:0,class:"get-coupon-box ss-flex ss-col-center ss-m-l-20",onClick:s[1]||(s[1]=e=>k.showModel=!0)},{default:c((()=>[i(j,{class:"discounts-title ss-m-r-8"},{default:c((()=>[r("领券")])),_:1}),i(C,{class:"cicon-forward"})])),_:1})):p("",!0)])),_:1}),i(j,{class:"title-text ss-line-2 ss-m-b-6"},{default:c((()=>[r(f(k.goodsInfo.name),1)])),_:1}),i(j,{class:"subtitle-text ss-line-1"},{default:c((()=>[r(f(k.goodsInfo.introduction),1)])),_:1})])),_:1}),i(j,{class:"detail-cell-card detail-card ss-flex-col"},{default:c((()=>[i(Y,{modelValue:k.selectedSku.goods_sku_text,"onUpdate:modelValue":s[2]||(s[2]=e=>k.selectedSku.goods_sku_text=e),sku:k.selectedSku,onClick:s[3]||(s[3]=e=>k.showSelectSku=!0)},null,8,["modelValue","sku"])])),_:1}),i(A,{goodsInfo:k.goodsInfo,show:k.showSelectSku,onAddCart:h,onBuy:b,onChange:I,onClose:s[4]||(s[4]=e=>k.showSelectSku=!1)},null,8,["goodsInfo","show"])])),_:1}),i(ee,{class:"detail-comment-selector",goodsId:k.goodsId},null,8,["goodsId"]),i(se,{class:"detail-content-selector",content:k.goodsInfo.description},null,8,["content"]),i(oe,{modelValue:k.goodsInfo,"onUpdate:modelValue":s[8]||(s[8]=e=>k.goodsInfo=e)},{default:c((()=>[k.goodsInfo.stock>0&&k.goodsInfo.spuType&&1==k.goodsInfo.spuPayType?(d(),u(j,{key:0,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[i($,{class:"ss-reset-button add-btn ui-Shadow-Main",onClick:s[5]||(s[5]=e=>k.showSelectSku=!0)},{default:c((()=>[r(" 加入购物车 ")])),_:1}),i($,{class:"ss-reset-button buy-btn ui-Shadow-Main",onClick:s[6]||(s[6]=e=>k.showSelectSku=!0)},{default:c((()=>[r(" 立即购买 ")])),_:1})])),_:1})):k.goodsInfo.stock>0&&1!=k.goodsInfo.spuPayType||!k.goodsInfo.spuType?(d(),u(j,{key:1,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[i($,{class:"ss-reset-button disabled-btn buy-btn ui-Shadow-Main",onClick:s[7]||(s[7]=e=>k.showSelectSku=!0)},{default:c((()=>[1==k.goodsInfo.spuPayType||k.goodsInfo.spuType?k.goodsInfo.spuType?(d(),y(m,{key:2},[r(" 立即兑换 ")],64)):(d(),y(m,{key:1},[r(" 立即购买 ")],64)):(d(),y(m,{key:0},[r(" 立即兑换 ")],64))])),_:1})])),_:1})):(d(),u(j,{key:2,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[i($,{class:"ss-reset-button disabled-btn",disabled:"",style:{background:"#999999"}},{default:c((()=>[r(" 已售罄 ")])),_:1})])),_:1}))])),_:1},8,["modelValue"])],64))])),_:1},8,["onShareAppMessage"])])),_:1})}}},[["__scopeId","data-v-3dad46b1"]]);export{le as default};
|