|
|
@ -1,4 +1,4 @@ |
|
|
|
<!-- z-tabs v0.2.7 by-ZXLee --> |
|
|
|
<!-- z-tabs v0.3.0 by-ZXLee --> |
|
|
|
<!-- github地址:https://github.com/SmileZXLee/uni-z-tabs --> |
|
|
|
<!-- github地址:https://github.com/SmileZXLee/uni-z-tabs --> |
|
|
|
<!-- dcloud地址:https://ext.dcloud.net.cn/plugin?name=z-tabs --> |
|
|
|
<!-- dcloud地址:https://ext.dcloud.net.cn/plugin?name=z-tabs --> |
|
|
|
<!-- 反馈QQ群:371624008 --> |
|
|
|
<!-- 反馈QQ群:371624008 --> |
|
|
@ -49,7 +49,10 @@ |
|
|
|
// #endif |
|
|
|
// #endif |
|
|
|
import zTabsConfig from './config/index' |
|
|
|
import zTabsConfig from './config/index' |
|
|
|
|
|
|
|
|
|
|
|
//获取默认配置信息 |
|
|
|
// #ifdef APP-HARMONY |
|
|
|
|
|
|
|
let screenWidth = 0; |
|
|
|
|
|
|
|
// #endif |
|
|
|
|
|
|
|
// 获取默认配置信息 |
|
|
|
function _gc(key, defaultValue) { |
|
|
|
function _gc(key, defaultValue) { |
|
|
|
let config = null; |
|
|
|
let config = null; |
|
|
|
if (zTabsConfig && Object.keys(zTabsConfig).length) { |
|
|
|
if (zTabsConfig && Object.keys(zTabsConfig).length) { |
|
|
@ -60,10 +63,22 @@ |
|
|
|
const value = config[_toKebab(key)]; |
|
|
|
const value = config[_toKebab(key)]; |
|
|
|
return value === undefined ? defaultValue : value; |
|
|
|
return value === undefined ? defaultValue : value; |
|
|
|
} |
|
|
|
} |
|
|
|
//驼峰转短横线 |
|
|
|
// 驼峰转短横线 |
|
|
|
function _toKebab(value) { |
|
|
|
function _toKebab(value) { |
|
|
|
return value.replace(/([A-Z])/g, "-$1").toLowerCase(); |
|
|
|
return value.replace(/([A-Z])/g, "-$1").toLowerCase(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// rpx => px,兼容鸿蒙 |
|
|
|
|
|
|
|
function rpx2px(rpx) { |
|
|
|
|
|
|
|
// #ifdef APP-HARMONY |
|
|
|
|
|
|
|
if (!screenWidth) { |
|
|
|
|
|
|
|
screenWidth = uni.getSystemInfoSync().screenWidth; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (screenWidth * Number.parseFloat(rpx)) / 750; |
|
|
|
|
|
|
|
// #endif |
|
|
|
|
|
|
|
// #ifndef APP-HARMONY |
|
|
|
|
|
|
|
return uni.upx2px(rpx); |
|
|
|
|
|
|
|
// #endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* z-tabs 标签 |
|
|
|
* z-tabs 标签 |
|
|
@ -109,9 +124,9 @@ |
|
|
|
barCalcedWidth: 0, |
|
|
|
barCalcedWidth: 0, |
|
|
|
pxBarWidth: 0, |
|
|
|
pxBarWidth: 0, |
|
|
|
scrollLeft: 0, |
|
|
|
scrollLeft: 0, |
|
|
|
tabsSuperWidth: uni.upx2px(750), |
|
|
|
tabsSuperWidth: rpx2px(750), |
|
|
|
tabsWidth: uni.upx2px(750), |
|
|
|
tabsWidth: rpx2px(750), |
|
|
|
tabsHeight: uni.upx2px(80), |
|
|
|
tabsHeight: rpx2px(80), |
|
|
|
tabsLeft: 0, |
|
|
|
tabsLeft: 0, |
|
|
|
tabsContainerWidth: 0, |
|
|
|
tabsContainerWidth: 0, |
|
|
|
itemNodeInfos: [], |
|
|
|
itemNodeInfos: [], |
|
|
@ -281,8 +296,7 @@ |
|
|
|
handler(newVal) { |
|
|
|
handler(newVal) { |
|
|
|
this._handleListChange(newVal); |
|
|
|
this._handleListChange(newVal); |
|
|
|
}, |
|
|
|
}, |
|
|
|
immediate: false, |
|
|
|
immediate: false |
|
|
|
deep: true |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
bottomDotX(newVal) { |
|
|
|
bottomDotX(newVal) { |
|
|
|
if(newVal >= 0){ |
|
|
|
if(newVal >= 0){ |
|
|
@ -420,7 +434,6 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
//更新z-tabs内部布局 |
|
|
|
//更新z-tabs内部布局 |
|
|
|
updateSubviewLayout(tryCount = 0) { |
|
|
|
updateSubviewLayout(tryCount = 0) { |
|
|
|
|
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
this.$nextTick(() => { |
|
|
|
let delayTime = 10; |
|
|
|
let delayTime = 10; |
|
|
|
// #ifdef APP-NVUE || MP-BAIDU |
|
|
|
// #ifdef APP-NVUE || MP-BAIDU |
|
|
@ -429,7 +442,6 @@ |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
this._getNodeClientRect('.z-tabs-scroll-view-conatiner').then(res=>{ |
|
|
|
this._getNodeClientRect('.z-tabs-scroll-view-conatiner').then(res=>{ |
|
|
|
if (res){ |
|
|
|
if (res){ |
|
|
|
|
|
|
|
|
|
|
|
if (!res[0].width && tryCount < 10) { |
|
|
|
if (!res[0].width && tryCount < 10) { |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
tryCount ++; |
|
|
|
tryCount ++; |
|
|
@ -504,7 +516,7 @@ |
|
|
|
if (nodeRes) { |
|
|
|
if (nodeRes) { |
|
|
|
node = nodeRes[0]; |
|
|
|
node = nodeRes[0]; |
|
|
|
offset = this.currentScrollLeft; |
|
|
|
offset = this.currentScrollLeft; |
|
|
|
this.tabsHeight = Math.max(node.height + uni.upx2px(28), this.tabsHeight); |
|
|
|
this.tabsHeight = Math.max(node.height + rpx2px(28), this.tabsHeight); |
|
|
|
tabsContainerWidth = 0; |
|
|
|
tabsContainerWidth = 0; |
|
|
|
for(let i = 0;i < this.itemNodeInfos.length;i++){ |
|
|
|
for(let i = 0;i < this.itemNodeInfos.length;i++){ |
|
|
|
let oldNode = this.itemNodeInfos[i]; |
|
|
|
let oldNode = this.itemNodeInfos[i]; |
|
|
@ -611,7 +623,7 @@ |
|
|
|
_convertTextToPx(text) { |
|
|
|
_convertTextToPx(text) { |
|
|
|
const dataType = Object.prototype.toString.call(text); |
|
|
|
const dataType = Object.prototype.toString.call(text); |
|
|
|
if (dataType === '[object Number]') { |
|
|
|
if (dataType === '[object Number]') { |
|
|
|
return uni.upx2px(text); |
|
|
|
return rpx2px(text); |
|
|
|
} |
|
|
|
} |
|
|
|
let isRpx = false; |
|
|
|
let isRpx = false; |
|
|
|
if (text.indexOf('rpx') !== -1 || text.indexOf('upx') !== -1) { |
|
|
|
if (text.indexOf('rpx') !== -1 || text.indexOf('upx') !== -1) { |
|
|
@ -620,10 +632,10 @@ |
|
|
|
} else if (text.indexOf('px') !== -1) { |
|
|
|
} else if (text.indexOf('px') !== -1) { |
|
|
|
text = text.replace('px', ''); |
|
|
|
text = text.replace('px', ''); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
text = uni.upx2px(text); |
|
|
|
text = rpx2px(text); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!isNaN(text)) { |
|
|
|
if (!isNaN(text)) { |
|
|
|
if (isRpx) return Number(uni.upx2px(text)); |
|
|
|
if (isRpx) return Number(rpx2px(text)); |
|
|
|
return Number(text); |
|
|
|
return Number(text); |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|