1 |
- import{r as l,m as n}from"./index.d925b97f.js";import{d as g,ao as u,T as y,a as t,ak as f,aj as b,I as C,j as c,C as w,q as p,k as S,l as m,ab as x,al as h,ac as j,z as I,x as P,F as T,ap as G,u as v,aq as k,P as L}from"./vendor.ad13860b.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{i as D}from"./icon-shop-cart.37434050.js";import{A as B}from"./index.ab23e248.js";/* empty css */const N="_swipeItemImg_1y2kt_1",A="_swipe_1y2kt_1",H="_goodsHead_1y2kt_17",q="_priceGroup_1y2kt_24",E="_price_1y2kt_24",M="_delPrice_1y2kt_36",R="_stock_1y2kt_42",V="_goodsName_1y2kt_46",z="_row_1y2kt_52",F="_col_1y2kt_56",J="_radio_1y2kt_61",$="_badge_1y2kt_95",O="_section_1y2kt_99",W="_detail_1y2kt_103",U="_photoDetail_1y2kt_128",Z="_goodsDetail_1y2kt_132",K="_actionBar_1y2kt_135",Q="_addCertBtn_1y2kt_155",X="_buyGroup_1y2kt_159";var e={swipeItemImg:N,swipe:A,"custom-indicator":"_custom-indicator_1y2kt_7",goodsHead:H,priceGroup:q,price:E,delPrice:M,stock:R,goodsName:V,row:z,col:F,"radio-group":"_radio-group_1y2kt_61",radio:J,badge:$,section:O,detail:W,photoDetail:U,goodsDetail:Z,actionBar:K,addCertBtn:Q,buyGroup:X};function Y(o){return typeof o=="function"||Object.prototype.toString.call(o)==="[object Object]"&&!P(o)}var _t=g({name:"goods-detail",data(){return{id:this.$route.query.id,albumPics:[],product:{},radio:0,skuStockListTemp:[],detailMobileHtml:"",loading:!1,addGoodsShow:!1,selectGoodsItem:{},cartCount:0,showType:"cart"}},computed:{skuStockList(){const o=this.product,i=this.skuStockListTemp.length>0?this.skuStockListTemp:[{id:-1,price:o.price,pic:o.pic,stock:o.stock,spData:null}];return i.forEach(s=>{if(s.spData){const a=JSON.parse(s.spData);let r="";a.forEach(d=>{r+=`${d.value}`}),s.spDataJson=r}else s.spDataJson="\u9ED8\u8BA4"}),i},getPrice(){let o=this.skuStockList.filter(i=>i.id==this.radio);return o&&Array.isArray(o)&&o.length?o[0].price:0}},async mounted(){try{this.loading=!0;const o=await l.get(`/api-mall-portal/product/detail/${this.id}`);this.loading=!1;const i=o.data||{};if(this.albumPics=[i.product.pic].concat(i.product.albumPics.split(",")).filter(s=>s),this.product=i.product,this.skuStockListTemp=i.skuStockList||[],this.skuStockListTemp.length){let s=this.skuStockListTemp.length;for(let a=0;a<s;a++){let r=this.skuStockListTemp[a];if(r.stock>=0){this.radio=r.id;break}}}this.detailMobileHtml=i.product.detailMobileHtml}catch{}this.getCartCount()},methods:{onPreview(o){u({images:this.albumPics,startPosition:o,closeable:!0})},onShowImg(o){const{localName:i}=o.srcElement;if(i!=="img")return;let s=0;const a=document.querySelectorAll(".msgWrap img");let r=Array.from(a).map((d,_)=>(o.srcElement==d&&(s=_),d.src));u({images:r,startPosition:s,closeable:!0})},onShowCart(o="cart"){this.selectGoodsItem={price:this.product.pic,stock:this.product.stock,skuStockList:this.skuStockListTemp.length?this.skuStockListTemp:void 0,brandName:this.product.brandName,productCategoryId:this.product.productCategoryId,name:this.product.name,productSn:this.product.productSn,productSubTitle:this.product.subTitle,id:this.product.id},this.showType=o,this.addGoodsShow=!0},onBuy(){if(!this.radio)return y("\u8BF7\u9009\u62E9\u89C4\u683C");console.log(!0)},async getCartCount(){try{let{code:o,data:i}=await l.get("/api-mall-portal/cart/list");o===200&&(this.cartCount=i.length)}catch{}}},render(){let o;const i=this.product;return t("div",{class:e.goodsDetail},[t(f,{class:e.swipe,lazyRender:!0},{default:()=>[this.albumPics.map((s,a)=>t(b,null,{default:()=>[t(C,{class:e.swipeItemImg,src:s,onClick:()=>this.onPreview(a),fit:"cover"},null)]}))],indicator:s=>s.total>1&&t("div",{class:e["custom-indicator"]},[(s.active||0)+1,c(" / "),s.total])}),t(w,{border:!1,class:[e.goodsHead,"mb12"]},{default:()=>[t(p,{center:!0,border:!1,title:i.name,titleClass:[e.goodsName,"van-ellipsis"]},null),t(p,{center:!0,border:!1},{title:()=>t("div",{class:e.priceGroup},[t("span",{class:e.price},[t("i",null,[c("\xA5")]),n(this.getPrice)]),t("del",{class:e.delPrice},[c("\xA5"),n(i.originalPrice)])])})]}),t(S,{class:[e.row,"mb12"]},{default:()=>[t(m,{span:4,class:e.col},{default:()=>[c("\u89C4\u683C")]}),t(m,{span:20},{default:()=>[t(x,{class:e["radio-group"],modelValue:this.radio,"onUpdate:modelValue":s=>this.radio=s},Y(o=this.skuStockList.map(s=>{const a=s.id===this.radio,r=a?"primary":"default";return t(h,{position:"top-right",content:s.stock<=0?"\u7F3A\u8D27":"",color:"#999999",class:e.badge,offset:[-20,0]},{default:()=>[t(j,{class:e.radio,name:s.id,disabled:s.stock<=0,onClick:()=>{s.stock<=0||(this.radio=s.id)}},{default:()=>[t(I,{size:"large",plain:a,type:r},{default:()=>[s.spDataJson]})]})]})}))?o:{default:()=>[o]})]})]}),this.detailMobileHtml&&t("div",{class:[e.section]},[t("div",{class:e.detail},[t("span",null,[c("\u56FE\u6587\u8BE6\u60C5")])]),t("div",{class:[e.photoDetail,"msgWrap"],onClick:this.onShowImg,innerHTML:this.detailMobileHtml},null)]),!this.loading&&t(T,null,[t(G,{class:e.actionBar,"safe-area-inset-bottom":!0},{default:()=>[t(h,{content:this.cartCount,showZero:!1,onClick:()=>{this.$router.push("/cart")}},{default:()=>[t(v,{name:D,size:30},null)]})],button:()=>t("div",{class:e.buyGroup},[t(k,{type:"primary",class:e.addCertBtn,text:"\u52A0\u5165\u8D2D\u7269\u8F66",onClick:()=>this.onShowCart()},null),t(k,{type:"primary",text:"\u7ACB\u5373\u8D2D\u4E70",onClick:()=>this.onShowCart("cartConfirm")},null)])})]),t(L,{show:this.addGoodsShow,closeable:!0,position:"bottom",round:!0,onClose:()=>{this.addGoodsShow=!1}},{default:()=>[t(B,{onGetCartCount:()=>this.getCartCount(),item:this.selectGoodsItem,defaultRadio:this.radio,showType:this.showType},null)]})])}});export{_t as default};
|