You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
12 KiB
1 lines
12 KiB
import{p as o,o as e,c as s,r as a,$ as t,w as l,a as d,b as i,d as n,F as u,f as r,n as c,e as m,l as p,i as g,j as f,y as _,t as h,z as k,Z as S,v as C,x as y,U as w}from"./index-4ddb689d.js";import{_ as x}from"./mp-html.2b6407c3.js";import{r as b}from"./uni-app.es.24af5d4f.js";import{W as v}from"./wxofficial.956096a5.js";import{p as P,d as T}from"./index.85d62ccb.js";import{a as I,t as B}from"./cart.86d426b5.js";import{G as L}from"./SpecType.cb8615db.js";import{R as N}from"./index.5efbe1fd.js";import{S as V,a as j,C as A}from"./Comment.8cab973f.js";import{C as $}from"./index.cdfc996d.js";import{h as M}from"./color.813a9497.js";import{G as U}from"./index.0d19d98b.js";import{_ as E}from"./_plugin-vue_export-helper.1b428a4d.js";import{_ as R}from"./u-popup.37b3343e.js";import"./comment.083546cf.js";import"./u-icon.e981d1c2.js";import"./index.1169d7d7.js";const D={components:{GoodsSkuPopup:U},emits:["update:modelValue"],props:{modelValue:{Type:Boolean,default:!1},skuMode:{type:Number,default:1},goods:{type:Object,default:{}}},data:()=>({goodsInfo:{},maxBuyNum:null}),computed:{activedBtnBackgroundColor(){return M(this.appTheme.mainBg,.1)}},created(){const o=this,{goods:e}=o;o.goodsInfo={_id:e.goods_id,name:e.goods_name,goods_thumb:e.goods_image,sku_list:o.getSkuList(),spec_list:o.getSpecList()},o.maxBuyNum=o.getMaxBuyNum()},methods:{onChangeValue(o){this.$emit("update:modelValue",o)},getSkuList(){const o=this,{goods:{goods_name:e,goods_image:s,skuList:a}}=o,t=[];return a.forEach((a=>{t.push({_id:a.id,goods_sku_id:a.goods_sku_id,goods_id:a.goods_id,goods_name:e,image:a.image_url?a.image_url:s,price:100*a.goods_price,stock:a.stock_num,spec_value_ids:a.spec_value_ids,sku_name_arr:o.getSkuNameArr(a.spec_value_ids)})})),t},getSkuNameArr(o){const e=this,s=[];return o&&o.forEach(((o,a)=>{const t=e.getSpecValueName(o,a);s.push(t)})),s.length?s:["默认"]},getSpecValueName(o,e){const{goods:{specList:s}}=this;return s[e].valueList.find((e=>e.spec_value_id==o)).spec_value},getSpecList(){const{goods:{specList:o}}=this,e=[];return o.forEach((o=>{const s=[];o.valueList.forEach((o=>{s.push({name:o.spec_value})})),e.push({name:o.spec_name,list:s})})),e.length?e:[{name:"默认",list:[{name:"默认"}]}]},getMaxBuyNum(){const{goods:o}=this;return o.is_restrict?o.restrict_single:null},openSkuPopup(){},closeSkuPopup(){},addCart(e){const s=this,{goods_id:a,goods_sku_id:t,buy_num:l}=e;I(a,t,l).then((e=>{s.$toast(e.message),s.onChangeValue(!1);const a=e.data.cartTotal;o(a),s.$emit("addCart",a)}))},buyNow(o){this.$navTo("pages/checkout/index",{mode:"buyNow",goodsId:o.goods_id,goodsSkuId:o.goods_sku_id,goodsNum:o.buy_num}),this.onChangeValue(!1)}}};const G="goods.service/list";const W=E({components:{Recommended:N,ShareSheet:V,CustomerBtn:$,SlideImage:j,SkuPopup:E(D,[["render",function(o,t,l,d,i,n){const u=a("goods-sku-popup");return e(),s(u,{modelValue:l.modelValue,onInput:n.onChangeValue,"border-radius":"20",localdata:i.goodsInfo,mode:l.skuMode,maskCloseAble:!0,priceColor:o.appTheme.mainBg,buyNowBackgroundColor:o.appTheme.mainBg,addCartColor:o.appTheme.viceText,addCartBackgroundColor:o.appTheme.viceBg,activedStyle:{color:o.appTheme.mainBg,borderColor:o.appTheme.mainBg,backgroundColor:n.activedBtnBackgroundColor},onOpen:n.openSkuPopup,onClose:n.closeSkuPopup,onAddCart:n.addCart,onBuyNow:n.buyNow,buyNowText:"立即购买",maxBuyNum:i.maxBuyNum},null,8,["modelValue","onInput","localdata","mode","priceColor","buyNowBackgroundColor","addCartColor","addCartBackgroundColor","activedStyle","onOpen","onClose","onAddCart","onBuyNow","maxBuyNum"])}]]),Comment:A,Service:E({props:{goodsId:{type:Number,default:null}},data:()=>({isLoading:!0,showPopup:!1,list:[]}),created(){this.getServiceList()},methods:{getServiceList(){const o=this;var e;o.isLoading=!0,(e=o.goodsId,t.get(G,{goodsId:e})).then((e=>o.list=e.data.list)).finally((()=>o.isLoading=!1))},handlePopup(){this.showPopup=!this.showPopup}}},[["render",function(o,a,t,k,S,C){const y=p,w=g,x=f,v=b(_("u-popup"),R);return S.list.length?(e(),s(w,{key:0,class:"service-wrapper",style:c(o.appThemeStyle)},{default:l((()=>[d(w,{class:"service-simple",onClick:C.handlePopup},{default:l((()=>[d(w,{class:"s-list"},{default:l((()=>[(e(!0),i(u,null,n(S.list,((o,a)=>(e(),s(w,{class:"s-item",key:a},{default:l((()=>[d(y,{class:"item-icon iconfont icon-fuwu"}),d(y,{class:"item-val"},{default:l((()=>[r(h(o.name),1)])),_:2},1024)])),_:2},1024)))),128))])),_:1}),d(w,{class:"s-arrow f-26 col-9 t-r"},{default:l((()=>[d(y,{class:"iconfont icon-arrow-right"})])),_:1})])),_:1},8,["onClick"]),d(v,{modelValue:S.showPopup,"onUpdate:modelValue":a[0]||(a[0]=o=>S.showPopup=o),mode:"bottom",closeable:!0,"border-radius":26},{default:l((()=>[d(w,{class:"service-content"},{default:l((()=>[d(w,{class:"title"},{default:l((()=>[r("服务")])),_:1}),d(x,{class:"content-scroll","scroll-y":!0},{default:l((()=>[d(w,{class:"s-list clearfix"},{default:l((()=>[(e(!0),i(u,null,n(S.list,((o,a)=>(e(),s(w,{class:"s-item",key:a},{default:l((()=>[d(y,{class:"item-icon iconfont icon-fuwu"}),d(w,{class:"item-val"},{default:l((()=>[r(h(o.name),1)])),_:2},1024),d(w,{class:"item-summary"},{default:l((()=>[r(h(o.summary),1)])),_:2},1024)])),_:2},1024)))),128))])),_:1})])),_:1})])),_:1})])),_:1},8,["modelValue"])])),_:1},8,["style"])):m("",!0)}],["__scopeId","data-v-f70a2bec"]])},mixins:[v],data:()=>({isLoading:!0,goodsId:null,goods:{},cartTotal:0,showSkuPopup:!1,skuMode:1,showShareSheet:!1,posterApiCall:P,isEnableCart:!1,isShowCustomerBtn:!1}),async onLoad(o){this.onRecordQuery(o),this.onRefreshPage(),this.isShowCustomerBtn=await k.isShowCustomerBtn()},methods:{onRecordQuery(o){const e=S(o);this.goodsId=o.goodsId?parseInt(o.goodsId):parseInt(e.gid)},onRefreshPage(){const o=this;o.isLoading=!0,Promise.all([o.getGoodsDetail(),o.getCartTotal()]).then((()=>o.setWxofficialShareData())).finally((()=>o.isLoading=!1))},getGoodsDetail(){const o=this;return new Promise(((e,s)=>{T(o.goodsId).then((s=>{o.goods=s.data.detail,o.goods.goods_type==L.PHYSICAL.value&&(o.isEnableCart=!0),e(s)})).catch(s)}))},getCartTotal(){const o=this;return new Promise(((e,s)=>{B().then((s=>{o.cartTotal=s.data.cartTotal,e(s)})).catch(s)}))},onAddCart(o){this.cartTotal=o},onShowSkuPopup(o=1){const e=this;e.isEnableCart?e.skuMode=o:e.skuMode=3,e.showSkuPopup=!e.showSkuPopup},onShowShareSheet(){this.showShareSheet=!this.showShareSheet},onTargetHome(o){this.$navTo("pages/index/index")},onTargetCart(){this.$navTo("pages/cart/index")},setWxofficialShareData(){const{goods:o}=this;this.updateShareCardData({title:o.goods_name,desc:o.selling_point,imgUrl:o.goods_image})}},onShareAppMessage(){const o=this,e=o.$getShareUrlParams({goodsId:o.goodsId});return{title:o.goods.goods_name,path:`/pages/goods/detail?${e}`}},onShareTimeline(){const o=this,e=o.$getShareUrlParams({goodsId:o.goodsId});return{title:o.goods.goods_name,path:`/pages/goods/detail?${e}`}}},[["render",function(o,t,f,k,S,v){const P=a("SlideImage"),T=p,I=g,B=w,L=a("Service"),N=a("SkuPopup"),V=a("Comment"),j=b(_("mp-html"),x),A=a("recommended"),$=a("customer-btn"),M=a("share-sheet");return C((e(),s(I,{class:"container",style:c(o.appThemeStyle)},{default:l((()=>[S.isLoading?m("",!0):(e(),s(P,{key:0,video:S.goods.video,videoCover:S.goods.videoCover,images:S.goods.goods_images},null,8,["video","videoCover","images"])),S.isLoading?m("",!0):(e(),s(I,{key:1,class:"goods-info m-top20"},{default:l((()=>[d(I,{class:"info-item info-item__top dis-flex flex-x-between flex-y-end"},{default:l((()=>[d(I,{class:"block-left dis-flex flex-y-center"},{default:l((()=>[d(T,{class:"floor-price__samll"},{default:l((()=>[r("¥")])),_:1}),d(T,{class:"floor-price"},{default:l((()=>[r(h(S.goods.goods_price_min),1)])),_:1}),S.goods.is_user_grade?(e(),s(I,{key:0,class:"user-grade"},{default:l((()=>[d(T,null,{default:l((()=>[r("会员价")])),_:1})])),_:1})):m("",!0),S.goods.line_price_min>0?(e(),s(T,{key:1,class:"original-price"},{default:l((()=>[r("¥"+h(S.goods.line_price_min),1)])),_:1})):m("",!0)])),_:1}),d(I,{class:"block-right dis-flex"},{default:l((()=>[d(I,{class:"goods-sales"},{default:l((()=>[d(T,null,{default:l((()=>[r("已售"+h(S.goods.goods_sales)+"件",1)])),_:1})])),_:1})])),_:1})])),_:1}),d(I,{class:"info-item info-item__name dis-flex flex-y-center"},{default:l((()=>[d(I,{class:"goods-name flex-box"},{default:l((()=>[d(T,{class:"twoline-hide"},{default:l((()=>[r(h(S.goods.goods_name),1)])),_:1})])),_:1}),d(I,{class:"goods-share__line"}),d(I,{class:"goods-share"},{default:l((()=>[d(B,{class:"share-btn dis-flex flex-dir-column",onClick:t[0]||(t[0]=o=>v.onShowShareSheet())},{default:l((()=>[d(T,{class:"share__icon iconfont icon-fenxiang"}),d(T,{class:"f-24"},{default:l((()=>[r("分享")])),_:1})])),_:1})])),_:1})])),_:1}),S.goods.selling_point?(e(),s(I,{key:0,class:"info-item info-item_selling-point"},{default:l((()=>[d(T,null,{default:l((()=>[r(h(S.goods.selling_point),1)])),_:1})])),_:1})):m("",!0)])),_:1})),20==S.goods.spec_type?(e(),s(I,{key:2,class:"goods-choice m-top20 b-f",onClick:t[1]||(t[1]=o=>v.onShowSkuPopup(1))},{default:l((()=>[d(I,{class:"spec-list"},{default:l((()=>[d(I,{class:"flex-box"},{default:l((()=>[d(T,{class:"col-8"},{default:l((()=>[r("选择:")])),_:1}),(e(!0),i(u,null,n(S.goods.specList,((o,a)=>(e(),s(T,{class:"spec-name",key:a},{default:l((()=>[r(h(o.spec_name),1)])),_:2},1024)))),128))])),_:1}),d(I,{class:"f-26 col-9 t-r"},{default:l((()=>[d(T,{class:"iconfont icon-arrow-right"})])),_:1})])),_:1})])),_:1})):m("",!0),S.isLoading?m("",!0):(e(),s(L,{key:3,"goods-id":S.goodsId},null,8,["goods-id"])),S.isLoading?m("",!0):(e(),s(N,{key:4,modelValue:S.showSkuPopup,"onUpdate:modelValue":t[2]||(t[2]=o=>S.showSkuPopup=o),skuMode:S.skuMode,goods:S.goods,onAddCart:v.onAddCart},null,8,["modelValue","skuMode","goods","onAddCart"])),S.isLoading?m("",!0):(e(),s(V,{key:5,"goods-id":S.goodsId,limit:2},null,8,["goods-id"])),S.isLoading?m("",!0):(e(),s(I,{key:6,class:"goods-content m-top20"},{default:l((()=>[d(I,{class:"item-title b-f"},{default:l((()=>[d(T,null,{default:l((()=>[r("商品描述")])),_:1})])),_:1}),""!=S.goods.content?(e(),s(I,{key:0,class:"goods-content__detail b-f"},{default:l((()=>[d(j,{content:S.goods.content},null,8,["content"])])),_:1})):m("",!0)])),_:1})),d(A),d(I,{class:"footer-fixed"},{default:l((()=>[d(I,{class:"footer-container"},{default:l((()=>[d(I,{class:"foo-item-fast"},{default:l((()=>[d(I,{class:"fast-item fast-item--home",onClick:v.onTargetHome},{default:l((()=>[d(I,{class:"fast-icon"},{default:l((()=>[d(T,{class:"iconfont icon-shouye"})])),_:1}),d(I,{class:"fast-text"},{default:l((()=>[d(T,null,{default:l((()=>[r("首页")])),_:1})])),_:1})])),_:1},8,["onClick"]),S.isShowCustomerBtn?(e(),s($,{key:0},{default:l((()=>[d(I,{class:"fast-item"},{default:l((()=>[d(I,{class:"fast-icon"},{default:l((()=>[d(T,{class:"iconfont icon-kefu1"})])),_:1}),d(I,{class:"fast-text"},{default:l((()=>[d(T,null,{default:l((()=>[r("客服")])),_:1})])),_:1})])),_:1})])),_:1})):m("",!0),d(I,{class:"fast-item fast-item--cart",onClick:v.onTargetCart},{default:l((()=>[S.cartTotal>0?(e(),s(I,{key:0,class:"fast-badge fast-badge--fixed"},{default:l((()=>[r(h(S.cartTotal>99?"99+":S.cartTotal),1)])),_:1})):m("",!0),d(I,{class:"fast-icon"},{default:l((()=>[d(T,{class:"iconfont icon-gouwuche"})])),_:1}),d(I,{class:"fast-text"},{default:l((()=>[d(T,null,{default:l((()=>[r("购物车")])),_:1})])),_:1})])),_:1},8,["onClick"])])),_:1}),d(I,{class:"foo-item-btn"},{default:l((()=>[d(I,{class:"btn-wrapper"},{default:l((()=>[S.isEnableCart?(e(),s(I,{key:0,class:"btn-item btn-item-deputy",onClick:t[3]||(t[3]=o=>v.onShowSkuPopup(2))},{default:l((()=>[d(T,null,{default:l((()=>[r("加入购物车")])),_:1})])),_:1})):m("",!0),d(I,{class:"btn-item btn-item-main",onClick:t[4]||(t[4]=o=>v.onShowSkuPopup(3))},{default:l((()=>[d(T,null,{default:l((()=>[r("立即购买")])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})])),_:1}),d(M,{modelValue:S.showShareSheet,"onUpdate:modelValue":t[5]||(t[5]=o=>S.showShareSheet=o),shareTitle:S.goods.goods_name,shareImageUrl:S.goods.goods_image,posterApiCall:S.posterApiCall,posterApiParam:{goodsId:S.goodsId}},null,8,["modelValue","shareTitle","shareImageUrl","posterApiCall","posterApiParam"])])),_:1},8,["style"])),[[y,!S.isLoading]])}],["__scopeId","data-v-b5697ef4"]]);export{W as default};
|
|
|