<template>
|
<PageLayout title="" class="toggleMatchMakingIdentity-page-wrapper" :need-auth="false">
|
<ContentScrollView class="toggleMatchMakingIdentity-page-scroll-view">
|
<img :src="OssAssets.setting.ToggleBg" class="toggleMatchMakingIdentity-page-bg" />
|
<div class="toggleMatchMakingIdentity-page-title">
|
您的当前身份为“{{ MatchMakingIdentityEnumText[matchMakingIdentity] }}”
|
</div>
|
<PageFooterBtn type="primary" class="toggleMatchMakingIdentity-page-btn" @click="handleSet"
|
>切换为“{{ MatchMakingIdentityEnumText[toggledMatchMakingIdentity] }}”身份</PageFooterBtn
|
>
|
<PageFooterBtn class="toggleMatchMakingIdentity-page-btn cancel" @click="goBack"
|
>暂不切换</PageFooterBtn
|
>
|
</ContentScrollView>
|
</PageLayout>
|
</template>
|
|
<script setup lang="ts">
|
import { MatchMakingIdentityEnumText, MatchMakingIdentityEnum } from '@12333/constants';
|
import { useUser } from '@/hooks';
|
import Taro from '@tarojs/taro';
|
import { goBack, setMatchMakingIdentity } from '@/utils';
|
import { useUserStore } from '@/stores/modules/user';
|
import { Message } from '@12333/utils';
|
import { OssAssets } from '@/constants';
|
|
defineOptions({
|
name: 'toggleMatchMakingIdentity',
|
});
|
|
const { matchMakingIdentity, userDetail, isSetMatchMakingIdentity } = useUser();
|
const userStore = useUserStore();
|
|
onMounted(() => {
|
if (!isSetMatchMakingIdentity.value) {
|
setMatchMakingIdentity(matchMakingIdentity.value);
|
userStore.isSetMatchMakingIdentity = true;
|
}
|
});
|
|
const toggledMatchMakingIdentity = computed(() =>
|
matchMakingIdentity.value === MatchMakingIdentityEnum.Contributors
|
? MatchMakingIdentityEnum.Employing
|
: MatchMakingIdentityEnum.Contributors
|
);
|
|
async function handleSet() {
|
try {
|
let res = await userStore.setMatchMakingIdentity({
|
matchMakingIdentity: toggledMatchMakingIdentity.value,
|
userId: userDetail.value?.userId,
|
});
|
if (res) {
|
Message.success('切换成功', {
|
onClosed: () => {
|
goBack();
|
},
|
});
|
}
|
} catch (error) {}
|
}
|
</script>
|
|
<style lang="scss">
|
@import '@/styles/common.scss';
|
|
.toggleMatchMakingIdentity-page-wrapper {
|
background-color: #fff;
|
|
.toggleMatchMakingIdentity-page-scroll-view {
|
background-color: #fff;
|
}
|
|
.toggleMatchMakingIdentity-page-bg {
|
margin: 80px auto 60px;
|
}
|
|
.toggleMatchMakingIdentity-page-title {
|
font-weight: bold;
|
font-size: 36px;
|
color: boleGetCssVar('text-color', 'primary');
|
line-height: 50px;
|
text-align: center;
|
margin-bottom: 60px;
|
}
|
|
.toggleMatchMakingIdentity-page-btn {
|
width: 542px;
|
margin: 0 auto 40px;
|
display: block;
|
font-size: 28px;
|
|
&.cancel {
|
background: #f8f9fb;
|
font-weight: bold;
|
color: boleGetCssVar('text-color', 'primary');
|
}
|
}
|
}
|
</style>
|