|
|
|
@ -3,6 +3,9 @@ |
|
|
|
* |
|
|
|
--> |
|
|
|
<template> |
|
|
|
<!-- 协议弹框 --> |
|
|
|
<AgreementModal v-if="showAgreementModal" @confirm="handleAgreementConfirm" @cancel="handleAgreementCancel" /> |
|
|
|
|
|
|
|
<!-- 顶部用户信息--> |
|
|
|
<a-row> |
|
|
|
<HomeHeader /> |
|
|
|
@ -53,7 +56,9 @@ |
|
|
|
</a-row> |
|
|
|
</template> |
|
|
|
<script setup> |
|
|
|
import { computed } from 'vue'; |
|
|
|
import { computed, ref, onMounted } from 'vue'; |
|
|
|
import { message } from 'ant-design-vue'; |
|
|
|
import { useUserStore } from '/@/store/modules/system/user'; |
|
|
|
import HomeHeader from './home-header.vue'; |
|
|
|
import HomeNotice from './home-notice.vue'; |
|
|
|
import OfficialAccountCard from './components/official-account-card.vue'; |
|
|
|
@ -62,12 +67,73 @@ |
|
|
|
import Category from './components/echarts/category.vue'; |
|
|
|
import Pie from './components/echarts/pie.vue'; |
|
|
|
import Gradient from './components/echarts/gradient.vue'; |
|
|
|
import AgreementModal from './components/agreement-modal.vue'; |
|
|
|
import { letterApi } from '/@/api/business/letter/letter-api'; |
|
|
|
// import AdModal from './ad-modal.vue'; |
|
|
|
|
|
|
|
// 业绩完成百分比 |
|
|
|
const saleTargetPercent = computed(() => { |
|
|
|
return 75; |
|
|
|
}); |
|
|
|
const showAgreementModal = ref(false); |
|
|
|
const userStore = useUserStore(); |
|
|
|
|
|
|
|
// 检查是否需要显示协议弹框 |
|
|
|
onMounted(() => { |
|
|
|
checkAgreementStatus(); |
|
|
|
}); |
|
|
|
|
|
|
|
// 检查协议状态 |
|
|
|
function checkAgreementStatus() { |
|
|
|
// 从登录接口返回的数据中获取agreementSignFlag字段 |
|
|
|
// 如果为true,表示已同意协议,不需要显示弹框 |
|
|
|
// 如果为false或不存在,需要显示弹框 |
|
|
|
const agreementSigned = userStore.agreementSignFlag; |
|
|
|
showAgreementModal.value = !agreementSigned; |
|
|
|
|
|
|
|
console.log('协议状态检查:', 'agreementSignFlag =', agreementSigned, '显示弹框 =', showAgreementModal.value); |
|
|
|
} |
|
|
|
|
|
|
|
// 协议确认 - 签署承诺书 |
|
|
|
async function handleAgreementConfirm() { |
|
|
|
try { |
|
|
|
|
|
|
|
await letterApi.add(); |
|
|
|
message.success('承诺书签署成功'); |
|
|
|
showAgreementModal.value = false; |
|
|
|
|
|
|
|
// 更新本地协议状态 |
|
|
|
userStore.agreementSignFlag = true; |
|
|
|
|
|
|
|
//console.log('承诺书签署完成,用户ID:', userStore.employeeId); |
|
|
|
} catch (error) { |
|
|
|
message.error('承诺书签署失败,请重新登录'); |
|
|
|
console.error('承诺书签署失败:', error); |
|
|
|
|
|
|
|
// 签署失败,退出登录 |
|
|
|
userStore.logout(); |
|
|
|
|
|
|
|
// 延迟跳转到登录页 |
|
|
|
setTimeout(() => { |
|
|
|
window.location.href = '/login'; |
|
|
|
}, 1500); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 协议取消 |
|
|
|
function handleAgreementCancel() { |
|
|
|
message.warning('您需要同意平台协议才能使用系统'); |
|
|
|
showAgreementModal.value = false; |
|
|
|
|
|
|
|
// 可以在这里添加退出登录逻辑 |
|
|
|
userStore.logout(); |
|
|
|
|
|
|
|
// 延迟跳转到登录页 |
|
|
|
setTimeout(() => { |
|
|
|
window.location.href = '/login'; |
|
|
|
}, 1500); |
|
|
|
} |
|
|
|
|
|
|
|
// 业绩完成百分比 |
|
|
|
const saleTargetPercent = computed(() => { |
|
|
|
return 75; |
|
|
|
}); |
|
|
|
</script> |
|
|
|
<style lang="less" scoped> |
|
|
|
@import './index.less'; |
|
|
|
|