fix(mobile): require employee position before user flow

This commit is contained in:
2026-07-09 17:09:26 +08:00
parent 8b92a7e9ac
commit 8f73cb0c84
13 changed files with 473 additions and 33 deletions
+21 -5
View File
@@ -8,7 +8,7 @@
v-model="query"
class="textarea"
maxlength="200"
placeholder="例如: 业主投诉噪音,生活顾问应该怎么处理?"
:placeholder="quickQuestionPlaceholder"
/>
<view class="chip-row">
<button v-for="item in quickQuestions" :key="item" class="chip" :disabled="loading" @click="useQuickQuestion(item)">
@@ -107,7 +107,7 @@
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { computed, ref } from 'vue';
import { onShow } from '@dcloudio/uni-app';
import type {
AnswerFeedbackVerdict,
@@ -119,10 +119,13 @@ import {
searchKnowledge,
submitAnswerFeedback
} from '@/services/knowledge';
import { isLoggedIn, rememberLoginRedirect } from '@/services/auth';
import { getSelectedPositionProfile, isLoggedIn, rememberLoginRedirect } from '@/services/auth';
import { resetPageScroll } from '@/services/navigation';
import { ensureEmployeePosition } from '@/services/position';
const quickQuestions = ['业主投诉噪音怎么安抚', '停车费催缴怎么说', '生活顾问的一天做什么'];
const positionProfile = ref(getSelectedPositionProfile());
const quickQuestions = computed(() => positionProfile.value.quickQuestions);
const quickQuestionPlaceholder = computed(() => `例如: ${quickQuestions.value[0] || '岗位SOP怎么处理?'}`);
const query = ref('');
const result = ref<KnowledgeSearchResponse | null>(null);
const summaryCard = ref<SummaryCardResponse | null>(null);
@@ -143,6 +146,7 @@ const resetResultState = () => {
const refreshAuthState = () => {
loggedIn.value = isLoggedIn();
positionProfile.value = getSelectedPositionProfile();
};
const handleRequestError = (error: unknown, fallback: string, wasLoggedIn = loggedIn.value) => {
@@ -169,6 +173,10 @@ const search = async () => {
goLogin();
return;
}
if (!(await ensureEmployeePosition('/pages/user/sop/index'))) {
return;
}
positionProfile.value = getSelectedPositionProfile();
loading.value = true;
message.value = '';
resetResultState();
@@ -256,9 +264,13 @@ const goLogin = () => {
uni.navigateTo({ url: '/pages/auth/login/index' });
};
onShow(() => {
const handleShow = async () => {
resetPageScroll();
refreshAuthState();
if (loggedIn.value && !(await ensureEmployeePosition('/pages/user/sop/index'))) {
return;
}
positionProfile.value = getSelectedPositionProfile();
if (!loggedIn.value) {
resetResultState();
}
@@ -276,6 +288,10 @@ onShow(() => {
} else {
message.value = '登录后继续查询该问题';
}
};
onShow(() => {
void handleShow();
});
</script>