pages-goods-seckill.395e21d3.js 12 KB

1
  1. import{_ as e}from"./s-empty.6d3471cc.js";import{y as s,c as t,W as l,l as o,m as a,e as c,f as n,w as r,j as i,v as u,s as d,t as f,u as p,k as m,F as g,r as _,B as k,a1 as b,x as y,i as x,E as v,G as h,S as w,A as S,d as I,K as C,o as A,g as P,D as j}from"./index-b48a414d.js";import{_ as L}from"./su-swiper.9cc599a0.js";import{_ as T}from"./su-number-box.64465b76.js";import{_ as $}from"./phone-international-input.feef99c7.js";import{c as E,f as V,g as U,u as O,_ as D}from"./s-layout.d6dcdc81.js";import{_ as M}from"./_plugin-vue_export-helper.1b428a4d.js";import{d as R,a as B,_ as F,b as N,c as q,e as z}from"./detail-content-card.811fb535.js";import{S as G,g as H,T as J}from"./const.75de4c57.js";import{S as K}from"./spu.3911022d.js";/* empty css */import"./favorite.ac70f83c.js";import"./comment-item.90dd3105.js";import"./uni-rate.ae6b2b33.js";import"./su-image.900c884d.js";import"./mp-html.da111812.js";const W=M({__name:"s-select-seckill-sku",props:{modelValue:{type:Object,default(){}},show:{type:Boolean,default:!1},singleLimitCount:{type:Number,default:1}},emits:["change","addCart","buy","close"],setup(e,{emit:S}){const I=S,C=e,A=s({goodsInfo:t((()=>C.modelValue)),selectedSku:{},currentPropertyArray:[]}),P=E(A.goodsInfo.skus),j=t((()=>{let e=A.goodsInfo.skus;for(let s of e)s.value_id_array=s.properties.map((e=>e.valueId));return e}));A.goodsInfo.is_sku||(A.selectedSku=A.goodsInfo.skus[0]),l((()=>A.selectedSku),(e=>{I("change",e)}),{immediate:!0,deep:!0});const L=()=>{A.selectedSku.id?A.selectedSku.stock<=0?d.$helper.toast("库存不足"):I("buy",A.selectedSku):d.$helper.toast("请选择规格")};const U=(e=!1,s=0,t=0)=>{let l=[];if(e)for(let c of j.value)c.stock<=0||c.value_id_array.indexOf(t)>=0&&l.push(c);else l=O();let o=[];for(let c of l)o=o.concat(c.value_id_array);if(o=Array.from(new Set(o)),e){let e=o.indexOf(t);o.splice(e,1)}else A.currentPropertyArray.forEach((e=>{if(""!==e.toString())return;let s=o.indexOf(e);s>=0&&o.splice(s,1)}));let a=[];e?a=[s]:A.currentPropertyArray.forEach(((e,s)=>{""!==e&&a.push(s)}));for(let c in P)if(!(a.indexOf(P[c].id)>=0))for(let e in P[c].values)P[c].values[e].disabled=o.indexOf(P[c].values[e].id)<0},O=()=>{let e=[];for(let s of j.value){if(s.stock<=0)continue;let t=!0;A.currentPropertyArray.forEach((e=>{""!==e.toString()&&s.value_id_array.indexOf(e)<0&&(t=!1)})),t&&e.push(s)}return e};return U(!1),(s,t)=>{const l=y,S=x,C=v,j=h,E=o(a("su-number-box"),T),D=w,M=o(a("su-popup"),$);return c(),n(M,{show:e.show,round:"10",onClose:t[2]||(t[2]=e=>I("close"))},{default:r((()=>[i(S,{class:"ss-modal-box bg-white ss-flex-col"},{default:r((()=>[i(S,{class:"modal-header ss-flex ss-col-center"},{default:r((()=>[i(S,{class:"header-left ss-m-r-30"},{default:r((()=>[i(l,{class:"sku-image",src:u(d).$url.cdn(A.selectedSku.picUrl||A.goodsInfo.picUrl),mode:"aspectFill"},null,8,["src"])])),_:1}),i(S,{class:"header-right ss-flex-col ss-row-between ss-flex-1"},{default:r((()=>[i(S,{class:"goods-title ss-line-2"},{default:r((()=>[f(p(A.goodsInfo.name),1)])),_:1}),i(S,{class:"header-right-bottom ss-flex ss-col-center ss-row-between"},{default:r((()=>[i(S,{class:"price-text"},{default:r((()=>[f(p(u(V)(A.selectedSku.price||A.goodsInfo.price)),1)])),_:1}),i(S,{class:"tig ss-flex ss-col-center"},{default:r((()=>[i(S,{class:"tig-icon ss-flex ss-col-center ss-row-center"},{default:r((()=>[i(C,{class:"cicon-alarm"})])),_:1}),i(S,{class:"tig-title"},{default:r((()=>[f("秒杀价")])),_:1})])),_:1}),i(S,{class:"stock-text ss-m-l-20"},{default:r((()=>[f(" 库存"+p(A.selectedSku.stock||A.goodsInfo.stock)+"件 ",1)])),_:1})])),_:1})])),_:1})])),_:1}),i(S,{class:"modal-content ss-flex-1"},{default:r((()=>[i(D,{"scroll-y":"true",class:"modal-content-scroll"},{default:r((()=>[(c(!0),m(g,null,_(u(P),(e=>(c(),n(S,{class:"sku-item ss-m-b-20",key:e.id},{default:r((()=>[i(S,{class:"label-text ss-m-b-20"},{default:r((()=>[f(p(e.name),1)])),_:2},1024),i(S,{class:"ss-flex ss-col-center ss-flex-wrap"},{default:r((()=>[(c(!0),m(g,null,_(e.values,(s=>(c(),n(j,{class:k(["ss-reset-button spec-btn",[{"checked-btn":A.currentPropertyArray[e.id]===s.id},{"disabled-btn":!0===s.disabled}]]),key:s.id,disabled:!0===s.disabled,onClick:t=>((e,s)=>{let t=!0;void 0!==A.currentPropertyArray[e]&&A.currentPropertyArray[e]===s?(t=!1,A.currentPropertyArray.splice(e,1,"")):A.currentPropertyArray[e]=s;let l=[];A.currentPropertyArray.forEach((e=>{""!==e&&l.push(e)}));let o=O();l.length===P.length&&o.length?(o[0].count=A.selectedSku.count||1,A.selectedSku=o[0]):A.selectedSku={},U(t,e,s)})(e.id,s.id)},{default:r((()=>[f(p(s.name),1)])),_:2},1032,["class","disabled","onClick"])))),128))])),_:2},1024)])),_:2},1024)))),128)),i(S,{class:"buy-num-box ss-flex ss-col-center ss-row-between"},{default:r((()=>[i(S,{class:"label-text"},{default:r((()=>[f("购买数量")])),_:1}),i(E,{min:1,max:u(b.min)([e.singleLimitCount,A.selectedSku.stock]),step:1,modelValue:A.selectedSku.count,"onUpdate:modelValue":t[0]||(t[0]=e=>A.selectedSku.count=e),onChange:t[1]||(t[1]=e=>{var s;(s=e)>0&&A.selectedSku.count!==s&&(A.selectedSku.count=s)}),activity:"seckill"},null,8,["max","modelValue"])])),_:1})])),_:1})])),_:1}),i(S,{class:"modal-footer"},{default:r((()=>[i(S,{class:"buy-box ss-flex ss-col-center ss-flex ss-col-center ss-row-center"},{default:r((()=>[i(j,{class:"ss-reset-button buy-btn",onClick:L},{default:r((()=>[f("确认")])),_:1})])),_:1})])),_:1})])),_:1})])),_:1},8,["show"])}}},[["__scopeId","data-v-bd8b32ba"]]),Q=M({__name:"detail-progress",props:{percent:{type:Number,default:0}},setup:e=>(s,t)=>{const l=x;return c(),n(l,{class:"ss-flex ss-col-center"},{default:r((()=>[i(l,{class:"progress-title ss-m-r-10"},{default:r((()=>[f(" 已抢"+p(e.percent)+"% ",1)])),_:1}),i(l,{class:"progress-box ss-flex ss-col-center"},{default:r((()=>[i(l,{class:"progerss-active",style:S({width:e.percent<10?"10%":e.percent+"%"})},null,8,["style"])])),_:1})])),_:1})}},[["__scopeId","data-v-58b2423c"]]),X=M({__name:"seckill",setup(l){j((e=>({"284c9add":u(_),"1b768876":u(y),"78b5065a":u(w),"93a7b3ee":u(S),d4b50090:u(T)})));const _=d.$url.css("/static/img/shop/goods/seckill-bg.png"),y=d.$url.css("/static/img/shop/goods/seckill-btn.png"),w=d.$url.css("/static/img/shop/goods/activity-btn-disabled.png"),S=d.$url.css("/static/img/shop/goods/seckill-tip-bg.png"),T=d.$url.css("/static/img/shop/goods/groupon-tip-bg.png");I((()=>{}));const $=s({skeletonLoading:!0,goodsInfo:{},showSelectSku:!1,goodsSwiper:[],selectedSku:{},showModel:!1,total:0,percent:0,price:""}),E=t((()=>O(Z.value.endTime)));function M(e){$.selectedSku=e}function X(e){d.$router.go("/pages/order/confirm",{data:JSON.stringify({order_type:"goods",buy_type:"seckill",seckillActivityId:Z.value.id,items:[{skuId:e.id,count:e.count}]})})}const Y=t((()=>b.isEmpty(Z)?{}:d.$platform.share.getShareInfo({title:Z.value.name,image:d.$url.cdn($.goodsInfo.picUrl),params:{page:"4",query:Z.value.id}},{type:"goods",title:Z.value.name,image:d.$url.cdn($.goodsInfo.picUrl),price:$.goodsInfo.price,marketPrice:$.goodsInfo.marketPrice}))),Z=C(),ee=C(""),se=async e=>{const{data:s}=await K.getSpuDetail(e);s.activity_type="seckill",$.goodsInfo=s,$.goodsSwiper=U($.goodsInfo.sliderPicUrls),$.goodsInfo.price=b.min([$.goodsInfo.price,...Z.value.products.map((e=>e.seckillPrice))]),s.skus.forEach((e=>{const s=Z.value.products.find((s=>s.skuId===e.id));s?(e.price=s.seckillPrice,e.stock=Math.min(e.stock,s.stock)):e.stock=0,Z.value.totalLimitCount>0&&Z.value.singleLimitCount>0?e.limitCount=Math.min(Z.value.totalLimitCount,Z.value.singleLimitCount):Z.value.totalLimitCount>0?e.limitCount=Z.value.totalLimitCount:Z.value.singleLimitCount>0&&(e.limitCount=Z.value.singleLimitCount)})),$.skeletonLoading=!1};return A((e=>{e.id?(async e=>{const{data:s}=await G.getSeckillActivity(e);Z.value=s,ee.value=H(Z.startTime,Z.endTime),await se(s.spuId)})(e.id):$.goodsInfo=null})),(s,t)=>{const l=o(a("s-empty"),e),_=o(a("su-swiper"),L),b=x,y=v,w=o(a("s-select-seckill-sku"),W),S=h,I=o(a("s-layout"),D);return c(),n(I,{onShareAppMessage:Y.value,navbar:"goods"},{default:r((()=>[i(R),$.skeletonLoading?(c(),n(B,{key:0})):null===$.goodsInfo||"seckill"!==$.goodsInfo.activity_type?(c(),n(l,{key:1,text:"活动不存在或已结束",icon:"/static/soldout-empty.png",showAction:"",actionText:"再逛逛",actionUrl:"/pages/goods/list"})):(c(),m(g,{key:2},[i(b,{class:"detail-swiper-selector"},{default:r((()=>[i(_,{class:"ss-m-b-14",isPreview:"",list:$.goodsSwiper,dotStyle:"tag",imageMode:"widthFix",dotCur:"bg-mask-40",seizeHeight:750},null,8,["list"]),i(b,{class:"title-card ss-m-y-14 ss-m-x-20 ss-p-x-20 ss-p-y-34"},{default:r((()=>[i(b,{class:"price-box ss-flex ss-row-between ss-m-b-18"},{default:r((()=>[i(b,{class:"ss-flex"},{default:r((()=>[i(b,{class:"price-text ss-m-r-16"},{default:r((()=>[f(p(u(V)($.selectedSku.price||$.goodsInfo.price)),1)])),_:1}),i(b,{class:"tig ss-flex ss-col-center"},{default:r((()=>[i(b,{class:"tig-icon ss-flex ss-col-center ss-row-center"},{default:r((()=>[i(y,{class:"cicon-alarm"})])),_:1}),i(b,{class:"tig-title"},{default:r((()=>[f("秒杀价")])),_:1})])),_:1})])),_:1}),E.value.ms>0?(c(),n(b,{key:0,class:"countdown-box"},{default:r((()=>[i(b,{class:"countdown-title ss-m-b-20"},{default:r((()=>[f("距结束仅剩")])),_:1}),i(b,{class:"ss-flex countdown-time"},{default:r((()=>[i(b,{class:"ss-flex countdown-h"},{default:r((()=>[f(p(E.value.h),1)])),_:1}),i(b,{class:"ss-m-x-4"},{default:r((()=>[f(":")])),_:1}),i(b,{class:"countdown-num ss-flex ss-row-center"},{default:r((()=>[f(p(E.value.m),1)])),_:1}),i(b,{class:"ss-m-x-4"},{default:r((()=>[f(":")])),_:1}),i(b,{class:"countdown-num ss-flex ss-row-center"},{default:r((()=>[f(p(E.value.s),1)])),_:1})])),_:1})])),_:1})):(c(),n(b,{key:1,class:"countdown-title"},{default:r((()=>[f(" 活动已结束 ")])),_:1}))])),_:1}),i(b,{class:"ss-flex ss-row-between ss-m-b-60"},{default:r((()=>[$.goodsInfo.marketPrice?(c(),n(b,{key:0,class:"origin-price ss-flex ss-col-center"},{default:r((()=>[f(" 原价 "),i(b,{class:"origin-price-text"},{default:r((()=>[f(p(u(V)($.selectedSku.marketPrice||$.goodsInfo.marketPrice)),1)])),_:1})])),_:1})):P("",!0),i(Q,{percent:$.percent},null,8,["percent"])])),_:1}),i(b,{class:"title-text ss-line-2 ss-m-b-6"},{default:r((()=>{var e;return[f(p(null==(e=$.goodsInfo)?void 0:e.name),1)]})),_:1}),i(b,{class:"subtitle-text ss-line-1"},{default:r((()=>[f(p($.goodsInfo.introduction),1)])),_:1})])),_:1}),i(b,{class:"detail-cell-card detail-card ss-flex-col"},{default:r((()=>[i(F,{sku:$.selectedSku,onClick:t[0]||(t[0]=e=>$.showSelectSku=!0)},null,8,["sku"])])),_:1}),i(w,{modelValue:$.goodsInfo,"onUpdate:modelValue":t[1]||(t[1]=e=>$.goodsInfo=e),show:$.showSelectSku,"single-limit-count":Z.value.singleLimitCount,onBuy:X,onChange:M,onClose:t[2]||(t[2]=e=>$.showSelectSku=!1)},null,8,["modelValue","show","single-limit-count"])])),_:1}),i(N,{class:"detail-comment-selector",goodsId:$.goodsInfo.id},null,8,["goodsId"]),i(q,{class:"detail-content-selector",content:$.goodsInfo.description},null,8,["content"]),i(z,{modelValue:$.goodsInfo,"onUpdate:modelValue":t[5]||(t[5]=e=>$.goodsInfo=e)},{default:r((()=>[i(b,{class:"buy-box ss-flex ss-col-center ss-p-r-20"},{default:r((()=>[$.goodsInfo.marketPrice?(c(),n(S,{key:0,class:"ss-reset-button origin-price-btn ss-flex-col",onClick:t[3]||(t[3]=e=>u(d).$router.go("/pages/goods/index",{id:$.goodsInfo.id}))},{default:r((()=>[i(b,null,{default:r((()=>[i(b,{class:"btn-price"},{default:r((()=>[f(p(u(V)($.goodsInfo.marketPrice)),1)])),_:1}),i(b,null,{default:r((()=>[f("原价购买")])),_:1})])),_:1})])),_:1})):(c(),n(S,{key:1,class:"ss-reset-button origin-price-btn ss-flex-col"},{default:r((()=>[i(b,{class:k(["no-original",(0===$.goodsInfo.stock||(ee.value,u(J).STARTED),"")])},{default:r((()=>[f(" 秒杀价 ")])),_:1},8,["class"])])),_:1})),i(S,{class:k(["ss-reset-button btn-box ss-flex-col",ee.value===u(J).STARTED&&0!=$.goodsInfo.stock?"check-btn-box":"disabled-btn-box"]),onClick:t[4]||(t[4]=e=>$.showSelectSku=!0),disabled:0===$.goodsInfo.stock||ee.value!==u(J).STARTED},{default:r((()=>[i(b,{class:"btn-price"},{default:r((()=>[f(p(u(V)($.goodsInfo.price)),1)])),_:1}),ee.value===u(J).STARTED?(c(),n(b,{key:0},{default:r((()=>[0===$.goodsInfo.stock?(c(),n(b,{key:0},{default:r((()=>[f("已售罄")])),_:1})):(c(),n(b,{key:1},{default:r((()=>[f("立即秒杀")])),_:1}))])),_:1})):(c(),n(b,{key:1},{default:r((()=>[f(p(ee.value),1)])),_:1}))])),_:1},8,["class","disabled"])])),_:1})])),_:1},8,["modelValue"])],64))])),_:1},8,["onShareAppMessage"])}}},[["__scopeId","data-v-31d78969"]]);export{X as default};