|
|
@@ -38,7 +38,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, onMounted } from 'vue';
|
|
|
+import { ref } from 'vue';
|
|
|
+import { onShow } from '@dcloudio/uni-app';
|
|
|
import { logger } from '@/utils/logger';
|
|
|
import { isReplenisher } from '@/utils/auth';
|
|
|
|
|
|
@@ -53,22 +54,27 @@ const tabPages = [
|
|
|
|
|
|
const currentIndex = ref(0);
|
|
|
|
|
|
-onMounted(() => {
|
|
|
- visible.value = !isReplenisher();
|
|
|
+const updateCurrentIndex = () => {
|
|
|
const pages = getCurrentPages();
|
|
|
+ if (!pages || pages.length === 0) return;
|
|
|
const currentPage = pages[pages.length - 1];
|
|
|
- const currentPath = '/' + currentPage.route;
|
|
|
+ if (!currentPage) return;
|
|
|
+ let route = currentPage.route || '';
|
|
|
+ if (!route.startsWith('/')) route = '/' + route;
|
|
|
+ const idx = tabPages.indexOf(route);
|
|
|
+ if (idx !== -1) currentIndex.value = idx;
|
|
|
+};
|
|
|
|
|
|
- const index = tabPages.indexOf(currentPath);
|
|
|
- if (index !== -1) {
|
|
|
- currentIndex.value = index;
|
|
|
- }
|
|
|
+onShow(() => {
|
|
|
+ visible.value = !isReplenisher();
|
|
|
+ updateCurrentIndex();
|
|
|
});
|
|
|
|
|
|
const switchTab = (index: number) => {
|
|
|
if (currentIndex.value === index) return;
|
|
|
|
|
|
currentIndex.value = index;
|
|
|
+ uni.setStorageSync('__tab_index__', index);
|
|
|
uni.switchTab({
|
|
|
url: tabPages[index]
|
|
|
});
|
|
|
@@ -162,6 +168,8 @@ const handleScan = () => {
|
|
|
font-size: 20rpx;
|
|
|
font-weight: 400;
|
|
|
line-height: 1.3;
|
|
|
+ text-align: center;
|
|
|
+ width: 100%;
|
|
|
}
|
|
|
|
|
|
.tab-item.active .tab-text {
|