import{x as e,o as a,c as t,w as l,a as s,e as o,f as n,g as i,i as r,ab as d,B as c,ac as u,K as p,ad as m,t as h,j as f,k as _,r as g,b as C,d as y,F as v,P as w,N as k,O as b}from"./index-ae8bbb19.js";import{_ as P}from"./u-popup.d74d5514.js";import{r as x}from"./uni-app.es.ee1d5b08.js";import{_ as I}from"./_plugin-vue_export-helper.1b428a4d.js";import{a as S,_ as V}from"./comment.92b0fbb1.js";import{A as L}from"./index.0c0be40a.js";const A=I({name:"ShareSheet",components:{GoodsPosterPopup:I({name:"goods-poster-popup",emits:["update:modelValue"],props:{modelValue:{Type:Boolean,default:!1},apiCall:{type:Function,default:()=>{}},apiParam:{type:Object,default:()=>{}}},watch:{modelValue:{immediate:!0,handler(e){e?this.onShowPopup():this.show=!1}}},data:()=>({show:!1,imageUrl:""}),methods:{onShowPopup(){const e=this;e.apiCall({...e.apiParam,channel:e.platform}).then((a=>{e.imageUrl=a.data.imageUrl,e.show=!0})).catch((a=>e.onClose()))},onClose(){this.$emit("update:modelValue",!1)},handlePreviewImage(){uni.previewImage({urls:[this.imageUrl]})},handleDownload(){const e=this;uni.showLoading({title:"加载中"}),uni.downloadFile({url:e.imageUrl,success(a){console.log(a),uni.hideLoading(),e.onSaveImage(a.tempFilePath)},fail(a){console.log("fail",a),uni.hideLoading(),e.$toast("很抱歉,自动保存失败 请点击图片后长按手动保存",3e3)}})},onSaveImage(e){const a=e.split("/"),t=a[a.length-1];this.fileDownLoadForH5({name:t,blob:e}),this.onClose()},fileDownLoadForH5({name:e,blob:a}){const t=document.createElement("a");t.setAttribute("href",a),t.setAttribute("downLoad",e),t.click()}}},[["render",function(d,c,u,p,m,h){const f=i,_=r,g=x(e("u-popup"),P);return a(),t(g,{modelValue:m.show,"onUpdate:modelValue":c[2]||(c[2]=e=>m.show=e),mode:"center",maskCloseAble:!1,closeable:!0,maskCustomStyle:{background:"rgba(0, 0, 0, 0.5)"},"border-radius":"18","z-index":12,onClose:c[3]||(c[3]=e=>h.onClose())},{default:l((()=>[s(_,{class:"pop-poster pop-example__container"},{default:l((()=>[s(_,{class:"image__container",onClick:c[0]||(c[0]=e=>h.handlePreviewImage())},{default:l((()=>[m.imageUrl?(a(),t(f,{key:0,class:"image",mode:"scaleToFill",src:m.imageUrl},null,8,["src"])):o("",!0)])),_:1}),s(_,{class:"save-btn__container"},{default:l((()=>[s(_,{class:"save-btn",onClick:c[1]||(c[1]=e=>h.handleDownload())},{default:l((()=>[n("保存海报图")])),_:1})])),_:1})])),_:1})])),_:1},8,["modelValue","maskCustomStyle"])}],["__scopeId","data-v-434e9104"]])},emits:["update:modelValue"],props:{modelValue:{Type:Boolean,default:!1},cancelWithMask:{type:Boolean,default:!0},shareTitle:{type:String,default:"商品分享"},shareImageUrl:{type:String,default:""},cancelText:{type:String,default:"关闭"},posterApiCall:{type:Function,default:()=>{}},posterApiParam:{type:Object,default:()=>{}}},data:()=>({enabledAppShareWeixin:d.get("enabledAppShareWeixin"),showGoodsPosterPopup:!1}),created(){this.initSharesheet()},methods:{initSharesheet(){const e=this;uni.getProvider({service:"share",success({provider:a}){c("weixin",a)||(e.enabledAppShareWeixin=!1)}})},onMaskClick(){this.cancelWithMask&&this.handleCancel()},getShareUrl(){const{path:e,query:a}=u();return new Promise(((t,l)=>{p.h5Url().then((l=>{const s=m(l,e,a);t(s)}))}))},handleCopyLink(){const e=this;e.getShareUrl().then((a=>{uni.setClipboardData({data:a,success:()=>e.$toast("链接复制成功,快去发送给朋友吧~"),fail:a=>e.$toast("很遗憾,复制失败"),complete:()=>e.handleCancel()})}))},handleCancel(){this.$emit("update:modelValue",!1)},handlePoster(){this.showGoodsPosterPopup=!0,this.handleCancel()}}},[["render",function(e,i,d,c,u,p){const m=r,C=_,y=g("goods-poster-popup");return a(),t(m,{class:f(["sharesheet",{show:d.modelValue}])},{default:l((()=>[s(m,{class:"mask-class sharesheet__mask",onClick:p.onMaskClick},null,8,["onClick"]),s(m,{class:"sharesheet__container"},{default:l((()=>[s(m,{class:"sharesheet__list"},{default:l((()=>[s(m,{class:"share-item",onClick:i[0]||(i[0]=e=>p.handlePoster())},{default:l((()=>[s(m,{class:"item-image",style:{backgroundColor:"#38beec"}},{default:l((()=>[s(C,{class:"iconfont icon-poster"})])),_:1}),s(m,{class:"item-name"},{default:l((()=>[s(C,null,{default:l((()=>[n("生成海报")])),_:1})])),_:1})])),_:1}),s(m,{class:"share-item",onClick:i[1]||(i[1]=e=>p.handleCopyLink())},{default:l((()=>[s(m,{class:"item-image",style:{backgroundColor:"#38beec"}},{default:l((()=>[s(C,{class:"iconfont icon-link"})])),_:1}),s(m,{class:"item-name"},{default:l((()=>[s(C,null,{default:l((()=>[n("复制链接")])),_:1})])),_:1})])),_:1})])),_:1}),d.cancelText?(a(),t(m,{key:0,class:"sharesheet__footer",onClick:i[2]||(i[2]=e=>p.handleCancel())},{default:l((()=>[s(m,{class:"btn-cancel"},{default:l((()=>[n(h(d.cancelText),1)])),_:1})])),_:1})):o("",!0)])),_:1}),s(y,{modelValue:u.showGoodsPosterPopup,"onUpdate:modelValue":i[3]||(i[3]=e=>u.showGoodsPosterPopup=e),apiCall:d.posterApiCall,apiParam:d.posterApiParam},null,8,["modelValue","apiCall","apiParam"])])),_:1},8,["class"])}],["__scopeId","data-v-d8016c6c"]]);const U=I({props:{video:{type:Object,default:()=>null},videoCover:{type:Object,default:()=>null},images:{type:Array,default:[]}},data:()=>({indicatorDots:!0,autoplay:!0,interval:4e3,duration:800,currentIndex:1}),methods:{onVideoPlay(e){this.autoplay=!1},setCurrent({detail:e}){this.currentIndex=e.current+1},onPreviewImages(e){const a=[];this.images.forEach((e=>{a.push(e.preview_url)})),uni.previewImage({current:a[e],urls:a})}}},[["render",function(e,d,c,u,p,m){const f=w,g=r,P=k,x=i,I=b,S=_;return a(),t(g,{class:"images-swiper"},{default:l((()=>[s(I,{class:"swiper-box",autoplay:p.autoplay,duration:p.duration,"indicator-dots":p.indicatorDots,interval:p.interval,circular:!0,onChange:m.setCurrent},{default:l((()=>[c.video?(a(),t(P,{key:0},{default:l((()=>[s(g,{class:"slide-video"},{default:l((()=>[s(f,{id:"myVideo",class:"video",poster:c.videoCover.preview_url,src:c.video.external_url,controls:"","x5-playsinline":"",playsinline:"","x5-video-player-type":"h5","x5-video-player-fullscreen":"","x5-video-orientation":"portrait","enable-progress-gesture":!1,onPlay:m.onVideoPlay},null,8,["poster","src","onPlay"])])),_:1})])),_:1})):o("",!0),(a(!0),C(v,null,y(c.images,((e,o)=>(a(),t(P,{key:o,onClick:e=>m.onPreviewImages(o)},{default:l((()=>[s(g,{class:"slide-image"},{default:l((()=>[s(x,{class:"image",draggable:!1,src:e.preview_url},null,8,["src"])])),_:2},1024)])),_:2},1032,["onClick"])))),128))])),_:1},8,["autoplay","duration","indicator-dots","interval","onChange"]),s(g,{class:"swiper-count"},{default:l((()=>[s(S,null,{default:l((()=>[n(h(p.currentIndex),1)])),_:1}),s(S,null,{default:l((()=>[n("/")])),_:1}),s(S,null,{default:l((()=>[n(h(c.images.length+(c.video?1:0)),1)])),_:1})])),_:1})])),_:1})}],["__scopeId","data-v-0062d7ee"]]);const T=I({components:{AvatarImage:L},props:{goodsId:{type:Number,default:null},limit:{type:Number,default:2}},data:()=>({isLoading:!0,rates:{10:5,20:3,30:1},list:[],total:0}),created(){this.getCommentList()},methods:{getCommentList(){const e=this;e.isLoading=!0,S(e.goodsId,e.limit).then((a=>{e.list=a.data.list,e.total=a.data.total})).catch((e=>e)).finally((()=>e.isLoading=!1))},onTargetToComment(){this.$navTo("pages/comment/index",{goodsId:this.goodsId})}}},[["render",function(i,d,c,u,p,m){const f=_,w=r,k=g("avatar-image"),b=x(e("u-rate"),V);return!p.isLoading&&p.list.length?(a(),t(w,{key:0,class:"goods-comment m-top20"},{default:l((()=>[s(w,{class:"item-title dis-flex"},{default:l((()=>[s(w,{class:"block-left flex-box"},{default:l((()=>[n(" 商品评价 ("),s(f,{class:"total"},{default:l((()=>[n(h(p.total)+"条",1)])),_:1}),n(") ")])),_:1}),s(w,{class:"block-right"},{default:l((()=>[s(f,{onClick:m.onTargetToComment,class:"show-more col-9"},{default:l((()=>[n("查看更多")])),_:1},8,["onClick"]),s(f,{class:"iconfont icon-arrow-right col-9"})])),_:1})])),_:1}),s(w,{class:"comment-list"},{default:l((()=>[(a(!0),C(v,null,y(p.list,((e,o)=>(a(),t(w,{class:"comment-item",key:o},{default:l((()=>[s(w,{class:"comment-item_row dis-flex flex-y-center"},{default:l((()=>[s(w,{class:"user-info dis-flex flex-y-center"},{default:l((()=>[s(w,{class:"user-avatar"},{default:l((()=>[s(k,{url:e.user.avatar_url,width:50},null,8,["url"])])),_:2},1024),s(f,{class:"user-name"},{default:l((()=>[n(h(e.user.nick_name),1)])),_:2},1024)])),_:2},1024),s(w,{class:"star-rating"},{default:l((()=>[s(b,{"active-color":"#f4a213",current:p.rates[e.score],disabled:!0},null,8,["current"])])),_:2},1024)])),_:2},1024),s(w,{class:"item-content m-top20"},{default:l((()=>[s(f,{class:"f-26 twoline-hide"},{default:l((()=>[n(h(e.content),1)])),_:2},1024)])),_:2},1024),s(w,{class:"comment-time"},{default:l((()=>[n(h(e.create_time),1)])),_:2},1024)])),_:2},1024)))),128))])),_:1})])),_:1})):o("",!0)}],["__scopeId","data-v-94b3762a"]]);export{T as C,A as S,U as a};