1 |
- import{r as d,m as n}from"./index.b39df320.js";import{d as f,ak as u,T as k,a as t,ai as j,ah as b,I as C,j as l,C as w,q as p,k as S,l as m,a9 as y,al as h,aa as x,z as I,x as T,am as v,an as G,u as P,ao as _,P as L}from"./vendor.f57b7239.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{i as B}from"./icon-shop-cart.37434050.js";import{A as D}from"./index.65faf0e7.js";/* empty css */const N="_swipeItemImg_12lj0_1",A="_swipe_12lj0_1",H="_goodsHead_12lj0_17",q="_priceGroup_12lj0_24",E="_price_12lj0_24",M="_delPrice_12lj0_36",R="_stock_12lj0_42",V="_goodsName_12lj0_46",$="_row_12lj0_52",z="_col_12lj0_56",J="_radio_12lj0_61",O="_badge_12lj0_95",F="_section_12lj0_99",W="_detail_12lj0_103",U="_photoDetail_12lj0_128",Z="_goodsDetail_12lj0_132",K="_actionBar_12lj0_135",Q="_addCertBtn_12lj0_150",X="_buyGroup_12lj0_155";var e={swipeItemImg:N,swipe:A,"custom-indicator":"_custom-indicator_12lj0_7",goodsHead:H,priceGroup:q,price:E,delPrice:M,stock:R,goodsName:V,row:$,col:z,"radio-group":"_radio-group_12lj0_61",radio:J,badge:O,section:F,detail:W,photoDetail:U,goodsDetail:Z,actionBar:K,addCertBtn:Q,buyGroup:X};function Y(s){return typeof s=="function"||Object.prototype.toString.call(s)==="[object Object]"&&!T(s)}var _t=f({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 s=this.product,i=this.skuStockListTemp.length>0?this.skuStockListTemp:[{id:-1,price:s.price,pic:s.pic,stock:s.stock,spData:null}];return i.forEach(o=>{if(o.spData){const a=JSON.parse(o.spData);let r="";a.forEach(c=>{r+=`${c.value}`}),o.spDataJson=r}else o.spDataJson="\u9ED8\u8BA4"}),i}},async mounted(){try{this.loading=!0;const s=await d.get(`/api-mall-portal/product/detail/${this.id}`);this.loading=!1;const i=s.data||{};if(this.albumPics=i.product.albumPics?i.product.albumPics.split(","):[i.product.pic],this.product=i.product,this.skuStockListTemp=i.skuStockList||[],this.skuStockListTemp.length){let o=this.skuStockListTemp.length;for(let a=0;a<o;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(s){u({images:this.albumPics,startPosition:s,closeable:!0})},onShowImg(s){const{localName:i}=s.srcElement;if(i!=="img")return;let o=0;const a=document.querySelectorAll(".msgWrap img");let r=Array.from(a).map((c,g)=>(s.srcElement==c&&(o=g),c.src));u({images:r,startPosition:o,closeable:!0})},onShowCart(s="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=s,this.addGoodsShow=!0},onBuy(){if(!this.radio)return k("\u8BF7\u9009\u62E9\u89C4\u683C");console.log(!0)},async getCartCount(){try{let{code:s,data:i}=await d.get("/api-mall-portal/cart/list");s===200&&(this.cartCount=i.length)}catch{}}},render(){let s;const i=this.product;return t("div",{class:e.goodsDetail},[t(j,{class:e.swipe,lazyRender:!0},{default:()=>[this.albumPics.map((o,a)=>t(b,null,{default:()=>[t(C,{class:e.swipeItemImg,src:o,onClick:()=>this.onPreview(a),fit:"cover"},null)]}))],indicator:o=>o.total>1&&t("div",{class:e["custom-indicator"]},[(o.active||0)+1,l(" / "),o.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,[l("\xA5")]),n(i.price)]),t("del",{class:e.delPrice},[l("\xA5"),n(i.originalPrice)])])})]}),t(S,{class:[e.row,"mb12"]},{default:()=>[t(m,{span:4,class:e.col},{default:()=>[l("\u89C4\u683C")]}),t(m,{span:20},{default:()=>[t(y,{class:e["radio-group"],modelValue:this.radio,"onUpdate:modelValue":o=>this.radio=o},Y(s=this.skuStockList.map(o=>{const a=o.id===this.radio,r=a?"primary":"default";return t(h,{position:"top-right",content:o.stock<=0?"\u7F3A\u8D27":"",color:"#999999",class:e.badge,offset:[-20,0]},{default:()=>[t(x,{class:e.radio,name:o.id,disabled:o.stock<=0,onClick:()=>{o.stock<=0||(this.radio=o.id)}},{default:()=>[t(I,{size:"large",plain:a,type:r},{default:()=>[o.spDataJson]})]})]})}))?s:{default:()=>[s]})]})]}),this.detailMobileHtml&&t("div",{class:[e.section]},[t("div",{class:e.detail},[t("span",null,[l("\u56FE\u6587\u8BE6\u60C5")])]),t("div",{class:[e.photoDetail,"msgWrap"],onClick:this.onShowImg,innerHTML:this.detailMobileHtml},null)]),!this.loading&&t(v,{class:e.actionBar},{default:()=>[t(G,{icon:"cart-o",onClick:()=>{this.$router.push("/cart")}},{icon:()=>t(h,{content:this.cartCount,showZero:!1},{default:()=>[t(P,{name:B,size:30},null)]})}),t("div",{class:e.buyGroup},[t(_,{type:"primary",class:e.addCertBtn,text:"\u52A0\u5165\u8D2D\u7269\u8F66",onClick:()=>this.onShowCart()},null),t(_,{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(D,{onGetCartCount:()=>this.getCartCount(),item:this.selectGoodsItem,defaultRadio:this.radio,showType:this.showType},null)]})])}});export{_t as default};
|