支付宝下单和其他细节优化

This commit is contained in:
2026-05-21 15:10:02 +08:00
parent 39bf8548df
commit 1637ee5bbc
33 changed files with 1511 additions and 232 deletions
+45 -24
View File
@@ -9,6 +9,9 @@
:initial-data="editInitialData"
@save="handleSaveEdit"
/>
<!-- 欢迎上传简历弹窗 -->
<ProfileWelcomeDialog v-model="showWelcomeDialog" />
<!-- 页面标题 -->
<div class="profile-page__header">
@@ -51,12 +54,13 @@
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { ref, onMounted, watch, computed } from 'vue'
import { useRouter } from 'vue-router'
import { useStore } from 'vuex'
import SideNav from '@/components/SideNav.vue'
import ProfileEditDrawer from '@/components/ProfileEditDrawer.vue'
import ProfilePageContent from '@/components/ProfilePageContent.vue'
import ProfileWelcomeDialog from '@/components/ProfileWelcomeDialog.vue'
import { saveProfile, fetchProfile, fetchEducation, saveEducation, fetchWork, saveWork, fetchInternship, saveInternship, fetchProject, saveProject, fetchCompetition, saveCompetition } from '@/api/profile'
import type { SaveEducationItem, SaveWorkItem, SaveProjectItem, SaveCompetitionItem } from '@/api/profile'
@@ -68,8 +72,26 @@ onMounted(async () => {
if (!store.state.regions.length) {
store.dispatch('loadCommonData')
}
// 请求个人资料主表数据,填充非数组字段
await loadProfile()
// 请求个人资料主表数据,判断是否需要弹出欢迎弹窗
const profileRes = await fetchProfile()
if (profileRes.code === '0' && (!profileRes.data || profileRes.data === null)) {
// 无个人资料数据,弹出欢迎上传弹窗
showWelcomeDialog.value = true
return
}
// 有数据,正常填充
if (profileRes.code === '0' && profileRes.data) {
const d = profileRes.data
profile.value.name = d.name || ''
profile.value.phone = d.mobileNumber || ''
profile.value.email = d.email || ''
profile.value.idNumber = d.idCard || ''
profile.value.regionCode = d.regionCode || ''
profile.value.wechat = d.wechatNumber || ''
profile.value.skills = d.skills || []
profile.value.certificates = d.certificates || []
profile.value.portfolioUrl = d.portfolioUrl || ''
}
// 请求教育经历数据
await loadEducation()
// 请求工作经历数据
@@ -82,27 +104,6 @@ onMounted(async () => {
await loadCompetition()
})
/** 加载个人资料主表数据 */
async function loadProfile() {
try {
const res = await fetchProfile()
if (res.code === '0' && res.data) {
const d = res.data
profile.value.name = d.name || ''
profile.value.phone = d.mobileNumber || ''
profile.value.email = d.email || ''
profile.value.idNumber = d.idCard || ''
profile.value.regionCode = d.regionCode || ''
profile.value.wechat = d.wechatNumber || ''
profile.value.skills = d.skills || []
profile.value.certificates = d.certificates || []
profile.value.portfolioUrl = d.portfolioUrl || ''
}
} catch {
console.error('[Profile] 加载个人资料失败')
}
}
/** 加载教育经历数据 */
async function loadEducation() {
try {
@@ -213,6 +214,26 @@ async function loadCompetition() {
/** 编辑抽屉的显示状态 */
const showEditDrawer = ref(false)
/** 欢迎弹窗的显示状态 */
const showWelcomeDialog = ref(false)
/** 登录状态 */
const isAuthenticated = computed(() => store.state.isAuthenticated)
/** 监听登录状态变化 — 登录成功后检查个人资料是否存在 */
watch(isAuthenticated, async (newVal, oldVal) => {
if (newVal && !oldVal) {
try {
const profileRes = await fetchProfile()
if (profileRes.code === '0' && (!profileRes.data || profileRes.data === null)) {
showWelcomeDialog.value = true
}
} catch {
// 接口异常不阻塞
}
}
})
/** 当前编辑的模块名称 */
const editModule = ref('info')