Browse Source

fix: 添加页面返回功能 解决角色滚动bug

wrr
song 4 years ago
parent
commit
87ce0f7e06
  1. 1
      CHANGELOG.md
  2. 24
      src/components/Roles/Roles.vue
  3. 6
      src/components/Title/Title.vue

1
CHANGELOG.md

@ -158,6 +158,7 @@
- | 监听时间基本点 | [033fca0](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/033fca0)
- | 角色显示状态修改 | [7d3b906](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/7d3b906)
- | 角色栏修改 | [19228d6](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/19228d6)
- | 角色滚动问题修复 | [c8ee189](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/c8ee189)
- | 解决时间轴报错 | [da1eece](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/da1eece)
- | 设置时间轴自动滚动到当前位置 | [a3474f8](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/a3474f8)
- | 调试定期任务bug;不能合并使用 | [d641312](https://dd.tall.wiki/gitea/wally/tall-mui-3-project/commits/d641312)

24
src/components/Roles/Roles.vue

@ -46,6 +46,7 @@ export default {
{ id: 1, name: '项目经理', mine: 0, pm: 1, sequence: 1 },
{ id: 2, name: '运维', mine: 0, pm: 0, sequence: 2 },
],
roleLeft: 0,
};
},
@ -69,6 +70,16 @@ export default {
} else {
this.roles = [...this.visibleRoles];
}
this.$nextTick(() => {
const query = uni.createSelectorQuery().in(this);
query
.selectAll('.tab-children')
.boundingClientRect(data => {
this.roleLeft = data[0].left;
})
.exec();
});
},
methods: {
@ -77,7 +88,6 @@ export default {
...mapMutations('task', ['setPermanents', 'clearEndFlag']),
scroll(e) {
console.log(e.detail.scrollLeft);
this.scrollLeft = e.detail.scrollLeft;
},
@ -88,10 +98,7 @@ export default {
.selectAll('.tab-children')
.boundingClientRect(data => {
data.forEach(item => {
this.tabList.push({
width: item.width,
left: item.left,
});
this.tabList.push({ width: item.width });
});
})
.exec();
@ -102,14 +109,15 @@ export default {
//
let left = 0;
for (let i = 0; i < index; i++) {
left += this.tabList[i].width + (this.tabList[0].left - 8) * 2;
left += this.tabList[i].width + (this.roleLeft - 8) * 2;
}
left += (this.tabList[index].width + (this.tabList[0].left - 8) * 2) / 2;
left += (this.tabList[index].width + (this.roleLeft - 8) * 2) / 2;
if (left > screenWidth) {
this.scrollLeft = left - screenWidth + screenWidth / 2;
} else if (left > screenWidth / 2) {
this.scrollLeft = left - screenWidth / 2;
} else {
} else if (left < screenWidth / 2) {
this.scrollLeft = 0;
}
},

6
src/components/Title/Title.vue

@ -1,6 +1,7 @@
<template>
<view>
<u-navbar :is-back="false" :custom-back="onBack" class="overflow-hidden">
<!-- :is-back="false" -->
<u-navbar :custom-back="onBack" class="overflow-hidden">
<view class="flex justify-start flex-1 px-3 font-bold min-0">
<view class="truncate">{{ project.name }}</view>
</view>
@ -103,7 +104,8 @@ export default {
if (pages.length > 1) {
uni.navigateBack();
} else {
this.$u.route('/', { u: this.userId });
// this.$u.route('/', { u: this.userId });
uni.webView.redirectTo({ url: `/pages/index/index?u=${this.userId}` });
}
},

Loading…
Cancel
Save