Commit fee8de57 authored by youjie's avatar youjie

no message

parent bc552add
...@@ -38,11 +38,11 @@ ...@@ -38,11 +38,11 @@
</style> </style>
<template> <template>
<view> <view>
<scroll-view class="scheduleTsBox" :scroll-x="true" <!-- :scroll-left="scrollLeft" -->
:scrollLeft="scrollLeft"> <scroll-view class="scheduleTsBox" :scroll-x="true">
<view class="scheduleT-text row-aic-n"> <view class="scheduleT-text row-aic-n">
<template v-for="(item,index) in list"> <template v-for="(item,index) in list">
<view class="scheduleText" :id="item.val" <view class="scheduleText" :id="`refs_${index+1}`"
:class="[params.type==item.id?'active':'']" :class="[params.type==item.id?'active':'']"
:key="index" :key="index"
@click="getType(item)"> @click="getType(item)">
...@@ -60,24 +60,52 @@ ...@@ -60,24 +60,52 @@
data(){ data(){
return { return {
list: [], list: [],
scrollLeft: '' scrollLeft: 0
} }
}, },
watch:{ watch:{
titles: { titles: {
handler(newVal, oldVal) { handler(newVal, oldVal) {
this.list = JSON.parse(JSON.stringify(newVal)) this.list = JSON.parse(JSON.stringify(newVal))
// 使用 $nextTick 等待 DOM 渲染完成
this.$nextTick(() => {
this.list.forEach((x, index) => {
// 查询当前元素的位置
uni.createSelectorQuery()
.in(this) // 限定在当前组件内查询(关键!)
.select(`#refs_${index + 1}`) // 匹配元素的 id
.fields({
position: true, // 获取位置信息(left/top)
size: true // 获取尺寸(width/height)
})
.exec((res) => {
if (res[0]) {
const { left, top, width, height } = res[0];
// console.log(`元素 ${index} 的横向位置(left):`, left); // 单位:px
// console.log(`元素 ${index} 的宽度:`, width);
x.left = width*(index)
} else {
console.log(`未找到元素 refs_${index + 1}`);
}
});
});
});
}, },
deep: true, deep: true,
immediate: true immediate: true
}, },
params: { params: {
handler(newVal, oldVal) { handler(newVal, oldVal) {
this.$nextTick(() => {
let findIndex = this.list.findIndex(x => x.id == newVal.type)
if(findIndex != -1) {
this.scrollLeft = this.list[findIndex].left
}
})
}, },
deep: true, deep: true,
immediate: true immediate: true
} },
}, },
components: { components: {
......
...@@ -116,26 +116,11 @@ ...@@ -116,26 +116,11 @@
</view> </view>
</view> </view>
<scheduleHeader :titles="titles" :params="params" @change="getType"></scheduleHeader> <scheduleHeader :titles="titles" :params="params" @change="getType"></scheduleHeader>
<!--
<scroll-view class="scheduleTsBox" :scroll-x="true"
:scroll-left="scrollLeft"
@scroll="scrollHandler">
<view class="scheduleT-text row-aic-n">
<view class="scheduleText"
:class="[params.type==item.id?'active':'']"
v-for="(item,index) in titles"
:key="index"
@click="getType(item)">
<text>{{ item.name }}</text>
<view></view>
</view>
</view>
</scroll-view>-->
</view> </view>
<view class="scheduleTitle fixed" <view class="scheduleTitle fixed"
:style="{ opacity: boxOption + '%' ,'display':boxOption<=0?'none':'show'}"> :style="{ opacity: boxOption + '%' ,'display':boxOption<=0?'none':'show'}">
<headers textAlign="left" :title="pageTitle" color="#fff"></headers> <headers textAlign="left" :title="pageTitle" color="#fff"></headers>
<scheduleHeader :titles="titles" :params="params" @change="getType"></scheduleHeader> <scheduleHeader v-if="boxOption>0" :titles="titles" :params="params" @change="getType"></scheduleHeader>
</view> </view>
</view> </view>
<infor1 v-if="params.type==1" :data="inforData1"></infor1> <infor1 v-if="params.type==1" :data="inforData1"></infor1>
...@@ -255,7 +240,7 @@ export default { ...@@ -255,7 +240,7 @@ export default {
}, },
datas: {}, datas: {},
params:{ params:{
type: 1 type: 1,
}, },
scrollLeft: 0, scrollLeft: 0,
currencyList: [], currencyList: [],
...@@ -309,7 +294,9 @@ export default { ...@@ -309,7 +294,9 @@ export default {
this.optionObj = this.optionList[findIndex] this.optionObj = this.optionList[findIndex]
}, },
getType(item){ getType(item){
this.params.type = item.id this.params = {
type: item.id,
}
}, },
init() { init() {
uni.showLoading() uni.showLoading()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment