u-tabs.js 6.2 KB

1234567891011
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["uni_modules/uview-ui/components/u-tabs/u-tabs"],{325:function(t,e,n){"use strict";n.r(e);var i=n(326),r=n(328);for(var c in r)["default"].indexOf(c)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(c);n(331);var u,s=n(36),o=Object(s["default"])(r["default"],i["render"],i["staticRenderFns"],!1,null,"48634e29",null,!1,i["components"],u);o.options.__file="uni_modules/uview-ui/components/u-tabs/u-tabs.vue",e["default"]=o.exports},326:function(t,e,n){"use strict";n.r(e);var i=n(327);n.d(e,"render",(function(){return i["render"]})),n.d(e,"staticRenderFns",(function(){return i["staticRenderFns"]})),n.d(e,"recyclableRender",(function(){return i["recyclableRender"]})),n.d(e,"components",(function(){return i["components"]}))},327:function(t,e,n){"use strict";var i;n.r(e),n.d(e,"render",(function(){return r})),n.d(e,"staticRenderFns",(function(){return u})),n.d(e,"recyclableRender",(function(){return c})),n.d(e,"components",(function(){return i}));try{i={uBadge:function(){return Promise.all([n.e("common/vendor"),n.e("uni_modules/uview-ui/components/u-badge/u-badge")]).then(n.bind(null,505))}}}catch(s){if(-1===s.message.indexOf("Cannot find module")||-1===s.message.indexOf(".vue"))throw s;console.error(s.message),console.error("1. 排查组件名称拼写是否正确"),console.error("2. 排查组件是否符合 easycom 规范,文档:https://uniapp.dcloud.net.cn/collocation/pages?id=easycom"),console.error("3. 若组件不符合 easycom 规范,需手动引入,并在 components 中注册该组件")}var r=function(){var t=this,e=t.$createElement,n=(t._self._c,t.__get_style([t.$u.addStyle(t.itemStyle),{flex:t.scrollable?"":1}])),i=t.__map(t.list,(function(e,n){var i=t.__get_orig(e),r=t.__get_style([t.textStyle(n)]);return{$orig:i,s1:r}})),r=t.$u.addUnit(t.lineWidth),c=t.$u.addUnit(t.lineHeight);t.$mp.data=Object.assign({},{$root:{s0:n,l0:i,g0:r,g1:c}})},c=!1,u=[];r._withStripped=!0},328:function(t,e,n){"use strict";n.r(e);var i=n(329),r=n.n(i);for(var c in i)["default"].indexOf(c)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(c);e["default"]=r.a},329:function(t,e,n){"use strict";(function(t){var i=n(4);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=i(n(30)),c=i(n(5)),u=i(n(11)),s=i(n(32)),o=i(n(330));function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach((function(e){(0,u.default)(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var f={name:"u-tabs",mixins:[t.$u.mpMixin,t.$u.mixin,o.default],data:function(){return{firstTime:!0,scrollLeft:0,scrollViewWidth:0,lineOffsetLeft:0,tabsRect:{left:0},innerCurrent:0,moving:!1}},watch:{current:{immediate:!0,handler:function(t,e){var n=this;t!==this.innerCurrent&&(this.innerCurrent=t,this.$nextTick((function(){n.resize()})))}},list:function(){var t=this;this.$nextTick((function(){t.resize()}))}},computed:{textStyle:function(){var e=this;return function(n){var i={},r=n===e.innerCurrent?t.$u.addStyle(e.activeStyle):t.$u.addStyle(e.inactiveStyle);return e.list[n].disabled&&(i.color="#c8c9cc"),t.$u.deepMerge(r,i)}},propsBadge:function(){return t.$u.props.badge}},mounted:function(){var t=this;return(0,s.default)(r.default.mark((function e(){return r.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:t.init();case 1:case"end":return e.stop()}}),e)})))()},methods:{setLineLeft:function(){var e=this,n=this.list[this.innerCurrent];if(n){var i=this.list.slice(0,this.innerCurrent).reduce((function(t,e){return t+e.rect.width}),0),r=t.$u.getPx(this.lineWidth);this.lineOffsetLeft=i+(n.rect.width-r)/2,this.firstTime&&setTimeout((function(){e.firstTime=!1}),10)}},animation:function(t){},clickHandler:function(t,e){this.$emit("click",l(l({},t),{},{index:e})),t.disabled||(this.innerCurrent=e,this.resize(),this.$emit("change",l(l({},t),{},{index:e})))},init:function(){var e=this;t.$u.sleep().then((function(){e.resize()}))},setScrollLeft:function(){var e=this.list[this.innerCurrent],n=this.list.slice(0,this.innerCurrent).reduce((function(t,e){return t+e.rect.width}),0),i=t.$u.sys().windowWidth,r=n-(this.tabsRect.width-e.rect.width)/2-(i-this.tabsRect.right)/2+this.tabsRect.left/2;r=Math.min(r,this.scrollViewWidth-this.tabsRect.width),this.scrollLeft=Math.max(0,r)},resize:function(){var t=this;0!==this.list.length&&Promise.all([this.getTabsRect(),this.getAllItemRect()]).then((function(e){var n=(0,c.default)(e,2),i=n[0],r=n[1],u=void 0===r?[]:r;t.tabsRect=i,t.scrollViewWidth=0,u.map((function(e,n){t.scrollViewWidth+=e.width,t.list[n].rect=e})),t.setLineLeft(),t.setScrollLeft()}))},getTabsRect:function(){var t=this;return new Promise((function(e){t.queryRect("u-tabs__wrapper__scroll-view").then((function(t){return e(t)}))}))},getAllItemRect:function(){var t=this;return new Promise((function(e){var n=t.list.map((function(e,n){return t.queryRect("u-tabs__wrapper__nav__item-".concat(n),!0)}));Promise.all(n).then((function(t){return e(t)}))}))},queryRect:function(t,e){var n=this;return new Promise((function(e){n.$uGetRect(".".concat(t)).then((function(t){e(t)}))}))}}};e.default=f}).call(this,n(2)["default"])},331:function(t,e,n){"use strict";n.r(e);var i=n(332),r=n.n(i);for(var c in i)["default"].indexOf(c)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(c);e["default"]=r.a},332:function(t,e,n){}}]);
  2. //# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-ui/components/u-tabs/u-tabs.js.map
  3. ;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
  4. 'uni_modules/uview-ui/components/u-tabs/u-tabs-create-component',
  5. {
  6. 'uni_modules/uview-ui/components/u-tabs/u-tabs-create-component':(function(module, exports, __webpack_require__){
  7. __webpack_require__('2')['createComponent'](__webpack_require__(325))
  8. })
  9. },
  10. [['uni_modules/uview-ui/components/u-tabs/u-tabs-create-component']]
  11. ]);