You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
5.5 KiB
1 lines
5.5 KiB
import{o as t,c as e,w as i,f as r,t as s,k as a,n as l,e as o,i as n,y as u,a as d,b as h,F as f,d as c,j as p}from"./index-4ddb689d.js";import{_ as b}from"./_plugin-vue_export-helper.1b428a4d.js";import{r as y}from"./uni-app.es.24af5d4f.js";const m=b({name:"u-badge",props:{type:{type:String,default:"error"},size:{type:String,default:"default"},isDot:{type:Boolean,default:!1},count:{type:[Number,String]},overflowCount:{type:Number,default:99},showZero:{type:Boolean,default:!1},offset:{type:Array,default:()=>[20,20]},absolute:{type:Boolean,default:!0},fontSize:{type:[String,Number],default:"24"},color:{type:String,default:"#ffffff"},bgColor:{type:String,default:""},isCenter:{type:Boolean,default:!1}},computed:{boxStyle(){let t={};return this.isCenter?(t.top=0,t.right=0,t.transform="translateY(-50%) translateX(50%)"):(t.top=this.offset[0]+"rpx",t.right=this.offset[1]+"rpx",t.transform="translateY(0) translateX(0)"),"mini"==this.size&&(t.transform=t.transform+" scale(0.8)"),t},showText(){return this.isDot?"":this.count>this.overflowCount?`${this.overflowCount}+`:this.count},show(){return 0!=this.count||0!=this.showZero}}},[["render",function(u,d,h,f,c,p){const b=n;return p.show?(t(),e(b,{key:0,class:a(["u-badge",[h.isDot?"u-badge-dot":"","mini"==h.size?"u-badge-mini":"",h.type?"u-badge--bg--"+h.type:""]]),style:l([{top:h.offset[0]+"rpx",right:h.offset[1]+"rpx",fontSize:h.fontSize+"rpx",position:h.absolute?"absolute":"static",color:h.color,backgroundColor:h.bgColor},p.boxStyle])},{default:i((()=>[r(s(p.showText),1)])),_:1},8,["class","style"])):o("",!0)}],["__scopeId","data-v-55f0cd70"]]);const g=b({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(t,e){t.length!==e.length&&(this.currentIndex=0),this.$nextTick((()=>{this.init()}))},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 t=uni.createSelectorQuery().in(this);for(let e=0;e<this.list.length;e++)t.select(`#u-tab-item-${e}`).fields({size:!0,rect:!0});t.exec(function(t){this.tabQueryInfo=t,this.scrollByIndex()}.bind(this))},scrollByIndex(){let t=this.tabQueryInfo[this.currentIndex];if(!t)return;let e=t.width,i=t.left-this.parentLeft-(this.componentWidth-e)/2;this.scrollLeft=i<0?0:i;let r=t.left+t.width/2-this.parentLeft;this.scrollBarLeft=r-uni.upx2px(this.barWidth)/2,1==this.barFirstTimeMove&&setTimeout((()=>{this.barFirstTimeMove=!1}),100)}},mounted(){this.init()}},[["render",function(b,g,x,S,v,w){const I=y(u("u-badge"),m),C=n,B=p;return t(),e(C,{class:"u-tabs",style:l({background:x.bgColor})},{default:i((()=>[d(C,{id:v.id},{default:i((()=>[d(B,{"scroll-x":"",class:"u-scroll-view","scroll-left":v.scrollLeft,"scroll-with-animation":""},{default:i((()=>[d(C,{class:a(["u-scroll-box",{"u-tabs-scroll-flex":!x.isScroll}]),id:v.id},{default:i((()=>[(t(!0),h(f,null,c(x.list,((a,o)=>(t(),e(C,{class:"u-tab-item u-line-1",id:"u-tab-item-"+o,key:o,onClick:t=>w.clickTab(o),style:l([w.tabItemStyle(o)])},{default:i((()=>[d(I,{count:a[x.count]||a.count||0,offset:x.offset,size:"mini"},null,8,["count","offset"]),r(" "+s(a[x.name]||a.name),1)])),_:2},1032,["id","onClick","style"])))),128)),x.showBar?(t(),e(C,{key:0,class:"u-tab-bar",style:l([w.tabBarStyle])},null,8,["style"])):o("",!0)])),_:1},8,["id","class"])])),_:1},8,["scroll-left"])])),_:1},8,["id"])])),_:1},8,["style"])}],["__scopeId","data-v-1621c930"]]);export{g as _};
|
|
|