index.2e717d48.js 7.6 KB

1
  1. import{e as b,s as d,r as n,n as p}from"./index.88ea63df.js";import{d as C,ai as u,T as w,a as t,u as h,j as l,a2 as y,a3 as z,I,C as j,q as m,k as v,l as g,a7 as P,af as _,a8 as T,z as x,x as L,F as B,aj as D,ak as f,P as S}from"./vendor.75c233d7.js";/* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css *//* empty css */import{b as G,i as A}from"./icon-shop-cart.9b0f935d.js";import{A as H}from"./index.cf514686.js";import{C as $}from"./index.184deee6.js";import{C as N}from"./index.9ccb557c.js";/* empty css */import"./icon-sell-out.bc315722.js";/* empty css */import"./browser.ebb85846.js";import"./icon_teacher.40b6f077.js";const W="_swipeItemImg_19gzp_1",E="_swipe_19gzp_1",V="_goodsHead_19gzp_17",M="_priceGroup_19gzp_24",R="_price_19gzp_24",q="_delPrice_19gzp_37",O="_stock_19gzp_43",F="_goodsName_19gzp_47",J="_row_19gzp_53",U="_col_19gzp_57",Z="_radio_19gzp_61",K="_badge_19gzp_96",Q="_section_19gzp_100",X="_detail_19gzp_104",Y="_photoDetail_19gzp_129",tt="_goodsDetail_19gzp_133",st="_actionBar_19gzp_136",et="_addCertBtn_19gzp_157",ot="_buyGroup_19gzp_161",at="_selectWrap_19gzp_171",it="_shareBtn_19gzp_177",rt="_shareWrap_19gzp_183",ct="_sharePic_19gzp_193",lt="_shareLeft_19gzp_198",dt="_shareShopTitle_19gzp_201",nt="_shareShopDes_19gzp_206",pt="_shareShopValue_19gzp_212",ut="_shareShopOldPrice_19gzp_216";var e={swipeItemImg:W,swipe:E,"custom-indicator":"_custom-indicator_19gzp_7",goodsHead:V,priceGroup:M,price:R,delPrice:q,stock:O,goodsName:F,row:J,col:U,"radio-group":"_radio-group_19gzp_61",radio:Z,badge:K,section:Q,detail:X,photoDetail:Y,goodsDetail:tt,actionBar:st,addCertBtn:et,buyGroup:ot,selectWrap:at,shareBtn:it,shareWrap:rt,sharePic:ct,shareLeft:lt,shareShopTitle:dt,shareShopDes:nt,shareShopValue:pt,shareShopOldPrice:ut};function ht(s){return typeof s=="function"||Object.prototype.toString.call(s)==="[object Object]"&&!L(s)}var At=C({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",shareShow:!1}},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(a=>{if(a.spData){const o=JSON.parse(a.spData);a.spDataJson=o.reduce((r,c)=>(r+=c.value,r),""),a.sku=o.reduce((r,c)=>(r.push(`${c.key}: ${c.value}`),r),[]).join(",")}else a.spDataJson="\u9ED8\u8BA4"}),i},getPrice(){let s=this.skuStockList.filter(i=>i.id==this.radio);return s&&Array.isArray(s)&&s.length?s[0].price:0},shareUrl(){const s=this.product.id;return b().isApp?`${location.origin}/teacher/#/shareMall?bizId=${s}&userId=${d.user.data.userId}`:`${location.origin}/teacher.html#/shareMall?bizId=${s}&userId=${d.user.data.userId}`}},async mounted(){try{this.loading=!0;const s=await n.get(`/api-mall-portal/product/detail/${this.id}`);this.loading=!1;const i=s.data||{};if(this.albumPics=[i.product.pic].concat(i.product.albumPics.split(",")).filter(a=>a),this.product=i.product,this.skuStockListTemp=i.skuStockList||[],this.skuStockListTemp.length){let a=this.skuStockListTemp.length;for(let o=0;o<a;o++){let r=this.skuStockListTemp[o];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 a=0;const o=document.querySelectorAll(".msgWrap img");let r=Array.from(o).map((c,k)=>(s.srcElement==c&&(a=k),c.src));u({images:r,startPosition:a,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 w("\u8BF7\u9009\u62E9\u89C4\u683C");console.log(!0)},async getCartCount(){try{let{code:s,data:i}=await n.get("/api-mall-portal/cart/list");s===200&&(this.cartCount=i.length)}catch{}}},render(){let s;const i=this.product,a=this.skuStockList.find(o=>o.id===this.radio);return t("div",{class:e.goodsDetail},[t($,null,{right:()=>d.platformType==="TEACHER"?t("div",{class:e.shareBtn,onClick:()=>this.shareShow=!0},[t(h,{name:G,size:14,color:"#666"},null),t("span",{style:{marginLeft:"3px"}},[l("\u5206\u4EAB")])]):null}),t(y,{class:e.swipe,lazyRender:!0},{default:()=>[this.albumPics.map((o,r)=>t(z,null,{default:()=>[t(I,{class:e.swipeItemImg,src:o,onClick:()=>this.onPreview(r),fit:"cover"},null)]}))],indicator:o=>o.total>1&&t("div",{class:e["custom-indicator"]},[(o.active||0)+1,l(" / "),o.total])}),t(j,{border:!1,class:[e.goodsHead,"mb12"]},{default:()=>[t(m,{center:!0,border:!1},{title:()=>t("div",{class:e.priceGroup},[t("span",{class:e.price},[t("i",null,[l("\xA5")]),p(this.getPrice)])])}),t(m,{center:!0,border:!1,title:i.name,titleClass:[e.goodsName,"van-ellipsis"]},null)]}),t(v,{class:[e.row,"mb12"]},{default:()=>[t(g,{span:4,class:e.col},{default:()=>[l("\u89C4\u683C")]}),t(g,{span:20},{default:()=>[a?t("div",{class:e.selectWrap},[a.stock<=0?"\u5F53\u524D\u6B3E\u5F0F\u6682\u65F6\u7F3A\u8D27":`\u5DF2\u9009\u62E9 ${a.spDataJson}`]):t("div",null,[l("\u8BF7\u9009\u62E9 \u89C4\u683C")]),t(P,{class:e["radio-group"],modelValue:this.radio,"onUpdate:modelValue":o=>this.radio=o},ht(s=this.skuStockList.map(o=>{const r=o.id===this.radio,c=r?"primary":"default";return t(_,{position:"top-right",content:o.stock<=0?"\u7F3A\u8D27":"",color:"#999999",class:e.badge,offset:[-20,0]},{default:()=>[t(T,{class:e.radio,name:o.id,disabled:o.stock<=0,onClick:()=>{o.stock<=0||(this.radio=o.id)}},{default:()=>[t(x,{size:"large",plain:r,type:c},{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(B,null,[t(D,{class:e.actionBar,"safe-area-inset-bottom":!0},{default:()=>[t(_,{content:this.cartCount,showZero:!1,onClick:()=>{this.$router.push("/cart")}},{default:()=>[t(h,{name:A,size:30},null)]})],button:()=>t("div",{class:e.buyGroup},[t(f,{type:"primary",class:e.addCertBtn,text:"\u52A0\u5165\u8D2D\u7269\u8F66",onClick:()=>this.onShowCart()},null),t(f,{type:"primary",text:"\u7ACB\u5373\u8D2D\u4E70",onClick:()=>this.onShowCart("cartConfirm")},null)])})]),t(S,{show:this.addGoodsShow,closeable:!0,position:"bottom",round:!0,onClose:()=>{this.addGoodsShow=!1}},{default:()=>[t(H,{onGetCartCount:()=>this.getCartCount(),item:this.selectGoodsItem,defaultRadio:this.radio,showType:this.showType},null)]}),t(S,{style:{background:"transparent"},show:this.shareShow,onClose:()=>this.shareShow=!1},{default:()=>[t(N,{shareUrl:this.shareUrl,teacherId:d.user.data.userId,shareType:"mall"},{default:()=>[t("div",{class:e.shareWrap},[t("div",{class:e.shareLeft},[t("img",{crossorigin:"anonymous",class:e.sharePic,src:this.product.pic},null)]),t("div",{class:e.shareRight},[t("div",{class:e.shareShopTitle},[this.product.name]),a?t("div",{class:e.shareShopDes},[a.sku]):null,t("div",{class:e.shareShopValue},[t("span",{class:e.shareShopPrice},[p(this.getPrice)])])])])]})]})])}});export{At as default};