eeeeeeuuuu-ui
Version:
uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水
12 lines (11 loc) • 4.66 kB
JavaScript
require('../../../app.js');
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["uview-ui/components/u-subsection/u-subsection"],{2234:function(t,e,i){},4156:function(t,e,i){"use strict";(function(t){e["a"]={name:"u-subsection",props:{list:{type:Array,default(){return[]}},current:{type:[Number,String],default:0},activeColor:{type:String,default:"#303133"},inactiveColor:{type:String,default:"#606266"},mode:{type:String,default:"button"},fontSize:{type:[Number,String],default:28},animation:{type:Boolean,default:!0},height:{type:[Number,String],default:70},bold:{type:Boolean,default:!0},bgColor:{type:String,default:"#eeeeef"},buttonColor:{type:String,default:"#ffffff"},vibrateShort:{type:Boolean,default:!1}},data(){return{listInfo:[],itemBgStyle:{width:0,left:0,backgroundColor:"#ffffff",height:"100%",transition:""},currentIndex:this.current,buttonPadding:3,borderRadius:5,firstTimeVibrateShort:!0}},watch:{current:{immediate:!0,handler(t){this.currentIndex=t,this.changeSectionStatus(t)}}},created(){this.listInfo=this.list.map((t,e)=>{if("object"!=typeof t){let e={width:0,name:t};return e}return t.width=0,t})},computed:{noBorderRight(){return t=>{if("subsection"!=this.mode)return;let e="";return t<this.list.length-1&&(e+=" u-none-border-right"),0==t&&(e+=" u-item-first"),t==this.list.length-1&&(e+=" u-item-last"),e}},textStyle(){return t=>{let e={};return"subsection"==this.mode?t==this.currentIndex?e.color="#ffffff":e.color=this.activeColor:t==this.currentIndex?e.color=this.activeColor:e.color=this.inactiveColor,t==this.currentIndex&&this.bold&&(e.fontWeight="bold"),e.fontSize=this.fontSize+"rpx",e}},itemStyle(){return t=>{let e={};return"subsection"==this.mode&&(e.borderColor=this.activeColor,e.borderWidth="1px",e.borderStyle="solid"),e}},subsectionStyle(){let e={};return e.height=t.upx2px(this.height)+"px","button"==this.mode&&(e.backgroundColor=this.bgColor,e.padding=this.buttonPadding+"px",e.borderRadius=this.borderRadius+"px"),e},itemBarStyle(){let e={};return e.backgroundColor=this.activeColor,e.zIndex=1,"button"==this.mode&&(e.backgroundColor=this.buttonColor,e.borderRadius=this.borderRadius+"px",e.bottom=this.buttonPadding+"px",e.height=t.upx2px(this.height)-2*this.buttonPadding+"px",e.zIndex=0),Object.assign(this.itemBgStyle,e)}},mounted(){setTimeout(()=>{this.getTabsInfo()},10)},methods:{changeSectionStatus(e){"subsection"==this.mode&&(e==this.list.length-1&&(this.itemBgStyle.borderRadius=`0 ${this.buttonPadding}px ${this.buttonPadding}px 0`),0==e&&(this.itemBgStyle.borderRadius=`${this.buttonPadding}px 0 0 ${this.buttonPadding}px`),e>0&&e<this.list.length-1&&(this.itemBgStyle.borderRadius="0")),setTimeout(()=>{this.itemBgLeft()},10),this.vibrateShort&&!this.firstTimeVibrateShort&&t.vibrateShort(),this.firstTimeVibrateShort=!1},click(t){t!=this.currentIndex&&(this.currentIndex=t,this.changeSectionStatus(t),this.$emit("change",Number(t)))},getTabsInfo(){let e=t.createSelectorQuery().in(this);for(let t=0;t<this.list.length;t++)e.select(".u-item-"+t).boundingClientRect();e.exec(t=>{t.length||setTimeout(()=>{this.getTabsInfo()},10),t.map((t,e)=>{this.listInfo[e].width=t.width}),("subsection"==this.mode||"button"==this.mode)&&(this.itemBgStyle.width=this.listInfo[0].width+"px"),this.itemBgLeft()})},itemBgLeft(){this.animation?this.itemBgStyle.transition="all 0.35s":this.itemBgStyle.transition="all 0s";let t=0;this.listInfo.map((e,i)=>{i<this.currentIndex&&(t+=e.width)}),"subsection"==this.mode?this.itemBgStyle.left=t+"px":"button"==this.mode&&(this.itemBgStyle.left=t+this.buttonPadding+"px")}}}}).call(this,i("543d")["default"])},9807:function(t,e,i){"use strict";var o=i("2234"),s=i.n(o);s.a},"9dc6":function(t,e,i){"use strict";var o;i.r(e);var s,n=function(){var t=this,e=t.$createElement,i=(t._self._c,t.__get_style([t.subsectionStyle])),o=t.__map(t.listInfo,(function(e,i){var o=t.__get_orig(e),s=t.__get_style([t.itemStyle(i)]),n=t.noBorderRight(i),r=t.__get_style([t.textStyle(i)]);return{$orig:o,s1:s,m0:n,s2:r}})),s=t.__get_style([t.itemBarStyle]);t.$mp.data=Object.assign({},{$root:{s0:i,l0:o,s3:s}})},r=[],l=i("4156"),h=l["a"],u=(i("9807"),i("f0c5")),a=Object(u["a"])(h,n,r,!1,null,"5601dbfc",null,!1,o,s);e["default"]=a.exports}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'uview-ui/components/u-subsection/u-subsection-create-component',
{
'uview-ui/components/u-subsection/u-subsection-create-component':(function(module, exports, __webpack_require__){
__webpack_require__('543d')['createComponent'](__webpack_require__("9dc6"))
})
},
[['uview-ui/components/u-subsection/u-subsection-create-component']]
]);