fix ;bug
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<view class="sparring-center max_page">
|
||||
<view class="top-bg"></view>
|
||||
<view class="bot-bg"></view>
|
||||
<view class="sparring-center-body">
|
||||
<view class="sparring-center-body" v-if="!reSeting">
|
||||
<view class="body-title">
|
||||
<!-- @click="test.testApi" -->
|
||||
<uv-icon class="arrow-icon" name="arrow-left" @click="common.switchTab('/pages/index/index')" />
|
||||
@@ -14,11 +14,11 @@
|
||||
</uv-input>
|
||||
</view>
|
||||
<view class="tabs-view">
|
||||
<uv-tabs :list="tabList" @click="changeTab" :scrollable="true" active-style="font-weight:bold; color:#000;"
|
||||
<uv-tabs :list="tabList" @click="changeTab" :current="currentTab" :scrollable="true"
|
||||
class="font_pf my_tabs" :inactive-style="{ color: '#333333', fontSize: '30rpx', fontWeight: '500' }"
|
||||
:activeStyle="{ color: '#333333', fontSize: '30rpx', fontWeight: '600' }"></uv-tabs>
|
||||
<uv-tabs :list="tabSecList" @click="changeTabSec" :scrollable="true"
|
||||
active-style="font-weight:bold; color:#000;" class="font_pf my_tabs2"
|
||||
<uv-tabs :list="tabSecList" @click="changeTabSec" :current="currentTabSec" :scrollable="true"
|
||||
class="font_pf my_tabs2"
|
||||
:inactive-style="{ color: '#333333', fontSize: '24rpx', fontWeight: '500' }"
|
||||
:activeStyle="{ color: '#0066FF', fontSize: '24rpx', fontWeight: '500' }" :lineColor="`#06f`"></uv-tabs>
|
||||
<!-- :lineColor="`url(${LineBg}) 2% 2%`" -->
|
||||
@@ -66,7 +66,7 @@
|
||||
</uv-scroll-list>
|
||||
<view class="sparring-list">
|
||||
<view class="sparring-list-body">
|
||||
<scroll-view :class="['right-sparring-list', getActiveItemClass()]" :scroll-y="true"
|
||||
<scroll-view :class="['right-sparring-list']" :scroll-y="true"
|
||||
@scrolltolower="getMoreList()">
|
||||
<!-- <view class="all-item"> -->
|
||||
<view class="left-items">
|
||||
@@ -112,7 +112,8 @@
|
||||
onUnmounted
|
||||
} from 'vue'
|
||||
import {
|
||||
onShow
|
||||
onShow,
|
||||
onHide
|
||||
} from '@dcloudio/uni-app'
|
||||
import {
|
||||
useSocketStore
|
||||
@@ -136,6 +137,8 @@
|
||||
borderRadius: '23rpx'
|
||||
}
|
||||
const catelogList = ref([])
|
||||
const currentTab = ref(0)
|
||||
const currentTabSec = ref(0)
|
||||
const tabList = computed(() => {
|
||||
return [{
|
||||
name: '全 部',
|
||||
@@ -226,21 +229,6 @@
|
||||
// showFilterList.value = false
|
||||
}
|
||||
const activeLeftIndex = ref(-1)
|
||||
const getActiveItemClass = () => {
|
||||
let _class = ''
|
||||
if ('生产线' === activeTab.value) {
|
||||
_class = activeLeftIndex.value === 0 ? 'no-radius' : ''
|
||||
} else if ('全部' === activeTab.value) {
|
||||
_class = activeLeftIndex.value === 0 ? 'no-radius' : ''
|
||||
}
|
||||
return _class
|
||||
}
|
||||
// 点击生产线分类
|
||||
const changePrdLine = (item, index) => {
|
||||
activePrdlineType.value = item.value === activePrdlineType.value ? '' : item.value
|
||||
activeLeftIndex.value = index
|
||||
getMoreList(1)
|
||||
}
|
||||
// 点击课程分类
|
||||
const tagsList = computed(() => {
|
||||
let _arr = []
|
||||
@@ -367,7 +355,12 @@
|
||||
})
|
||||
}
|
||||
}
|
||||
const reSeting = ref(false)
|
||||
onMounted(() => {
|
||||
reSeting.value = true
|
||||
setTimeout(()=>{reSeting.value = false})
|
||||
currentTab.value = 0
|
||||
currentTabSec.value = 0
|
||||
queryTraPartnerCatelogList().then(res => {
|
||||
catelogList.value = res.body || []
|
||||
})
|
||||
@@ -386,20 +379,34 @@
|
||||
onUnmounted(() => {
|
||||
uni.$off('refresh_sparring_list')
|
||||
})
|
||||
onActivated(() => {
|
||||
// 重新获取标签信息
|
||||
getTraTagListApi().then(res => {
|
||||
tagsTree.value = res.body || []
|
||||
})
|
||||
changeTab({
|
||||
name: activeTab.value || '全部'
|
||||
})
|
||||
})
|
||||
// onActivated(() => {
|
||||
// currentTab.value = 2
|
||||
// currentTabSec.value = 0
|
||||
// // 重新获取标签信息
|
||||
// getTraTagListApi().then(res => {
|
||||
// tagsTree.value = res.body || []
|
||||
// })
|
||||
// changeTab({
|
||||
// name: activeTab.value || '全部'
|
||||
// })
|
||||
// })
|
||||
onShow(() => {
|
||||
reSeting.value = true
|
||||
setTimeout(()=>{reSeting.value = false})
|
||||
currentTab.value = 0
|
||||
currentTabSec.value = 0
|
||||
changeTab({
|
||||
name: activeTab.value || '全部'
|
||||
})
|
||||
socketStore.closeSocket()
|
||||
uni.$on('refresh_sparring_list', () => {
|
||||
changeTab({
|
||||
name: activeTab.value || '全部'
|
||||
})
|
||||
})
|
||||
})
|
||||
onHide(() => {
|
||||
uni.$off('refresh_sparring_list')
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -251,6 +251,8 @@
|
||||
})
|
||||
},
|
||||
setScrollLeft() {
|
||||
setTimeout(()=> {
|
||||
|
||||
// 当前活动tab的布局信息,有tab菜单的width和left(为元素左边界到父元素左边界的距离)等信息
|
||||
const tabRect = this.list[this.innerCurrent]
|
||||
// 累加得到当前item到左边的距离
|
||||
@@ -261,12 +263,14 @@
|
||||
}, 0)
|
||||
// 此处为屏幕宽度
|
||||
const windowWidth = this.$uv.sys().windowWidth
|
||||
let _rect = tabRect?.rect?.width||0
|
||||
// 将活动的tabs-item移动到屏幕正中间,实际上是对scroll-view的移动
|
||||
let scrollLeft = offsetLeft - (this.tabsRect.width - tabRect.rect.width) / 2 - (windowWidth - this.tabsRect
|
||||
let scrollLeft = offsetLeft - (this.tabsRect.width - _rect) / 2 - (windowWidth - this.tabsRect
|
||||
.right) / 2 + this.tabsRect.left / 2
|
||||
// 这里做一个限制,限制scrollLeft的最大值为整个scroll-view宽度减去tabs组件的宽度
|
||||
scrollLeft = Math.min(scrollLeft, this.scrollViewWidth - this.tabsRect.width)
|
||||
this.scrollLeft = Math.max(0, scrollLeft)
|
||||
},200)
|
||||
},
|
||||
// 获取所有标签的尺寸
|
||||
resize() {
|
||||
|
||||
Reference in New Issue
Block a user