index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <div>
  3. <section
  4. id="quem-somos"
  5. class="relative min-h-screen flex flex-col bg-cover lg:bg-left"
  6. :style="{ backgroundImage: `url(${heroBackground})` }"
  7. >
  8. <div class="absolute inset-0 bg-violet-normal/45"/>
  9. <div class="relative z-10 flex-1 flex items-center">
  10. <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 w-full pt-8 pb-20 lg:py-18">
  11. <div class="flex flex-col lg:flex-row gap-4 lg:gap-12">
  12. <div class="max-w-2xl justifyBetween">
  13. <h1
  14. class="reveal text-h2 text-white font-black mb-10"
  15. style="font-size: clamp(2rem, 5vw, 3.75rem); font-weight: 900;"
  16. >
  17. {{ settings.hero_title }}
  18. </h1>
  19. <p class="reveal reveal-delay-1 text-white/90 mb-6 leading-relaxed" style="font-size: clamp(1rem, 1.5vw, 1.125rem); font-weight: 600;">
  20. {{ settings.hero_subtitle }}
  21. </p>
  22. <div class="reveal reveal-delay-2 flex flex-col sm:flex-row gap-4">
  23. <button
  24. class="btn-primary"
  25. @click="scrollTo('associe-se')"
  26. >
  27. ASSOCIE-SE AGORA
  28. </button>
  29. <button
  30. class="btn-outline"
  31. @click="scrollTo('beneficios')"
  32. >
  33. CONHEÇA OS BENEFÍCIOS
  34. </button>
  35. </div>
  36. </div>
  37. <div class="reveal reveal-delay-3 flex flex-row lg:flex-col gap-6 lg:gap-8 shrink-0">
  38. <div class="flex flex-col items-start gap-1">
  39. <span class="material-icons text-white/90 text-3xl lg:text-4xl">group</span>
  40. <span class="text-white font-bold" style="font-size: clamp(1.25rem, 2.5vw, 1.75rem);">{{ settings.stat1_value }}</span>
  41. <span class="text-white/80 text-sm">{{ settings.stat1_label }}</span>
  42. </div>
  43. <div class="flex flex-col items-start gap-1">
  44. <span class="material-icons text-white/90 text-3xl lg:text-4xl">handshake</span>
  45. <span class="text-white font-bold" style="font-size: clamp(1.25rem, 2.5vw, 1.75rem);">{{ settings.stat2_value }}</span>
  46. <span class="text-white/80 text-sm">{{ settings.stat2_label }}</span>
  47. </div>
  48. <div class="flex flex-col items-start gap-1">
  49. <span class="material-icons text-white/90 text-3xl lg:text-4xl">favorite_border</span>
  50. <span class="text-white font-bold" style="font-size: clamp(1.25rem, 2.5vw, 1.75rem);">{{ settings.stat3_value }}</span>
  51. <span class="text-white/80 text-sm">{{ settings.stat3_label }}</span>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </section>
  58. <section id="beneficios" class="bg-neutral-light py-16 lg:py-24">
  59. <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
  60. <div class="reveal text-center mb-12 lg:mb-16">
  61. <h2 class="text-h4 text-text" style="font-size: clamp(1.5rem, 3vw, 2.125rem);">
  62. Benefícios para você
  63. </h2>
  64. </div>
  65. <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
  66. <div
  67. v-for="(benefit, index) in benefits"
  68. :key="benefit.id"
  69. :class="`reveal reveal-delay-${index + 1}`"
  70. class="benefit-card"
  71. >
  72. <div class="benefit-icon-wrap">
  73. <i :class="`mdi ${benefit.icon} text-violet-normal`" style="font-size: 1.5rem;" />
  74. </div>
  75. <h3 class="text-subtitle-1 font-semibold text-text mt-4 mb-2">
  76. {{ benefit.title }}
  77. </h3>
  78. <p class="text-body-2 text-text-2 leading-relaxed">
  79. {{ benefit.description }}
  80. </p>
  81. </div>
  82. </div>
  83. </div>
  84. </section>
  85. <section id="associe-se" class="bg-violet-light py-16 lg:py-24">
  86. <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
  87. <div class="reveal text-center mb-10 lg:mb-12">
  88. <h2 class="text-h4 text-text" style="font-size: clamp(1.5rem, 3vw, 2.125rem);">
  89. Associe-se
  90. </h2>
  91. </div>
  92. <div class="reveal reveal-delay-1 max-w-3xl mx-auto">
  93. <div class="mb-0">
  94. <button class="tab-active">
  95. NOVA ASSOCIAÇÃO
  96. </button>
  97. </div>
  98. <div class="bg-white rounded-b-2xl rounded-tr-2xl shadow-md p-6 lg:p-10">
  99. <form novalidate @submit.prevent="handleSubmit" >
  100. <div class="grid grid-cols-1 sm:grid-cols-2 gap-5 mb-6">
  101. <div class="field-group">
  102. <label class="field-label">Nome Completo</label>
  103. <div class="field-input-wrap">
  104. <span class="material-icons field-icon">person</span>
  105. <input
  106. v-model="form.nomeCompleto"
  107. type="text"
  108. placeholder="Seu Nome"
  109. class="field-input"
  110. >
  111. </div>
  112. </div>
  113. <div class="field-group">
  114. <label class="field-label">CPF</label>
  115. <div :class="['field-input-wrap', { 'field-error': errors.cpf }]">
  116. <span class="material-icons field-icon">badge</span>
  117. <input
  118. :value="form.cpf"
  119. type="text"
  120. placeholder="000.000.000-00"
  121. maxlength="14"
  122. class="field-input"
  123. @input="handleCPF"
  124. @blur="onCPFBlur"
  125. >
  126. </div>
  127. </div>
  128. <div class="field-group">
  129. <label class="field-label">Crachá</label>
  130. <div class="field-input-wrap">
  131. <span class="material-icons field-icon">credit_card</span>
  132. <input
  133. v-model="form.cracha"
  134. type="text"
  135. placeholder="Número do seu crachá"
  136. class="field-input"
  137. >
  138. </div>
  139. </div>
  140. <div class="field-group">
  141. <label class="field-label">E-mail</label>
  142. <div :class="['field-input-wrap', { 'field-error': errors.email }]">
  143. <span class="material-icons field-icon">email</span>
  144. <input
  145. v-model="form.email"
  146. type="email"
  147. placeholder="nome@conta.com"
  148. class="field-input"
  149. @blur="onEmailBlur"
  150. >
  151. </div>
  152. </div>
  153. <div class="field-group">
  154. <label class="field-label">Telefone</label>
  155. <div :class="['field-input-wrap', { 'field-error': errors.telefone }]">
  156. <span class="material-icons field-icon">phone</span>
  157. <input
  158. :value="form.telefone"
  159. type="tel"
  160. placeholder="(00) 00000-0000"
  161. maxlength="15"
  162. class="field-input"
  163. @input="handlePhone"
  164. @blur="onPhoneBlur"
  165. >
  166. </div>
  167. </div>
  168. <div class="field-group">
  169. <label class="field-label">Cargo</label>
  170. <div class="field-input-wrap">
  171. <span class="material-icons field-icon">work</span>
  172. <select v-model="form.cargoId" class="field-input">
  173. <option :value="null" disabled>Selecione seu cargo</option>
  174. <option v-for="position in positions" :key="position.id" :value="position.id">
  175. {{ position.name }}
  176. </option>
  177. </select>
  178. </div>
  179. </div>
  180. <div class="field-group">
  181. <label class="field-label">Setor</label>
  182. <div class="field-input-wrap">
  183. <span class="material-icons field-icon">business</span>
  184. <select v-model="form.setorId" class="field-input">
  185. <option :value="null" disabled>Selecione seu setor</option>
  186. <option v-for="sector in sectors" :key="sector.id" :value="sector.id">
  187. {{ sector.name }}
  188. </option>
  189. </select>
  190. </div>
  191. </div>
  192. </div>
  193. <div class="flex justify-center">
  194. <button type="submit" class="btn-submit" :disabled="isLoading" :style="isLoading ? 'opacity: 0.7; cursor: not-allowed;' : ''">
  195. {{ isLoading ? 'ENVIANDO...' : 'ENVIAR SOLICITAÇÃO' }}
  196. </button>
  197. </div>
  198. </form>
  199. </div>
  200. </div>
  201. </div>
  202. </section>
  203. <Transition name="toast">
  204. <div
  205. v-if="showSuccess"
  206. class="fixed bottom-6 right-6 z-50 bg-violet-normal text-white px-5 py-4 rounded-xl shadow-xl flex items-center gap-3"
  207. >
  208. <span class="material-icons text-xl">check_circle</span>
  209. <span class="text-sm font-medium">Solicitação enviada com sucesso!</span>
  210. </div>
  211. </Transition>
  212. <Transition name="toast">
  213. <div
  214. v-if="showError"
  215. class="fixed bottom-6 right-6 z-50 bg-red-600 text-white px-5 py-4 rounded-xl shadow-xl flex items-center gap-3"
  216. >
  217. <span class="material-icons text-xl">error_outline</span>
  218. <span class="text-sm font-medium">{{ errorMessage }}</span>
  219. </div>
  220. </Transition>
  221. </div>
  222. </template>
  223. <script setup lang="ts">
  224. import heroBgFallback from '~/assets/images/imagem_fundo.png'
  225. useHead({ title: 'Serprati' })
  226. definePageMeta({ layout: 'default' })
  227. const { settings, benefits } = useCompanyData()
  228. const heroBackground = computed(() => settings.value.hero_background_url ?? heroBgFallback)
  229. const scrollTo = (id: string) => {
  230. document.getElementById(id)?.scrollIntoView({ behavior: 'smooth' })
  231. }
  232. const form = reactive({
  233. nomeCompleto: '',
  234. cpf: '',
  235. cracha: '',
  236. email: '',
  237. telefone: '',
  238. cargoId: null as number | null,
  239. setorId: null as number | null,
  240. })
  241. const formatCPF = (value: string): string => {
  242. return value
  243. .replace(/\D/g, '')
  244. .replace(/(\d{3})(\d)/, '$1.$2')
  245. .replace(/(\d{3})(\d)/, '$1.$2')
  246. .replace(/(\d{3})(\d{1,2})$/, '$1-$2')
  247. .slice(0, 14)
  248. }
  249. const validateCPF = (cpf: string): boolean => {
  250. const d = cpf.replace(/\D/g, '')
  251. if (d.length !== 11 || /^(\d)\1{10}$/.test(d)) return false
  252. const calc = (n: number): number => {
  253. let sum = 0
  254. for (let i = 0; i < n; i++) sum += parseInt(d.charAt(i)) * (n + 1 - i)
  255. const rem = sum % 11
  256. return rem < 2 ? 0 : 11 - rem
  257. }
  258. return calc(9) === parseInt(d.charAt(9)) && calc(10) === parseInt(d.charAt(10))
  259. }
  260. const validateEmail = (email: string): boolean =>
  261. /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)
  262. const formatPhone = (value: string): string =>
  263. value
  264. .replace(/\D/g, '')
  265. .replace(/^(\d{2})(\d)/, '($1) $2')
  266. .replace(/(\d{5})(\d{1,4})$/, '$1-$2')
  267. .slice(0, 15)
  268. const errors = reactive({ cpf: '', email: '', telefone: '' })
  269. const handleCPF = (e: Event) => {
  270. form.cpf = formatCPF((e.target as HTMLInputElement).value)
  271. if (errors.cpf) errors.cpf = ''
  272. }
  273. const handlePhone = (e: Event) => {
  274. form.telefone = formatPhone((e.target as HTMLInputElement).value)
  275. if (errors.telefone) errors.telefone = ''
  276. }
  277. const onCPFBlur = () => {
  278. errors.cpf = form.cpf && !validateCPF(form.cpf) ? 'CPF inválido' : ''
  279. }
  280. const onEmailBlur = () => {
  281. errors.email = form.email && !validateEmail(form.email) ? 'E-mail inválido' : ''
  282. }
  283. const onPhoneBlur = () => {
  284. errors.telefone = form.telefone && form.telefone.replace(/\D/g, '').length < 10 ? 'Telefone inválido' : ''
  285. }
  286. watch(() => form.email, () => { if (errors.email) errors.email = '' })
  287. const { registerLandingUser, positions, sectors } = useRegisterApi()
  288. const isLoading = ref(false)
  289. const showSuccess = ref(false)
  290. const showError = ref(false)
  291. const errorMessage = ref('')
  292. const resetForm = () => {
  293. Object.assign(form, {
  294. nomeCompleto: '',
  295. cpf: '',
  296. cracha: '',
  297. email: '',
  298. telefone: '',
  299. cargoId: null,
  300. setorId: null,
  301. })
  302. Object.assign(errors, { cpf: '', email: '', telefone: '' })
  303. }
  304. const handleSubmit = async () => {
  305. errors.cpf = form.cpf && !validateCPF(form.cpf) ? 'CPF inválido' : ''
  306. errors.email = form.email && !validateEmail(form.email) ? 'E-mail inválido' : ''
  307. errors.telefone = form.telefone && form.telefone.replace(/\D/g, '').length < 10 ? 'Telefone inválido' : ''
  308. if (errors.cpf || errors.email || errors.telefone) return
  309. isLoading.value = true
  310. showError.value = false
  311. try {
  312. await registerLandingUser({
  313. name: form.nomeCompleto,
  314. cpf: form.cpf,
  315. registration: form.cracha,
  316. email: form.email,
  317. phone: form.telefone,
  318. position_id: form.cargoId,
  319. sector_id: form.setorId,
  320. })
  321. showSuccess.value = true
  322. setTimeout(() => { showSuccess.value = false }, 4000)
  323. resetForm()
  324. } catch (err: unknown) {
  325. const error = err as { data?: { errors?: Record<string, string[]>; message?: string } }
  326. const firstError = error?.data?.errors
  327. ? Object.values(error.data.errors)[0]?.[0]
  328. : error?.data?.message
  329. errorMessage.value = firstError || 'Erro ao enviar solicitação. Tente novamente.'
  330. showError.value = true
  331. setTimeout(() => { showError.value = false }, 5000)
  332. } finally {
  333. isLoading.value = false
  334. }
  335. }
  336. onMounted(() => {
  337. const observer = new IntersectionObserver(
  338. (entries) => {
  339. entries.forEach((entry) => {
  340. if (entry.isIntersecting) {
  341. entry.target.classList.add('is-visible')
  342. observer.unobserve(entry.target)
  343. }
  344. })
  345. },
  346. { threshold: 0.1, rootMargin: '0px 0px -40px 0px' }
  347. )
  348. document.querySelectorAll('.reveal').forEach((el) => observer.observe(el))
  349. })
  350. </script>
  351. <style scoped>
  352. @media (max-width: 1023px) {
  353. #quem-somos {
  354. background-position: 8% 65%;
  355. }
  356. }
  357. .btn-primary {
  358. background: linear-gradient(90deg, #4d1658 0%, #8b30a5 100%);
  359. color: #ffffff;
  360. font-family: "Nunito", sans-serif;
  361. font-weight: 800;
  362. font-size: 0.875rem;
  363. letter-spacing: 1px;
  364. padding: 0.75rem 1.75rem;
  365. border-radius: 0.5rem;
  366. transition: opacity 0.2s;
  367. cursor: pointer;
  368. white-space: nowrap;
  369. }
  370. .btn-primary:hover {
  371. opacity: 0.88;
  372. }
  373. .btn-outline {
  374. background-color: rgba(102, 29, 117, 0.18);
  375. color: #ffffff;
  376. font-family: "Nunito", sans-serif;
  377. font-weight: 700;
  378. font-size: 0.875rem;
  379. letter-spacing: 1px;
  380. padding: 0.75rem 1.75rem;
  381. border-radius: 0.5rem;
  382. border: 2px solid #a855c8;
  383. transition: background-color 0.2s, border-color 0.2s;
  384. cursor: pointer;
  385. white-space: nowrap;
  386. }
  387. .btn-outline:hover {
  388. background-color: rgba(102, 29, 117, 0.32);
  389. border-color: #ffffff;
  390. }
  391. .benefit-card {
  392. background-color: #ffffff;
  393. border-radius: 1rem;
  394. padding: 1.75rem;
  395. box-shadow: 0 2px 12px rgba(102, 29, 117, 0.07);
  396. transition: box-shadow 0.2s, transform 0.2s;
  397. }
  398. .benefit-card:hover {
  399. box-shadow: 0 6px 24px rgba(102, 29, 117, 0.13);
  400. transform: translateY(-2px);
  401. }
  402. .benefit-icon-wrap {
  403. display: inline-flex;
  404. align-items: center;
  405. justify-content: center;
  406. width: 48px;
  407. height: 48px;
  408. background-color: #f0e8f1;
  409. border-radius: 0.75rem;
  410. }
  411. .tab-active {
  412. background-color: #661d75;
  413. color: #ffffff;
  414. font-family: "Nunito", sans-serif;
  415. font-weight: 600;
  416. font-size: 0.75rem;
  417. letter-spacing: 1.25px;
  418. padding: 0.625rem 1.5rem;
  419. border-radius: 0.5rem 0.5rem 0 0;
  420. cursor: default;
  421. }
  422. .field-group {
  423. display: flex;
  424. flex-direction: column;
  425. gap: 0.375rem;
  426. }
  427. .field-label {
  428. font-family: "Nunito", sans-serif;
  429. font-size: 0.8125rem;
  430. font-weight: 600;
  431. color: #505050;
  432. }
  433. .field-input-wrap {
  434. display: flex;
  435. align-items: center;
  436. gap: 0.5rem;
  437. border: 1.5px solid #C0C0C0;
  438. border-radius: 0.5rem;
  439. padding: 0.5rem 0.75rem;
  440. background-color: #fefefe;
  441. transition: border-color 0.2s;
  442. }
  443. .field-input-wrap:focus-within {
  444. border-color: #661d75;
  445. }
  446. .field-input-wrap.field-error {
  447. border-color: #dc2626;
  448. }
  449. .field-icon {
  450. font-size: 1.125rem;
  451. color: #b6b6b6;
  452. flex-shrink: 0;
  453. }
  454. .field-input {
  455. flex: 1;
  456. border: none;
  457. outline: none;
  458. background: transparent;
  459. font-family: "Nunito", sans-serif;
  460. font-size: 0.875rem;
  461. color: #161616;
  462. }
  463. .field-input::placeholder {
  464. color: #b6b6b6;
  465. }
  466. .btn-submit {
  467. background-color: #661d75;
  468. color: #ffffff;
  469. font-family: "Nunito", sans-serif;
  470. font-weight: 600;
  471. font-size: 0.875rem;
  472. letter-spacing: 1.25px;
  473. padding: 0.875rem 3rem;
  474. border-radius: 0.5rem;
  475. transition: background-color 0.2s;
  476. cursor: pointer;
  477. }
  478. .btn-submit:hover {
  479. background-color: #5c1a69;
  480. }
  481. .toast-enter-active,
  482. .toast-leave-active {
  483. transition: opacity 0.4s ease, transform 0.4s ease;
  484. }
  485. .toast-enter-from,
  486. .toast-leave-to {
  487. opacity: 0;
  488. transform: translateY(12px);
  489. }
  490. .justifyBetween {
  491. display: flex;
  492. flex-direction: column;
  493. justify-content: space-between;
  494. }
  495. </style>