logistics_sy/public/mobile/assets/packages-pages-user_wallet-...

2 lines
6.4 KiB
JavaScript
Raw Normal View History

2023-11-08 15:13:08 +08:00
import{G as t,P as e,r as a,a as l,o as i,c as s,w as r,h as u,b as n,s as o,e as d,f as c,x as h,l as f,t as p,F as m,k as b,U as y,d as g,z as x,V as _,aa as v,aY as S,i as w}from"./index.26a6cf84.js";import{_ as I}from"./u-badge.f4477090.js";import{_ as k}from"./plugin-vue_export-helper.21dcd24c.js";import{_ as B}from"./z-paging.dba6931f.js";import{r as $}from"./recharge.ff7c9ddf.js";var C=k({name:"u-tabs",emits:["update:modelValue","input","change"],props:{value:{type:[Number,String],default:0},modelValue:{type:[Number,String],default:0},current:{type:[Number,String],default:0},isScroll:{type:Boolean,default:!0},list:{type:Array,default:()=>[]},height:{type:[String,Number],default:80},fontSize:{type:[String,Number],default:30},duration:{type:[String,Number],default:.5},activeColor:{type:String,default:"#2979ff"},inactiveColor:{type:String,default:"#303133"},barWidth:{type:[String,Number],default:40},barHeight:{type:[String,Number],default:6},gutter:{type:[String,Number],default:30},bgColor:{type:String,default:"#ffffff"},name:{type:String,default:"name"},count:{type:String,default:"count"},offset:{type:Array,default:()=>[5,20]},bold:{type:Boolean,default:!0},activeItemStyle:{type:Object,default:()=>({})},showBar:{type:Boolean,default:!0},barStyle:{type:Object,default:()=>({})},itemWidth:{type:[Number,String],default:"auto"}},data(){return{scrollLeft:0,tabQueryInfo:[],componentWidth:0,scrollBarLeft:0,parentLeft:0,id:this.$u.guid(),currentIndex:this.current,barFirstTimeMove:!0}},watch:{list:{immediate:!0,handler(t,e){e&&t.length!==e.length&&(this.currentIndex=0),setTimeout((()=>{this.init()}),200)}},current:{immediate:!0,handler(t,e){this.$nextTick((()=>{this.currentIndex=t,this.scrollByIndex()}))}},valueCom:{immediate:!0,handler(t,e){this.$nextTick((()=>{this.currentIndex=t,this.scrollByIndex()}))}}},computed:{valueCom(){return this.modelValue},tabBarStyle(){let t={width:this.barWidth+"rpx",transform:`translate(${this.scrollBarLeft}px, -100%)`,"transition-duration":`${this.barFirstTimeMove?0:this.duration}s`,"background-color":this.activeColor,height:this.barHeight+"rpx","border-radius":this.barHeight/2+"px"};return Object.assign(t,this.barStyle),t},tabItemStyle(){return t=>{let e={height:this.height+"rpx","line-height":this.height+"rpx","font-size":this.fontSize+"rpx","transition-duration":`${this.duration}s`,padding:this.isScroll?`0 ${this.gutter}rpx`:"",flex:this.isScroll?"auto":"1",width:this.$u.addUnit(this.itemWidth)};return t==this.currentIndex&&this.bold&&(e.fontWeight="bold"),t==this.currentIndex?(e.color=this.activeColor,e=Object.assign(e,this.activeItemStyle)):e.color=this.inactiveColor,e}}},methods:{async init(){let t=await this.$uGetRect("#"+this.id);this.parentLeft=t.left,this.componentWidth=t.width,this.getTabRect()},clickTab(t){t!=this.currentIndex&&(this.$emit("change",t),this.$emit("input",t),this.$emit("update:modelValue",t))},getTabRect(){let e=t().in(this);for(let t=0;t<this.list.length;t++)e.select(`#u-tab-item-${t}`).fields({id:!0,size:!0,rect:!0});e.exec(function(t){this.tabQueryInfo=t,this.scrollByIndex()}.bind(this))},scrollByIndex(){let t=this.tabQueryInfo[this.currentIndex];if(!t)return;let a=t.width,l=t.left-this.parentLeft-(this.componentWidth-a)/2;this.scrollLeft=l<0?0:l;let i=t.left+t.width/2-this.parentLeft;this.scrollBarLeft=i-e(this.barWidth)/2,1==this.barFirstTimeMove&&setTimeout((()=>{this.barFirstTimeMove=!1}),100)}},mounted(){this.init()}},[["render",function(t,e,g,x,_,v){const S=a(l("u-badge"),I),w=b,k=y;return i(),s(w,{class:"u-tabs",style:h({background:g.bgColor})},{default:r((()=>[u(" $u.getRect()对组件根节点无效,因为写了.in(this),故这里获取内层接点尺寸 "),n(w,{id:_.id},{default:r((()=>[n(k,{"scroll-x":"",class:"u-scroll-view","scroll-left":_.scrollLeft,"scroll-with-animation":""},{default:r((()=>[n(w,{class:o(["u-scroll-box",{"u-tabs-scorll-flex":!g.isScroll}])},{default:r((()=>[(i(!0),d(m,null,c(g.list,((t,e)=>(i(),s(w,{class:"u-tab-item u-line-1",id:"u-tab-item-"+e,key:e,onClick:t=>v.clickTab(e),style:h([v.tabItemStyle(e)])},{default:r((()=>[n(S