Compare commits
2 Commits
8540328bf1
...
7b225aa54a
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b225aa54a | |||
| a490254abd |
@@ -132,7 +132,6 @@ import { useRoute, useRouter } from "vue-router";
|
||||
import { useUserStore } from "@/stores/userStore";
|
||||
import { useDialogStore } from "@/stores/dialogStore";
|
||||
import { useEnv } from "@/composables/useEnv";
|
||||
import { showConfirmDialog } from "vant";
|
||||
|
||||
import Payment from "@/components/Payment.vue";
|
||||
import BindPhoneOnlyDialog from "@/components/BindPhoneOnlyDialog.vue";
|
||||
@@ -320,26 +319,11 @@ function handleBindSuccess() {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理输入框点击事件
|
||||
// 处理输入框点击事件(浏览/填写表单无需登录,仅付款时需要登录)
|
||||
const handleInputClick = async () => {
|
||||
if (!isLoggedIn.value) {
|
||||
if (!isWeChat.value && props.type !== 'promotion') {
|
||||
try {
|
||||
await showConfirmDialog({
|
||||
title: '提示',
|
||||
message: '您需要登录后才能进行查询,是否前往登录?',
|
||||
confirmButtonText: '前往登录',
|
||||
cancelButtonText: '取消',
|
||||
});
|
||||
router.push('/login');
|
||||
} catch {
|
||||
// 用户点击取消,什么都不做
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isWeChat.value && !userStore.mobile && props.type !== 'promotion') {
|
||||
dialogStore.openBindPhone();
|
||||
}
|
||||
// 已登录且在微信环境下未绑定手机号时,提示绑定
|
||||
if (isLoggedIn.value && isWeChat.value && !userStore.mobile && props.type !== 'promotion') {
|
||||
dialogStore.openBindPhone();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,59 +1,19 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from "vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { useAgentStore } from "@/stores/agentStore";
|
||||
import { useUserStore } from "@/stores/userStore";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { showToast } from "vant";
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const agentStore = useAgentStore();
|
||||
const userStore = useUserStore();
|
||||
const { isAgent } = storeToRefs(agentStore);
|
||||
const { mobile, isLoggedIn } = storeToRefs(userStore);
|
||||
|
||||
const feature = ref(route.params.feature);
|
||||
|
||||
// 获取产品信息
|
||||
const featureData = ref({});
|
||||
|
||||
// 检查是否可以查询:已登录且已绑定手机号
|
||||
const canQuery = computed(() => {
|
||||
return isLoggedIn.value && mobile.value && mobile.value.trim() !== '';
|
||||
});
|
||||
|
||||
// 检查登录状态和手机号绑定
|
||||
// 查询页可自由浏览,仅付款时需要登录
|
||||
onMounted(async () => {
|
||||
// 检查支付回调
|
||||
isFinishPayment();
|
||||
|
||||
// 检查是否已登录
|
||||
const token = localStorage.getItem("token");
|
||||
if (!token) {
|
||||
showToast({ message: "请先登录才能使用查询功能" });
|
||||
router.replace("/login");
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取用户信息(包括手机号)
|
||||
try {
|
||||
await userStore.fetchUserInfo();
|
||||
} catch (error) {
|
||||
console.error("获取用户信息失败:", error);
|
||||
showToast({ message: "获取用户信息失败,请重新登录" });
|
||||
router.replace("/login");
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查是否已绑定手机号
|
||||
if (!mobile.value || mobile.value.trim() === '') {
|
||||
showToast({ message: "请先绑定手机号才能使用查询功能" });
|
||||
router.replace("/me");
|
||||
return;
|
||||
}
|
||||
|
||||
// 已登录且已绑定手机号,可以查询
|
||||
await getProduct();
|
||||
});
|
||||
|
||||
@@ -88,20 +48,6 @@ async function getProduct() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 未登录或未绑定手机号,提示 -->
|
||||
<div v-if="!canQuery" class="min-h-screen flex items-center justify-center p-6">
|
||||
<div class="text-center">
|
||||
<div class="text-lg font-bold mb-4">无法使用查询功能</div>
|
||||
<div class="text-gray-600 mb-6">
|
||||
<span v-if="!isLoggedIn">请先登录</span>
|
||||
<span v-else>请先绑定手机号</span>
|
||||
</div>
|
||||
<button @click="router.push(isLoggedIn ? '/me' : '/login')"
|
||||
class="px-6 py-3 bg-primary text-white rounded-lg">
|
||||
{{ isLoggedIn ? '去绑定手机号' : '去登录' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 已登录且已绑定手机号,可以使用查询功能 -->
|
||||
<InquireForm v-else :type="'normal'" :feature="feature" :feature-data="featureData" />
|
||||
<!-- 查询页可自由浏览,付款时再要求登录 -->
|
||||
<InquireForm :type="'normal'" :feature="feature" :feature-data="featureData" />
|
||||
</template>
|
||||
Reference in New Issue
Block a user