crm_second_opening_mini/uview-ui/components/u-tabs/u-tabs.js

11 lines
4.8 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["uview-ui/components/u-tabs/u-tabs"],{5924:function(t,e,n){"use strict";n.r(e);var r=n("7e66"),i=n("df31");for(var a in i)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(a);n("ac21");var u=n("f0c5"),o=Object(u["a"])(i["default"],r["b"],r["c"],!1,null,"1bce6cd7",null,!1,r["a"],void 0);e["default"]=o.exports},"6b8e":function(t,e,n){"use strict";(function(t){var r=n("4ea4");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=r(n("2eee")),a=r(n("c973")),u={name:"u-tabs",props:{isScroll:{type:Boolean,default:!0},list:{type:Array,default:function(){return[]}},current:{type:[Number,String],default:0},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:function(){return[5,20]}},bold:{type:Boolean,default:!0},activeItemStyle:{type:Object,default:function(){return{}}},showBar:{type:Boolean,default:!0},barStyle:{type:Object,default:function(){return{}}},itemWidth:{type:[Number,String],default:"auto"}},data:function(){return{scrollLeft:0,tabQueryInfo:[],componentWidth:0,scrollBarLeft:0,parentLeft:0,id:this.$u.guid(),currentIndex:this.current,barFirstTimeMove:!0}},watch:{list:function(t,e){var n=this;t.length!==e.length&&(this.currentIndex=0),this.$nextTick((function(){n.init()}))},current:{immediate:!0,handler:function(t,e){var n=this;this.$nextTick((function(){n.currentIndex=t,n.scrollByIndex()}))}}},computed:{tabBarStyle:function(){var t={width:this.barWidth+"rpx",transform:"translate(".concat(this.scrollBarLeft,"px, -100%)"),"transition-duration":"".concat(this.barFirstTimeMove?0:this.duration,"s"),"background-color":this.activeColor,height:this.barHeight+"rpx",opacity:this.barFirstTimeMove?0:1,"border-radius":"".concat(this.barHeight/2,"px")};return Object.assign(t,this.barStyle),t},tabItemStyle:function(){var t=this;return function(e){var n={height:t.height+"rpx","line-height":t.height+"rpx","font-size":t.fontSize+"rpx","transition-duration":"".concat(t.duration,"s"),padding:t.isScroll?"0 ".concat(t.gutter,"rpx"):"",flex:t.isScroll?"auto":"1",width:t.$u.addUnit(t.itemWidth)};return e==t.currentIndex&&t.bold&&(n.fontWeight="bold"),e==t.currentIndex?(n.color=t.activeColor,n=Object.assign(n,t.activeItemStyle)):n.color=t.inactiveColor,n}}},methods:{init:function(){var t=this;return(0,a.default)(i.default.mark((function e(){var n;return i.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,t.$uGetRect("#"+t.id);case 2:n=e.sent,t.parentLeft=n.left,t.componentWidth=n.width,t.getTabRect();case 6:case"end":return e.stop()}}),e)})))()},clickTab:function(t){t!=this.currentIndex&&this.$emit("change",t)},getTabRect:function(){for(var e=t.createSelectorQuery().in(this),n=0;n<this.list.length;n++)e.select("#u-tab-item-".concat(n)).fields({size:!0,rect:!0});e.exec(function(t){this.tabQueryInfo=t,this.scrollByIndex()}.bind(this))},scrollByIndex:function(){var e=this,n=this.tabQueryInfo[this.currentIndex];if(n){var r=n.width,i=n.left-this.parentLeft,a=i-(this.componentWidth-r)/2;this.scrollLeft=a<0?0:a;var u=n.left+n.width/2-this.parentLeft;this.scrollBarLeft=u-t.upx2px(this.barWidth)/2,1==this.barFirstTimeMove&&setTimeout((function(){e.barFirstTimeMove=!1}),100)}}},mounted:function(){this.init()}};e.default=u}).call(this,n("543d")["default"])},"7e66":function(t,e,n){"use strict";n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return a})),n.d(e,"a",(function(){return r}));var r={uBadge:function(){return n.e("uview-ui/components/u-badge/u-badge").then(n.bind(null,"988f"))}},i=function(){var t=this,e=t.$createElement,n=(t._self._c,t.__map(t.list,(function(e,n){var r=t.__get_orig(e),i=t.__get_style([t.tabItemStyle(n)]);return{$orig:r,s0:i}}))),r=t.showBar?t.__get_style([t.tabBarStyle]):null;t.$mp.data=Object.assign({},{$root:{l0:n,s1:r}})},a=[]},ac21:function(t,e,n){"use strict";var r=n("dc928"),i=n.n(r);i.a},dc928:function(t,e,n){},df31:function(t,e,n){"use strict";n.r(e);var r=n("6b8e"),i=n.n(r);for(var a in r)["default"].indexOf(a)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(a);e["default"]=i.a}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'uview-ui/components/u-tabs/u-tabs-create-component',
{
'uview-ui/components/u-tabs/u-tabs-create-component':(function(module, exports, __webpack_require__){
__webpack_require__('543d')['createComponent'](__webpack_require__("5924"))
})
},
[['uview-ui/components/u-tabs/u-tabs-create-component']]
]);