import{_ as t}from"./news-card.73abff51.js";import{R as e,ar as s,o as i,c as a,w as o,b as n,q as l,x as h,E as d,e as c,f as r,l as u,t as m,F as p,h as f,k as v,as as w,at as b,d as g,X as y,m as k,z as x,r as C,a as W}from"./index.2c848137.js";import{_}from"./plugin-vue_export-helper.21dcd24c.js";import{_ as X}from"./z-paging.01368afc.js";import{e as B,c as $}from"./news.46a75e85.js";import"./u-image.843d4f39.js";import"./u-icon.a9820ed8.js";import"./icon_visit.9ad00ab7.js";var F=_({name:"u-swipe-action",emits:["click","content-click","open","close"],props:{index:{type:[Number,String],default:""},btnWidth:{type:[String,Number],default:180},disabled:{type:Boolean,default:!1},show:{type:Boolean,default:!1},bgColor:{type:String,default:"#ffffff"},vibrateShort:{type:Boolean,default:!1},options:{type:Array,default:()=>[]}},watch:{show:{immediate:!0,handler(t,e){t?this.open():this.close()}}},data(){return{moveX:0,scrollX:0,status:!1,movableAreaWidth:0,elId:this.$u.guid(),showBtn:!1}},computed:{movableViewWidth(){return this.movableAreaWidth+this.allBtnWidth+"px"},innerBtnWidth(){return e(this.btnWidth)},allBtnWidth(){return e(this.btnWidth)*this.options.length},btnStyle(){return t=>(t.width=this.btnWidth+"rpx",t)}},mounted(){this.getActionRect()},methods:{btnClick(t){this.status=!1,this.$emit("click",this.index,t)},change(t){this.scrollX=t.detail.x},close(){this.moveX=0,this.status=!1},open(){this.disabled||(this.moveX=-this.allBtnWidth,this.status=!0)},touchend(){this.moveX=this.scrollX,this.$nextTick((function(){0==this.status?this.scrollX<=-this.allBtnWidth/4?(this.moveX=-this.allBtnWidth,this.status=!0,this.emitOpenEvent(),this.vibrateShort&&s()):(this.moveX=0,this.status=!1,this.emitCloseEvent()):this.scrollX>3*-this.allBtnWidth/4?(this.moveX=0,this.$nextTick((()=>{this.moveX=101})),this.status=!1,this.emitCloseEvent()):(this.moveX=-this.allBtnWidth,this.status=!0,this.emitOpenEvent())}))},emitOpenEvent(){this.$emit("open",this.index)},emitCloseEvent(){this.$emit("close",this.index)},touchstart(){},getActionRect(){this.$uGetRect(".u-swipe-action").then((t=>{this.movableAreaWidth=t.width,this.$nextTick((()=>{this.showBtn=!0}))}))},contentClick(){1==this.status&&(this.status="close",this.moveX=0),this.$emit("content-click",this.index)}}},[["render",function(t,e,s,g,y,k){const x=v,C=w,W=b;return i(),a(x,{class:""},{default:o((()=>[n(W,{class:"u-swipe-action",style:l({backgroundColor:s.bgColor})},{default:o((()=>[n(C,{class:"u-swipe-view",onChange:k.change,onTouchend:k.touchend,onTouchstart:k.touchstart,direction:"horizontal",disabled:s.disabled,x:y.moveX,style:l({width:k.movableViewWidth?k.movableViewWidth:"100%"})},{default:o((()=>[n(x,{class:"u-swipe-content",onClick:h(k.contentClick,["stop"])},{default:o((()=>[d(t.$slots,"default",{},void 0,!0)])),_:3},8,["onClick"]),y.showBtn?(i(!0),c(p,{key:0},r(s.options,((t,e)=>(i(),a(x,{class:"u-swipe-del",onClick:h((t=>k.btnClick(e)),["stop"]),style:l([k.btnStyle(t.style)]),key:e},{default:o((()=>[n(x,{class:"u-btn-text"},{default:o((()=>[u(m(t.text),1)])),_:2},1024)])),_:2},1032,["onClick","style"])))),128)):f("v-if",!0)])),_:3},8,["onChange","onTouchend","onTouchstart","disabled","x","style"])])),_:3},8,["style"])])),_:3})}],["__scopeId","data-v-d0fdd334"]]);const j=g({__name:"collection",setup(e){const s=y(),l=k([{text:"取消收藏",style:{color:"#FFFFFF",backgroundColor:"#FF2C3C"}}]),h=x([]),d=async(t,e)=>{const{lists:i}=await B();i.forEach((t=>{t.show=!1})),h.value=i,s.value.complete(i)},u=async t=>{try{const e=h.value[t].articleId;await $({articleId:e}),uni.$u.toast("已取消收藏"),s.value.reload()}catch(e){console.log("取消收藏报错=>",e)}};return(e,m)=>{const f=C(W("news-card"),t),v=C(W("u-swipe-action"),F),w=C(W("z-paging"),X);return i(),a(w,{ref_key:"paging",ref:s,modelValue:h.value,"onUpdate:modelValue":m[0]||(m[0]=t=>h.value=t),onQuery:d,fixed:!1,height:"100%","use-page-scroll":""},{default:o((()=>[(i(!0),c(p,null,r(h.value,((t,e)=>(i(),a(v,{show:t.show,index:e,key:t.id,onClick:u,options:l,"btn-width":"120"},{default:o((()=>[n(f,{item:t,newsId:t.articleId},null,8,["item","newsId"])])),_:2},1032,["show","index","options"])))),128))])),_:1},8,["modelValue"])}}});export{j as default};
