WokerTask/public/mobile/assets/pages-collection-collection...

2 lines
4.1 KiB
JavaScript
Raw Permalink Normal View History

2023-12-27 14:06:33 +08:00
import{_ as t}from"./news-card.bf9d4267.js";import{P as e,aA as s,o as i,c as o,w as a,b as n,x as l,v as h,E as d,e as c,f as u,l as r,t as m,F as p,h as f,k as v,aB as b,aC as w,d as g,V as y,m as k,z as x,r as C,a as _}from"./index.26a6cf84.js";import{_ as W}from"./plugin-vue_export-helper.21dcd24c.js";import{_ as X}from"./z-paging.dba6931f.js";import{e as B,c as $}from"./news.3e6b7eb5.js";import"./u-image.e15c05f6.js";import"./u-icon.7191c6e8.js";import"./icon_visit.9ad00ab7.js";var F=W({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=b,_=w;return i(),o(x,{class:""},{default:a((()=>[n(_,{class:"u-swipe-action",style:l({backgroundColor:s.bgColor})},{default:a((()=>[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:a((()=>[n(x,{class:"u-swipe-content",onClick:h(k.contentClick,["stop"])},{default:a((()=>[d(t.$slots,"default",{},void 0,!0)])),_:3},8,["onClick"]),y.showBtn?(i(!0),c(p,{key:0},u(s.options,((t,e)=>(i(),o(x,{class:"u-swipe-del",onClick:h((t=>k.btnClick(e)),["stop"]),style:l([k.btnStyle(t.style)]),key:e},{default:a((()=>[n(x,{class:"u-btn-text"},{default:a((()=>[r(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)},r=async t=>{try{const e=h.value[t].article_id;await $({id:e}),uni.$u.toast("已取消收藏"),s.value.reload()}catch(e){console.log("取消收藏报错=>",e)}};return(e,m)=>{const f=C(_("news-card"),t),v=C(_("u-swipe-action"),F),b=C(_("z-paging"),X);return i(),o(b,{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:a((()=>[(i(!0),c(p,null,u(h.value,((t,e)=>(i(),o(v,{show:t.show,index:e,key:t.id,onClick:r,options:l,"btn-width":"120"},{default:a((()=>[n(f,{item:t,newsId:t.article_id},