import{_ as e,ab as s,aa as a,ak as l,b as t,d as i,p as n,w as u,H as c,i as o,o as d,f as r,k as p,t as f,e as g,y as h,F as _,a5 as m,a1 as y,D as I}from"./index-2PZN6pGH.js";import{p as T}from"./permission.D706xXoU.js";var x=[["camera"],["album"],["camera","album"]],C=[["compressed"],["original"],["compressed","original"]];const v=e({data:()=>({title:"choose/previewImage",imageList:[],sourceTypeIndex:2,sourceType:["拍照","相册","拍照或相册"],sizeTypeIndex:2,sizeType:["压缩","原图","压缩或原图"],countIndex:8,count:[1,2,3,4,5,6,7,8,9]}),onUnload(){this.imageList=[],this.sourceTypeIndex=2,this.sourceType=["拍照","相册","拍照或相册"],this.sizeTypeIndex=2,this.sizeType=["压缩","原图","压缩或原图"],this.countIndex=8},methods:{sourceTypeChange:function(e){this.sourceTypeIndex=parseInt(e.detail.value)},sizeTypeChange:function(e){this.sizeTypeIndex=parseInt(e.detail.value)},countChange:function(e){this.countIndex=e.detail.value},chooseImage:async function(){if(9===this.imageList.length){let e=await this.isFullImg();if(console.log("是否继续?",e),!e)return}s({sourceType:x[this.sourceTypeIndex],sizeType:C[this.sizeTypeIndex],count:this.imageList.length+this.count[this.countIndex]>9?9-this.imageList.length:this.count[this.countIndex],success:e=>{this.imageList=this.imageList.concat(e.tempFilePaths)},fail:e=>{console.log("err: ",e)}})},isFullImg:function(){return new Promise((e=>{a({content:"已经有9张图片了,是否清空现有图片？",success:s=>{s.confirm?(this.imageList=[],e(!0)):e(!1)},fail:()=>{e(!1)}})}))},previewImage:function(e){var s=e.target.dataset.src;l({current:s,urls:this.imageList})},async checkPermission(e){let s=e?e-1:this.sourceTypeIndex,l=T.isIOS?await T.requestIOS(x[s][0]):await T.requestAndroid(0===s?"android.permission.CAMERA":"android.permission.READ_EXTERNAL_STORAGE");return null===l||1===l?l=1:a({content:"没有开启权限",confirmText:"设置",success:function(e){e.confirm&&T.gotoAppSetting()}}),l}}},[["render",function(e,s,a,l,T,x){const C=t(i("page-head"),c),v=o,z=m,L=I,b=y;return d(),n(v,null,{default:u((()=>[r(C,{title:T.title},null,8,["title"]),r(v,{class:"uni-common-mt"},{default:u((()=>[r(b,null,{default:u((()=>[r(v,{class:"uni-list"},{default:u((()=>[r(v,{class:"uni-list-cell"},{default:u((()=>[r(v,{class:"uni-list-cell-left"},{default:u((()=>[r(v,{class:"uni-label"},{default:u((()=>[p("图片来源")])),_:1})])),_:1}),r(v,{class:"uni-list-cell-right"},{default:u((()=>[r(z,{range:T.sourceType,onChange:x.sourceTypeChange,value:T.sourceTypeIndex,mode:"selector"},{default:u((()=>[r(v,{class:"uni-input"},{default:u((()=>[p(f(T.sourceType[T.sourceTypeIndex]),1)])),_:1})])),_:1},8,["range","onChange","value"])])),_:1})])),_:1}),r(v,{class:"uni-list-cell"},{default:u((()=>[r(v,{class:"uni-list-cell-left"},{default:u((()=>[r(v,{class:"uni-label"},{default:u((()=>[p("图片质量")])),_:1})])),_:1}),r(v,{class:"uni-list-cell-right"},{default:u((()=>[r(z,{range:T.sizeType,onChange:x.sizeTypeChange,value:T.sizeTypeIndex,mode:"selector"},{default:u((()=>[r(v,{class:"uni-input"},{default:u((()=>[p(f(T.sizeType[T.sizeTypeIndex]),1)])),_:1})])),_:1},8,["range","onChange","value"])])),_:1})])),_:1}),r(v,{class:"uni-list-cell"},{default:u((()=>[r(v,{class:"uni-list-cell-left"},{default:u((()=>[r(v,{class:"uni-label"},{default:u((()=>[p("数量限制")])),_:1})])),_:1}),r(v,{class:"uni-list-cell-right"},{default:u((()=>[r(z,{range:T.count,onChange:x.countChange,mode:"selector"},{default:u((()=>[r(v,{class:"uni-input"},{default:u((()=>[p(f(T.count[T.countIndex]),1)])),_:1})])),_:1},8,["range","onChange"])])),_:1})])),_:1})])),_:1}),r(v,{class:"uni-list list-pd"},{default:u((()=>[r(v,{class:"uni-list-cell cell-pd"},{default:u((()=>[r(v,{class:"uni-uploader"},{default:u((()=>[r(v,{class:"uni-uploader-head"},{default:u((()=>[r(v,{class:"uni-uploader-title"},{default:u((()=>[p("点击可预览选好的图片")])),_:1}),r(v,{class:"uni-uploader-info"},{default:u((()=>[p(f(T.imageList.length)+"/9",1)])),_:1})])),_:1}),r(v,{class:"uni-uploader-body"},{default:u((()=>[r(v,{class:"uni-uploader__files"},{default:u((()=>[(d(!0),g(_,null,h(T.imageList,((e,s)=>(d(),n(v,{key:s,class:"uni-uploader__file"},{default:u((()=>[r(L,{class:"uni-uploader__img",src:e,"data-src":e,onClick:x.previewImage},null,8,["src","data-src","onClick"])])),_:2},1024)))),128)),r(v,{class:"uni-uploader__input-box"},{default:u((()=>[r(v,{class:"uni-uploader__input",onClick:x.chooseImage},null,8,["onClick"])])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})])),_:1})}],["__scopeId","data-v-c53a8f74"]]);export{v as default};
