pages-goods-index.4332e2b8.js 15 KB

1
  1. import{c as e,s,y as o,W as t,X as l,l as a,m as d,e as n,f as u,w as c,j as i,t as r,u as f,g as p,v as g,C as k,k as y,F as m,r as _,B as h,Y as I,x as b,i as S,E as x,G as w,Z as v,S as P,a0 as T,d as C,o as j,p as A,Q as $,q as V,a1 as F}from"./index-b48a414d.js";import{_ as M}from"./s-empty.6d3471cc.js";import{_ as O}from"./su-swiper.9cc599a0.js";import{_ as U}from"./su-number-box.64465b76.js";import{_ as E}from"./phone-international-input.feef99c7.js";import{_ as L}from"./points.c381a8e1.js";import{c as B,d as G,f as D,e as Q,p as W,S as q,g as z,_ as H}from"./s-layout.d6dcdc81.js";import{_ as J}from"./_plugin-vue_export-helper.1b428a4d.js";import{F as N}from"./favorite.ac70f83c.js";import{d as X,a as Y,_ as Z,b as K,c as R,e as ee}from"./detail-content-card.811fb535.js";import{S as se}from"./spu.3911022d.js";/* empty css */import"./comment-item.90dd3105.js";import"./uni-rate.ae6b2b33.js";import"./su-image.900c884d.js";import"./mp-html.da111812.js";const oe=J({__name:"s-select-sku",props:{goodsInfo:{type:Object,default(){}},show:{type:Boolean,default:!1}},emits:["change","addCart","buy","close"],setup(T,{emit:C}){const j=C,A=T,$=e((()=>s.$store("user").userWallet)),V=o({selectedSku:{},currentPropertyArray:[]}),F=B(A.goodsInfo.skus),M=e((()=>{let e=A.goodsInfo.skus;for(let s of e)s.value_id_array=s.properties.map((e=>e.valueId));return e}));function O(){A.goodsInfo.highPrecision?V.selectedSku.goods_num=parseInt(V.selectedSku.use_points/(V.selectedSku.highPrecisionPrice/100)):V.selectedSku.goods_num=parseInt(V.selectedSku.use_points/D(V.selectedSku.price))}function q(e){const o=e.detail.value;if(console.log(typeof o),""==o)return!1;const t=parseFloat(W($.value.integralDO.currentQuota));O(),I((()=>{V.selectedSku.use_points=parseInt(o),O()})),o<=0&&(s.$helper.toast("最低使用1积分"),I(t>=1?()=>{V.selectedSku.use_points=1,O()}:()=>{V.selectedSku.use_points=0,O()})),o>t&&(s.$helper.toast("可用积分不足"),I((()=>{V.selectedSku.use_points=parseInt(t),O()})))}function z(){V.selectedSku.id<=0?s.$helper.toast("请选择规格"):V.selectedSku.stock<=0?s.$helper.toast("库存不足"):j("addCart",V.selectedSku)}function H(){if(2==A.goodsInfo.spuPayType){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*D(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("库存不足"):j("buy",V.selectedSku)}function J(e=!1,s=0,o=0){let t=[];if(e)for(let d of M.value)d.stock<=0||d.value_id_array.indexOf(o)>=0&&t.push(d);else t=N();let l=[];for(let d of t)l=l.concat(d.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 d in F)if(!(a.indexOf(F[d].id)>=0))for(let e in F[d].values)F[d].values[e].disabled=l.indexOf(F[d].values[e].id)<0}function N(){let e=[];for(let s of M.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 X(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=N();t.length===F.length&&l.length?(l[0].goods_num=V.selectedSku.goods_num||1,V.selectedSku=l[0]):V.selectedSku={},J(o,e,s)}return t((()=>V.selectedSku),(e=>{j("change",e)}),{immediate:!0,deep:!0}),J(!1),l((()=>{1==F.length&&1==F[0].values.length&&X(0,0)})),(e,s)=>{const o=b,t=S,l=x,I=w,C=v,A=a(d("su-number-box"),U),M=P,O=a(d("su-popup"),E);return n(),u(O,{show:T.show,round:"10",onClose:s[4]||(s[4]=e=>j("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||T.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(T.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==T.goodsInfo.spuPayType?(n(),u(o,{key:0,src:L,style:{width:"30rpx",height:"30rpx"}})):p("",!0),T.goodsInfo.highPrecision?(n(),u(l,{key:1},{default:c((()=>[r(f(g(G)(V.selectedSku.highPrecisionPrice||T.goodsInfo.highPrecisionPrice)),1)])),_:1})):(n(),u(l,{key:2},{default:c((()=>[r(f(g(D)(V.selectedSku.price||T.goodsInfo.price)),1)])),_:1}))])),_:1}),V.selectedSku.promotionFee>=0||T.goodsInfo.promotionFee>=0?(n(),u(t,{key:0,class:"origin-price-text ss-m-l-10"},{default:c((()=>[r(" 积分:"+f(g(D)(V.selectedSku.promotionFee||T.goodsInfo.promotionFee)),1)])),_:1})):p("",!0)])),_:1}),i(t,{class:"stock-text ss-m-l-20"},{default:c((()=>[r(f(g(Q)("exact",V.selectedSku.stock||T.goodsInfo.stock)),1)])),_:1})])),_:1})])),_:1})])),_:1}),i(t,{class:"modal-content ss-flex-1"},{default:c((()=>[i(M,{"scroll-y":"true",class:"modal-content-scroll",onTouchmove:s[3]||(s[3]=k((()=>{}),["stop"]))},{default:c((()=>[(n(!0),y(m,null,_(g(F),(e=>(n(),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((()=>[(n(!0),y(m,null,_(e.values,(s=>(n(),u(I,{class:h(["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=>X(e.id,s.id)},{default:c((()=>[r(f(s.name),1)])),_:2},1032,["class","disabled","onClick"])))),128))])),_:2},1024)])),_:2},1024)))),128)),2==T.goodsInfo.spuPayType?(n(),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(W)($.value.integralDO.currentQuota))+")",1)])),_:1}),i(t,{class:"ss-flex ss-col-center"},{default:c((()=>[2==T.goodsInfo.spuPayType?(n(),u(o,{key:0,src:L,style:{width:"30rpx",height:"30rpx"}})):p("",!0),i(C,{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:q,disabled:!V.selectedSku.id},null,8,["modelValue","disabled"])])),_:1})])),_:1})):(n(),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(A,{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((()=>[T.goodsInfo.spuType&&1==T.goodsInfo.spuPayType?(n(),u(t,{key:0,class:"buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center"},{default:c((()=>[i(I,{class:"ss-reset-button add-btn ui-Shadow-Main",onClick:z},{default:c((()=>[r("加入购物车")])),_:1}),i(I,{class:"ss-reset-button buy-btn ui-Shadow-Main",onClick:H},{default:c((()=>[r("立即购买")])),_:1})])),_:1})):(n(),u(t,{key:1,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[i(I,{class:"ss-reset-button disabled-btn one-buy-btn ui-Shadow-Main",onClick:H},{default:c((()=>[1==T.goodsInfo.spuPayType||T.goodsInfo.spuType?T.goodsInfo.spuType?(n(),y(m,{key:2},[r(" 立即兑换 ")],64)):(n(),y(m,{key:1},[r(" 立即购买 ")],64)):(n(),y(m,{key:0},[r(" 立即兑换 ")],64))])),_:1})])),_:1}))])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-b982c954"]]),te=e=>T({url:"/promotion/activity/list-by-spu-id",method:"GET",params:{spuId:e}}),le=J({__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 h(e){k.selectedSku=e}function I(e){e.id?E.value?s.$store("cart").add(e):V():s.$helper.toast("请选择商品规格")}function v(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((()=>F.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:D(k.goodsInfo.price),original_price:D(k.goodsInfo.maretPrice)})));async function U(e){se.getSpuDetail(e).then((e=>{0===e.code&&e.data?(k.skeletonLoading=!1,k.goodsInfo=e.data,console.log(k.goodsInfo),E.value&&N.isFavoriteExists(k.goodsId,"goods").then((e=>{0===e.code&&(k.goodsInfo.favorite=e.data)}))):k.goodsInfo=null}))}const E=e((()=>s.$store("user").isLogin));return t((()=>E.value),(e=>{e&&U(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();q.getObjectIdByLinkId(s).then((e=>{0===e.code&&(k.goodsId=e.data,U(k.goodsId),async function(){q.getLinkId(3,k.goodsId).then((e=>{0===e.code&&(k.linkId=e.data.linkId)}))}())})),A("linkId",e.linkId)}else U(k.goodsId);te(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(d("s-empty"),M),t=a(d("su-swiper"),O),l=b,C=x,j=S,A=a(d("s-select-sku"),oe),V=w,F=a(d("s-layout"),H);return n(),u(j,null,{default:c((()=>[i(F,{onShareAppMessage:T.value,navbar:"goods"},{default:c((()=>[i(X,{modelValue:k.goodsInfo,"onUpdate:modelValue":s[0]||(s[0]=e=>k.goodsInfo=e)},null,8,["modelValue"]),k.skeletonLoading?(n(),u(Y,{key:0})):null===k.goodsInfo?(n(),u(o,{key:1,text:"商品不存在或已下架",icon:"/static/soldout-empty.png",showAction:"",actionText:"再逛逛",actionUrl:"/pages/goods/list"})):(n(),y(m,{key:2},[i(j,{class:"detail-swiper-selector"},{default:c((()=>[i(t,{class:"ss-m-b-14",isPreview:"",list:g(z)(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?(n(),u(l,{key:0,src:L,class:"ss-m-r-10",style:{width:"40rpx",height:"40rpx"}})):(n(),u(C,{key:1},{default:c((()=>[r("¥")])),_:1})),k.goodsInfo.highPrecision?(n(),u(C,{key:2},{default:c((()=>[r(f(g(G)(k.selectedSku.highPrecisionPrice||k.goodsInfo.highPrecisionPrice)),1)])),_:1})):(n(),u(C,{key:3},{default:c((()=>[r(f(g(D)(k.selectedSku.price||k.goodsInfo.price)),1)])),_:1}))])),_:1}),k.goodsInfo.promotionFee>=0?(n(),u(j,{key:0,class:"origin-price-text"},{default:c((()=>[r(" 积分:"+f(g(D)(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((()=>[$("div",{class:"tag-content"},[i(j,{class:"tag-box ss-flex"},{default:c((()=>[(n(!0),y(m,null,_(k.activityInfo,(e=>(n(),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?(n(),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(Z,{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:I,onBuy:v,onChange:h,onClose:s[4]||(s[4]=e=>k.showSelectSku=!1)},null,8,["goodsInfo","show"])])),_:1}),i(K,{class:"detail-comment-selector",goodsId:k.goodsId},null,8,["goodsId"]),i(R,{class:"detail-content-selector",content:k.goodsInfo.description},null,8,["content"]),i(ee,{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?(n(),u(j,{key:0,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[i(V,{class:"ss-reset-button add-btn ui-Shadow-Main",onClick:s[5]||(s[5]=e=>k.showSelectSku=!0)},{default:c((()=>[r(" 加入购物车 ")])),_:1}),i(V,{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?(n(),u(j,{key:1,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[i(V,{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?(n(),y(m,{key:2},[r(" 立即兑换 ")],64)):(n(),y(m,{key:1},[r(" 立即购买 ")],64)):(n(),y(m,{key:0},[r(" 立即兑换 ")],64))])),_:1})])),_:1})):(n(),u(j,{key:2,class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:c((()=>[i(V,{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};