Files
myprojplanet_vite/src/components/CRegistration/CRegistration.ts

120 lines
2.7 KiB
TypeScript
Executable File

import { tools } from '@tools'
import { costanti } from '@costanti'
import { computed, defineComponent, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
import { useQuasar } from 'quasar'
import { useI18n } from 'vue-i18n'
import { CContactUser } from '@src/components/CContactUser'
import { CMyUser } from '@src/components/CMyUser'
import { DefaultProfile, useUserStore } from '@store/UserStore'
import { useRoute, useRouter } from 'vue-router'
import { static_data } from '@src/db/static_data'
import { useGlobalStore } from '@store/globalStore'
export default defineComponent({
name: 'CRegistration',
emits: ['regEventEmail'],
components: { CMyUser, CContactUser },
props: {
slide: {
type: String,
required: false,
default: 'start',
},
invited: {
type: String,
required: false,
default: '',
},
regexpire: {
type: String,
required: false,
default: '',
},
signupform: {
type: Boolean,
required: false,
default: false,
},
},
setup(props, { emit }) {
const $q = useQuasar()
const { t } = useI18n()
const userStore = useUserStore()
const globalStore = useGlobalStore()
const $route = useRoute()
const $router = useRouter()
const site = ref(globalStore.site)
const chooseReg = ref(false)
const noInvited = ref(false)
const start = ref(false)
const slide = ref(props.slide)
const listlinksreg = computed(() => globalStore.datastat ? globalStore.datastat.listlinksreg : [])
const actionType = ref(costanti.ACTIONTYPE.LINK_REG)
function clickToRegister() {
//if (site.value.confpages.enableRegByBot) {
//$router.push('/bot')
//} else {
$router.push('/registrati/' + tools.getInvitante())
//}
}
function mounted() {
const invitante = tools.getInvitante()
console.log('invitante', invitante)
if (props.invited) {
start.value = true
chooseReg.value = true
slide.value = 'second'
}
}
function regEventEmail() {
if (props.signupform) {
emit('regEventEmail', props.invited)
} else {
$router.push('/registrati')
}
}
function buttRegistrati() {
const invitante = tools.getCookie(tools.APORTADOR_SOLIDARIO)
if (invitante) {
start.value = true
slide.value = 'second';
noInvited.value = false;
chooseReg.value = true;
} else {
start.value = true
}
}
onMounted(mounted)
return {
tools,
site,
clickToRegister,
chooseReg,
start,
noInvited,
slide,
regEventEmail,
buttRegistrati,
costanti,
listlinksreg,
actionType,
}
},
})