"use strict";const e=require("../../common/vendor.js"),a=require("../../utils/system.js"),l=require("../../api/apis.js");if(!Array){(e.resolveComponent("uni-icons")+e.resolveComponent("uni-dateformat")+e.resolveComponent("uni-rate")+e.resolveComponent("uni-popup"))()}Math||((()=>"../../uni_modules/uni-icons/components/uni-icons/uni-icons.js")+(()=>"../../uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat.js")+(()=>"../../uni_modules/uni-rate/components/uni-rate/uni-rate.js")+(()=>"../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"))();const o={__name:"preview",setup(o){const i=e.ref(!0),t=e.ref(null),u=e.ref({}),n=e.ref(null),s=e.ref(0),r=e.ref(!1),c=e.ref([]),p=e.ref(null),d=e.ref(0),v=e.ref([]),m=e.index.getStorageSync("storgClassList")||[];c.value=m.map((e=>({...e,picurl:e.smallPicurl.replace("_small.webp",".jpg")}))),e.onLoad((async e=>{if(p.value=e.id,"share"==e.type){let e=await l.apiDetailWall({id:p.value});c.value=e.data.map((e=>({...e,picurl:e.smallPicurl.replace("_small.webp",".jpg")})))}d.value=c.value.findIndex((e=>e._id==p.value)),h(),u.value=c.value[d.value]}));const f=e=>{d.value=e.detail.current,h(),u.value=c.value[d.value]},h=()=>{v.value.push(d.value<=0?c.value.length-1:d.value-1,d.value,d.value>=c.value.length-1?0:d.value+1),v.value=[...new Set(v.value)]},g=()=>{t.value.open()},w=()=>{t.value.close()},x=()=>{u.value.userScore&&(r.value=!0,s.value=u.value.userScore),n.value.open()},y=()=>{n.value.close(),s.value=0,r.value=!1},b=async()=>{e.index.showLoading({title:"加载中..."});let{classid:a,_id:o}=u.value,i=await l.apiGetSetScore({classid:a,wallId:o,userScore:s.value});e.index.hideLoading(),0===i.errCode&&e.index.showToast({title:"评分成功",icon:"none"}),c.value[d.value].userScore=s.value,e.index.setStorageSync("storgClassList",c.value),y()},_=()=>{i.value=!i.value},S=()=>{e.index.navigateBack({success:()=>{},fail:a=>{e.index.reLaunch({url:"/pages/index/index"})}})},C=async()=>{try{e.index.showLoading({title:"下载中...",mask:!0});let{classid:a,_id:o}=u.value,i=await l.apiWriteDownload({classid:a,wallId:o});if(0!=i.errCode)throw i;e.index.getImageInfo({src:u.value.picurl,success:a=>{e.index.saveImageToPhotosAlbum({filePath:a.path,success:a=>{e.index.showToast({title:"保存成功，请到相册查看",icon:"none"})},fail:a=>{"saveImagePhotoAlbum:fail cancel"!=a.errMsg?e.index.showModal({title:"授权提示",content:"需要授权保存相册",success:a=>{a.confirm&&e.index.openSetting({success:a=>{console.log(a),a.authSetting["scope.writePhotosAlbum"]?e.index.showToast({title:"获取授权成功",icon:"none"}):e.index.showToast({title:"获取权限失败",icon:"none"})}})}}):e.index.showToast({title:"保存失败，请重新点击下载",icon:"none"})},complete:()=>{e.index.hideLoading()}})}})}catch(a){e.index.hideLoading()}};return e.onShareAppMessage((e=>({title:"hzb壁纸-",path:"/pages/preview/preview?id="+p.value+"&type=share"}))),e.onShareTimeline((()=>({title:"hzb壁纸~~~",query:"id="+p.value+"&type=share"}))),(l,o)=>({a:e.f(c.value,((a,l,o)=>e.e({a:v.value.includes(l)},v.value.includes(l)?{b:e.o(_,a._id),c:a.picurl}:{},{d:a._id}))),b:d.value,c:e.o(f),d:e.p({type:"back",color:"#fff",size:"20"}),e:e.o(S),f:e.unref(a.getPreviewBarHeight)()+"px",g:e.t(d.value+1),h:e.t(c.value.length),i:e.p({date:Date.now(),format:"hh:mm"}),j:e.p({date:Date.now(),format:"MM月dd日"}),k:e.p({type:"info",size:"23"}),l:e.o(g),m:e.p({type:"star",size:"23"}),n:e.t(u.value.score),o:e.o(x),p:e.p({type:"download",size:"23"}),q:e.o(C),r:i.value,s:e.p({type:"closeempty",size:"18",color:"#999"}),t:e.o(w),v:e.t(u.value._id),w:e.t(u.value.nickname),x:e.p({readonly:!0,touchable:!1,value:u.value.score,size:"16"}),y:e.t(u.value.score),z:e.t(u.value.description),A:e.f(u.value.tabs,((a,l,o)=>({a:e.t(a),b:a}))),B:e.sr(t,"d9b78fb0-6",{k:"infoPopup"}),C:e.p({type:"bottom"}),D:e.t(r.value?"已经评分过了~":"壁纸评分"),E:e.p({type:"closeempty",size:"18",color:"#999"}),F:e.o(y),G:e.o(l.onChange),H:e.o((e=>s.value=e)),I:e.p({disabled:r.value,"disabled-color":"#FFCA3E",allowHalf:!0,modelValue:s.value}),J:e.t(s.value),K:e.o(b),L:!s.value||r.value,M:e.sr(n,"d9b78fb0-9",{k:"scorePopup"}),N:e.p({"is-mask-click":!1})})}},i=e._export_sfc(o,[["__scopeId","data-v-d9b78fb0"]]);o.__runtimeHooks=6,wx.createPage(i);
