Files
smartDriveEEUniApp/pages/furniture_reception/furniture_reception.vue

118 lines
2.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="subpackage-host">
<FurnitureReceptionImpl
v-if="implReady"
ref="furnitureReceptionImpl"
:incomingTab="incomingTab"
/>
<view v-else class="loading">
<text v-if="error">{{ error }}</text>
<text v-else>正在加载接待模块...</text>
</view>
</view>
</template>
<script>
// 微信小程序pages.json 的 componentPlaceholder 注册分包组件requiredComponents / 分包异步化)
// #ifndef MP-WEIXIN
import FurnitureReceptionImpl from '@/pages-subpackage/furniture_reception/furniture_reception-impl.vue';
// #endif
export default {
components: {
// #ifndef MP-WEIXIN
FurnitureReceptionImpl
// #endif
},
data() {
return {
implReady: false,
incomingTab: '',
error: ''
};
},
onLoad() {
this.loadImpl();
},
onShow() {
// tabBar 的 switchTab 不稳定携带 query因此从 storage 消费目标tab
try {
const allowed = ['status', 'reception', 'tag'];
const tab = (uni.getStorageSync('workbench-reception-tab') || '').toString();
if (allowed.includes(tab)) {
// 先清空再赋值,确保同一个 tabKey 也能触发子组件 watcher
this.incomingTab = '';
this.$nextTick(() => {
this.incomingTab = tab;
});
uni.removeStorageSync('workbench-reception-tab');
}
} catch (e) {
// ignore
}
// 底部 tab 等场景下页面会被缓存,子组件 mounted 不会再次执行,需每次显示时拉取最新数据
this.refreshImplDataIfReady();
},
methods: {
loadSubPackagePagesSubpackage() {
return new Promise((resolve, reject) => {
if (!uni || !uni.loadSubPackage) {
resolve();
return;
}
uni.loadSubPackage({
name: 'pages-subpackage',
success: resolve,
fail: () => {
// 兼容部分平台参数名差异
uni.loadSubPackage({
root: 'pages-subpackage',
success: resolve,
fail: reject
});
}
});
});
},
async loadImpl() {
try {
await this.loadSubPackagePagesSubpackage();
this.implReady = true;
await this.$nextTick();
this.refreshImplDataIfReady();
} catch (e) {
console.error('[FurnitureReceptionHost] loadImpl failed:', e);
this.error = '接待模块加载失败,请重试';
}
},
refreshImplDataIfReady() {
if (!this.implReady) {
return;
}
this.$nextTick(() => {
const impl = this.$refs.furnitureReceptionImpl;
if (impl && typeof impl.refreshPageData === 'function') {
impl.refreshPageData();
}
});
}
}
};
</script>
<style>
.subpackage-host {
min-height: 100vh;
background-color: #F5F5F5;
}
.loading {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
color: #666;
font-size: 28rpx;
}
</style>