1 |
- import{v as s,c as e,a6 as t,l as o,m as l,e as a,f as d,w as c,j as n,p as i,t as u,u as r,A as f,k as p,F as m,r as g,z as _,s as y,q as k,i as b,D as h,S as x,C as v,a7 as w,B as I,g as S,d as C,o as j,a2 as A,a1 as M,a3 as V,a8 as $}from"./index-9880b451.js";import{_ as P}from"./s-empty.74111684.js";import{_ as O}from"./su-swiper.55cf865c.js";import{_ as L}from"./su-number-box.8b58381a.js";import{d as T,a as U,_ as E}from"./s-layout.dfc5b0b5.js";import{c as B,f as G,a as F,b as D,d as q,e as z}from"./useGoods.bdd1c2ea.js";import{_ as R}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as H}from"./s-coupon-list.39460476.js";import{R as J}from"./rewardActivity.ffbd3c12.js";import{F as N}from"./favorite.390dabed.js";import{d as Y,a as Z,_ as K,b as Q,c as W,e as X}from"./detail-content-card.546d07c2.js";import{S as ss}from"./spu.3137f763.js";/* empty css */import"./index.df38848e.js";import"./comment-item.6bcd8e43.js";import"./uni-rate.ac7990fe.js";import"./su-image.53d60b59.js";import"./mp-html.1d0f8654.js";const es=R({__name:"s-select-sku",props:{goodsInfo:{type:Object,default(){}},show:{type:Boolean,default:!1}},emits:["change","addCart","buy","close"],setup(v,{emit:w}){const I=v,S=s({selectedSku:{},currentPropertyArray:[]}),C=B(I.goodsInfo.skus),j=e((()=>{let s=I.goodsInfo.skus;for(let e of s)e.value_id_array=e.properties.map((s=>s.valueId));return s}));function A(){S.selectedSku.id<=0?y.$helper.toast("请选择规格"):S.selectedSku.stock<=0?y.$helper.toast("库存不足"):w("addCart",S.selectedSku)}function M(){S.selectedSku.id<=0?y.$helper.toast("请选择规格"):S.selectedSku.stock<=0?y.$helper.toast("库存不足"):w("buy",S.selectedSku)}function V(s=!1,e=0,t=0){let o=[];if(s)for(let d of j.value)d.stock<=0||d.value_id_array.indexOf(t)>=0&&o.push(d);else o=$();let l=[];for(let d of o)l=l.concat(d.value_id_array);if(l=Array.from(new Set(l)),s){let s=l.indexOf(t);l.splice(s,1)}else S.currentPropertyArray.forEach((s=>{if(""!==s.toString())return;let e=l.indexOf(s);e>=0&&l.splice(e,1)}));let a=[];s?a=[e]:S.currentPropertyArray.forEach(((s,e)=>{""!==s&&a.push(e)}));for(let d in C)if(!(a.indexOf(C[d].id)>=0))for(let s in C[d].values)C[d].values[s].disabled=l.indexOf(C[d].values[s].id)<0}function $(){let s=[];for(let e of j.value){if(e.stock<=0)continue;let t=!0;S.currentPropertyArray.forEach((s=>{""!==s.toString()&&e.value_id_array.indexOf(s)<0&&(t=!1)})),t&&s.push(e)}return s}return t((()=>S.selectedSku),(s=>{w("change",s)}),{immediate:!0,deep:!0}),V(!1),(s,e)=>{const t=k,y=b,I=h,j=o(l("su-number-box"),L),P=x,O=o(l("su-popup"),T);return a(),d(O,{show:v.show,round:"10",onClose:e[3]||(e[3]=s=>w("close"))},{default:c((()=>[n(y,{class:"ss-modal-box bg-white ss-flex-col"},{default:c((()=>[n(y,{class:"modal-header ss-flex ss-col-center"},{default:c((()=>[n(y,{class:"header-left ss-m-r-30"},{default:c((()=>[n(t,{class:"sku-image",src:S.selectedSku.picUrl||v.goodsInfo.picUrl,mode:"aspectFill"},null,8,["src"])])),_:1}),n(y,{class:"header-right ss-flex-col ss-row-between ss-flex-1"},{default:c((()=>[n(y,{class:"goods-title ss-line-2"},{default:c((()=>[i(u(v.goodsInfo.name),1)])),_:1}),n(y,{class:"header-right-bottom ss-flex ss-col-center ss-row-between"},{default:c((()=>[n(y,{class:"ss-flex"},{default:c((()=>[n(y,{class:"price-text"},{default:c((()=>[i(u(r(G)(S.selectedSku.price||v.goodsInfo.price)),1)])),_:1})])),_:1}),n(y,{class:"stock-text ss-m-l-20"},{default:c((()=>[i(u(r(F)("exact",S.selectedSku.stock||v.goodsInfo.stock)),1)])),_:1})])),_:1})])),_:1})])),_:1}),n(y,{class:"modal-content ss-flex-1"},{default:c((()=>[n(P,{"scroll-y":"true",class:"modal-content-scroll",onTouchmove:e[2]||(e[2]=f((()=>{}),["stop"]))},{default:c((()=>[(a(!0),p(m,null,g(r(C),(s=>(a(),d(y,{class:"sku-item ss-m-b-20",key:s.id},{default:c((()=>[n(y,{class:"label-text ss-m-b-20"},{default:c((()=>[i(u(s.name),1)])),_:2},1024),n(y,{class:"ss-flex ss-col-center ss-flex-wrap"},{default:c((()=>[(a(!0),p(m,null,g(s.values,(e=>(a(),d(I,{class:_(["ss-reset-button spec-btn",[{"ui-BG-Main-Gradient":S.currentPropertyArray[s.id]===e.id},{"disabled-btn":!0===e.disabled}]]),key:e.id,disabled:!0===e.disabled,onClick:t=>function(s,e){let t=!0;void 0!==S.currentPropertyArray[s]&&S.currentPropertyArray[s]===e?(t=!1,S.currentPropertyArray.splice(s,1,"")):S.currentPropertyArray[s]=e;let o=[];S.currentPropertyArray.forEach((s=>{""!==s&&o.push(s)}));let l=$();o.length===C.length&&l.length?(l[0].goods_num=S.selectedSku.goods_num||1,S.selectedSku=l[0]):S.selectedSku={},V(t,s,e)}(s.id,e.id)},{default:c((()=>[i(u(e.name),1)])),_:2},1032,["class","disabled","onClick"])))),128))])),_:2},1024)])),_:2},1024)))),128)),n(y,{class:"buy-num-box ss-flex ss-col-center ss-row-between ss-m-b-40"},{default:c((()=>[n(y,{class:"label-text"},{default:c((()=>[i("购买数量")])),_:1}),n(j,{min:1,max:S.selectedSku.stock,step:1,modelValue:S.selectedSku.goods_num,"onUpdate:modelValue":e[0]||(e[0]=s=>S.selectedSku.goods_num=s),onChange:e[1]||(e[1]=s=>{var e;0!==(e=s)&&S.selectedSku.goods_num!==e&&(S.selectedSku.goods_num=e)})},null,8,["max","modelValue"])])),_:1})])),_:1})])),_:1}),n(y,{class:"modal-footer border-top"},{default:c((()=>[n(y,{class:"buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center"},{default:c((()=>[n(I,{class:"ss-reset-button add-btn ui-Shadow-Main",onClick:A},{default:c((()=>[i("加入购物车")])),_:1}),n(I,{class:"ss-reset-button buy-btn ui-Shadow-Main",onClick:M},{default:c((()=>[i("立即购买")])),_:1})])),_:1})])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-eb143562"]]),ts=R({__name:"s-coupon-get",props:{modelValue:{type:Object,default(){}},show:{type:Boolean,default:!1}},emits:["get","close"],setup(t,{emit:r}){const y=t,k=s({couponInfo:e((()=>y.modelValue))});return(s,e)=>{const y=b,v=h,w=o(l("s-coupon-list"),H),I=x,S=o(l("su-popup"),T);return a(),d(S,{show:t.show,type:"bottom",round:"20",onClose:e[0]||(e[0]=s=>r("close")),showClose:"",backgroundColor:"#f2f2f2"},{default:c((()=>[n(y,{class:"model-box"},{default:c((()=>[n(y,{class:"title ss-m-t-16 ss-m-l-20 ss-flex"},{default:c((()=>[i("优惠券")])),_:1}),n(I,{class:"model-content","scroll-y":"","scroll-with-animation":!1,"enable-back-to-top":!0},{default:c((()=>[n(y,{class:"subtitle ss-m-l-20"},{default:c((()=>[i("可使用优惠券")])),_:1}),(a(!0),p(m,null,g(k.couponInfo,(s=>(a(),d(y,{key:s.id},{default:c((()=>[n(w,{data:s},{default:c((()=>[n(v,{class:_(["ss-reset-button card-btn ss-flex ss-row-center ss-col-center",s.canTake?"":"boder-btn"]),onClick:f((e=>{return t=s.id,void r("get",t);var t}),["stop"]),disabled:!s.canTake},{default:c((()=>[i(u(s.canTake?"立即领取":"已领取"),1)])),_:2},1032,["class","onClick","disabled"])])),_:2},1032,["data"])])),_:2},1024)))),128))])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-3a9aaf40"]]),os=R({__name:"s-activity-pop",props:{modelValue:{type:Object,default(){}},show:{type:Boolean,default:!1}},emits:["close"],setup(f,{emit:_}){const k=f,h=s({activityInfo:e((()=>k.modelValue)),activityMap:{}});return t((()=>k.show),(()=>{var s;k.show&&(null==(s=h.activityInfo)||s.forEach((s=>{J.getRewardActivity(s.id).then((e=>{0===e.code&&(h.activityMap[s.id]=e.data)}))})))})),(s,e)=>{const t=b,k=v,w=x,I=o(l("su-popup"),T);return a(),d(I,{show:f.show,type:"bottom",round:"20",onClose:e[0]||(e[0]=s=>_("close")),showClose:""},{default:c((()=>[n(t,{class:"model-box"},{default:c((()=>[n(t,{class:"title ss-m-t-16 ss-m-l-20 ss-flex"},{default:c((()=>[i("营销活动")])),_:1}),n(w,{class:"model-content ss-m-t-50","scroll-y":"","scroll-with-animation":!1,"enable-back-to-top":!0},{default:c((()=>[(a(!0),p(m,null,g(h.activityInfo,(s=>(a(),d(t,{key:s.id},{default:c((()=>[n(t,{class:"ss-flex ss-col-top ss-m-b-40",onClick:e=>{return t=s,void y.$router.go("/pages/activity/index",{activityId:t.id});var t}},{default:c((()=>[n(t,{class:"model-content-tag ss-flex ss-row-center"},{default:c((()=>[i("满减")])),_:1}),n(t,{class:"ss-m-l-20 model-content-title ss-flex-1"},{default:c((()=>{var e;return[(a(!0),p(m,null,g(null==(e=h.activityMap[s.id])?void 0:e.rules,(e=>(a(),d(t,{class:"ss-m-b-24",key:e},{default:c((()=>[i(u(r(D)(h.activityMap[s.id],e)),1)])),_:2},1024)))),128))]})),_:2},1024),n(k,{class:"cicon-forward"})])),_:2},1032,["onClick"])])),_:2},1024)))),128))])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-fdb00d48"]]),ls=s=>w({url:"/promotion/activity/list-by-spu-id",method:"GET",params:{spuId:s}}),as=R({__name:"detail-activity-tip",props:{activityList:{type:Array,default:()=>[]}},setup(s){const e=s;I((s=>({"78cc2f40":r(t),"584588ef":r(f)})));const t=y.$url.css("/static/img/shop/goods/seckill-tip-bg.png"),f=y.$url.css("/static/img/shop/goods/groupon-tip-bg.png");return(s,t)=>{const f=k,x=b,v=h,w=o(l("su-fixed"),U);return a(),d(w,{bottom:"",placeholder:"",val:44},{default:c((()=>[n(x,null,{default:c((()=>[(a(!0),p(m,null,g(e.activityList,(s=>(a(),d(x,{key:s.id},{default:c((()=>[n(x,{class:_(["activity-box ss-p-x-38 ss-flex ss-row-between ss-col-center",1===s.type?"seckill-box":"groupon-box"])},{default:c((()=>[n(x,{class:"activity-title ss-flex"},{default:c((()=>[n(x,{class:"ss-m-r-16"},{default:c((()=>[1===s.type?(a(),d(f,{key:0,src:r(y).$url.static("/static/img/shop/goods/seckill-icon.png"),class:"activity-icon"},null,8,["src"])):3===s.type?(a(),d(f,{key:1,src:r(y).$url.static("/static/img/shop/goods/groupon-icon.png"),class:"activity-icon"},null,8,["src"])):S("",!0)])),_:2},1024),n(x,null,{default:c((()=>[i("该商品正在参与"+u(s.name)+"活动",1)])),_:2},1024)])),_:2},1024),n(v,{class:"ss-reset-button activity-go",onClick:e=>function(s){const e=s.type,t=1===e?"seckill":2===e?"TODO 拼团":"groupon";y.$router.go(`/pages/goods/${t}`,{id:s.id})}(s)},{default:c((()=>[i(" GO ")])),_:2},1032,["onClick"])])),_:2},1032,["class"])])),_:2},1024)))),128))])),_:1})])),_:1})}}},[["__scopeId","data-v-fedbc64b"]]),ds=R({__name:"index",setup(t){C((()=>{}));const f=s({goodsId:0,skeletonLoading:!0,goodsInfo:{},showSelectSku:!1,selectedSku:{},showModel:!1,couponInfo:[],showActivityModel:!1,activityInfo:[],activityList:[]});function _(s){f.selectedSku=s}function k(s){s.id?y.$store("cart").add(s):y.$helper.toast("请选择商品规格")}function x(s){f.selectedSku.id?y.$router.go("/pages/order/confirm",{data:JSON.stringify({items:[{skuId:s.id,count:s.goods_num}],deliveryType:1,pointStatus:!1})}):y.$helper.toast("请选择商品规格")}function w(){f.showActivityModel=!0}async function I(s){const{code:e}=await A.takeCoupon(s);0===e&&(V({title:"领取成功"}),setTimeout((()=>{T()}),1e3))}const L=e((()=>$.isEmpty(f.goodsInfo)?{}:y.$platform.share.getShareInfo({title:f.goodsInfo.name,image:y.$url.cdn(f.goodsInfo.image),desc:f.goodsInfo.subtitle,params:{page:"2",query:f.goodsInfo.id}},{type:"goods",title:f.goodsInfo.name,image:y.$url.cdn(f.goodsInfo.picUrl),price:G(f.goodsInfo.price),original_price:G(f.goodsInfo.maretPrice)})));async function T(){const{code:s,data:e}=await A.getCouponTemplateList(f.goodsId,2,10);0===s&&(f.couponInfo=e)}return j((s=>{s.id?(f.goodsId=s.id,ss.getSpuDetail(f.goodsId).then((s=>{0===s.code&&s.data?(f.skeletonLoading=!1,f.goodsInfo=s.data,N.isFavoriteExists(f.goodsId,"goods").then((s=>{0===s.code&&(f.goodsInfo.favorite=s.data)}))):f.goodsInfo=null})),T(),ls(f.goodsId).then((s=>{0===s.code&&s.data.forEach((s=>{[1,2,3].includes(s.type)?f.activityList.push(s):5===s.type?f.activityInfo.push(s):console.log("待实现!优先级不高")}))}))):f.goodsInfo=null})),(s,e)=>{const t=o(l("s-empty"),P),y=o(l("su-swiper"),O),C=b,j=v,A=o(l("s-select-sku"),es),V=h,$=o(l("s-coupon-get"),ts),T=o(l("s-activity-pop"),os),U=o(l("s-layout"),E);return a(),d(C,null,{default:c((()=>[n(U,{onShareAppMessage:r(L),navbar:"goods"},{default:c((()=>[n(Y),f.skeletonLoading?(a(),d(Z,{key:0})):null===f.goodsInfo?(a(),d(t,{key:1,text:"商品不存在或已下架",icon:"/static/soldout-empty.png",showAction:"",actionText:"再逛逛",actionUrl:"/pages/goods/list"})):(a(),p(m,{key:2},[n(C,{class:"detail-swiper-selector"},{default:c((()=>[n(y,{class:"ss-m-b-14",isPreview:"",list:r(q)(f.goodsInfo.sliderPicUrls),otStyle:"tag",imageMode:"widthFix",dotCur:"bg-mask-40",seizeHeight:750},null,8,["list"]),n(C,{class:"title-card detail-card ss-p-y-40 ss-p-x-20"},{default:c((()=>[n(C,{class:"ss-flex ss-row-between ss-col-center ss-m-b-26"},{default:c((()=>[n(C,{class:"price-box ss-flex ss-col-bottom"},{default:c((()=>[n(C,{class:"price-text ss-m-r-16"},{default:c((()=>[i(u(r(G)(f.selectedSku.price||f.goodsInfo.price)),1)])),_:1}),f.goodsInfo.marketPrice>0?(a(),d(C,{key:0,class:"origin-price-text"},{default:c((()=>[i(u(r(G)(f.selectedSku.marketPrice||f.goodsInfo.marketPrice)),1)])),_:1})):S("",!0)])),_:1}),n(C,{class:"sales-text"},{default:c((()=>[i(u(r(z)("exact",f.goodsInfo.salesCount)),1)])),_:1})])),_:1}),n(C,{class:"discounts-box ss-flex ss-row-between ss-m-b-28"},{default:c((()=>[M("div",{class:"tag-content"},[n(C,{class:"tag-box ss-flex"},{default:c((()=>[(a(!0),p(m,null,g(f.activityInfo,(s=>(a(),d(C,{class:"tag ss-m-r-10",key:s.id,onClick:w},{default:c((()=>[i(u(s.name),1)])),_:2},1024)))),128))])),_:1})]),f.couponInfo.length?(a(),d(C,{key:0,class:"get-coupon-box ss-flex ss-col-center ss-m-l-20",onClick:e[0]||(e[0]=s=>f.showModel=!0)},{default:c((()=>[n(C,{class:"discounts-title ss-m-r-8"},{default:c((()=>[i("领券")])),_:1}),n(j,{class:"cicon-forward"})])),_:1})):S("",!0)])),_:1}),n(C,{class:"title-text ss-line-2 ss-m-b-6"},{default:c((()=>[i(u(f.goodsInfo.name),1)])),_:1}),n(C,{class:"subtitle-text ss-line-1"},{default:c((()=>[i(u(f.goodsInfo.introduction),1)])),_:1})])),_:1}),n(C,{class:"detail-cell-card detail-card ss-flex-col"},{default:c((()=>[n(K,{modelValue:f.selectedSku.goods_sku_text,"onUpdate:modelValue":e[1]||(e[1]=s=>f.selectedSku.goods_sku_text=s),sku:f.selectedSku,onClick:e[2]||(e[2]=s=>f.showSelectSku=!0)},null,8,["modelValue","sku"])])),_:1}),n(A,{goodsInfo:f.goodsInfo,show:f.showSelectSku,onAddCart:k,onBuy:x,onChange:_,onClose:e[3]||(e[3]=s=>f.showSelectSku=!1)},null,8,["goodsInfo","show"])])),_:1}),n(Q,{class:"detail-comment-selector",goodsId:f.goodsId},null,8,["goodsId"]),n(W,{class:"detail-content-selector",content:f.goodsInfo.description},null,8,["content"]),f.activityList.length>0?(a(),d(as,{key:0,"activity-list":f.activityList},null,8,["activity-list"])):S("",!0),n(X,{modelValue:f.goodsInfo,"onUpdate:modelValue":e[6]||(e[6]=s=>f.goodsInfo=s)},{default:c((()=>[f.goodsInfo.stock>0?(a(),d(C,{key:0,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[n(V,{class:"ss-reset-button add-btn ui-Shadow-Main",onClick:e[4]||(e[4]=s=>f.showSelectSku=!0)},{default:c((()=>[i(" 加入购物车 ")])),_:1}),n(V,{class:"ss-reset-button buy-btn ui-Shadow-Main",onClick:e[5]||(e[5]=s=>f.showSelectSku=!0)},{default:c((()=>[i(" 立即购买 ")])),_:1})])),_:1})):(a(),d(C,{key:1,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[n(V,{class:"ss-reset-button disabled-btn",disabled:""},{default:c((()=>[i(" 已售罄 ")])),_:1})])),_:1}))])),_:1},8,["modelValue"]),n($,{modelValue:f.couponInfo,"onUpdate:modelValue":e[7]||(e[7]=s=>f.couponInfo=s),show:f.showModel,onClose:e[8]||(e[8]=s=>f.showModel=!1),onGet:I},null,8,["modelValue","show"]),n(T,{modelValue:f.activityInfo,"onUpdate:modelValue":e[9]||(e[9]=s=>f.activityInfo=s),show:f.showActivityModel,onClose:e[10]||(e[10]=s=>f.showActivityModel=!1)},null,8,["modelValue","show"])],64))])),_:1},8,["onShareAppMessage"])])),_:1})}}},[["__scopeId","data-v-ae8b2e14"]]);export{ds as default};
|