index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. <template>
  2. <div class="login-wrap">
  3. <div class="login--gate" v-show="loginVisible == 'Y'">
  4. <div
  5. class="inf--gate"
  6. :class="gate1 ? 'actv' : ''"
  7. @mousemove.stop="handleInfluenceMove"
  8. >
  9. <div class="btn--contents">
  10. <h2>influence</h2>
  11. <v-btn class="loc--btn" @click.stop="location('influence')"
  12. >Discover more ></v-btn
  13. >
  14. </div>
  15. </div>
  16. <div
  17. class="ven--gate"
  18. :class="gate2 ? 'actv' : ''"
  19. @mousemove.stop="handleVendorMove"
  20. >
  21. <div class="btn--contents">
  22. <h2>vendor</h2>
  23. <v-btn class="loc--btn" @click.stop="location('vendor')">Discover more ></v-btn>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="login--cock" v-show="loginVisible == 'N'">
  28. <!-- header -->
  29. <div class="login--header">
  30. <div class="login--header--l">
  31. <div class="logo">
  32. SHOPDELI
  33. </div>
  34. </div>
  35. <div class="login--header--r"></div>
  36. </div>
  37. <!-- login -->
  38. <div class="login-box">
  39. <div class="login-l">
  40. <div class="login-l-center">
  41. <span class="logo">
  42. <!-- prettier-ignore -->
  43. SHOPDELI
  44. </span>
  45. <!-- <p>We Make Scalable Mobility Life</p> -->
  46. </div>
  47. </div>
  48. <div class="login-r">
  49. <div class="tit-login">
  50. <strong>{{ route.query.type == 'brand' ? '브랜드사' : route.query.type == 'vendor' ? '벤더사' : '' }} 로그인</strong>
  51. </div>
  52. <div class="login-input-wrap">
  53. <div
  54. class="txt-field-box"
  55. :class="!loginForm.validCheck.input.userId ? 'error' : ''"
  56. >
  57. <v-text-field
  58. v-model="loginForm.userId"
  59. placeholder="아이디를 입력해주세요"
  60. class="custom-input"
  61. @keyup.enter="
  62. loginAction(loginForm.userId, loginForm.passwd, loginForm.loginType)
  63. "
  64. @input="setInputField('main_userId')"
  65. ></v-text-field>
  66. <i class="ico"></i>
  67. </div>
  68. <div
  69. class="txt-field-box"
  70. :class="!loginForm.validCheck.input.passwd ? 'error' : ''"
  71. >
  72. <v-text-field
  73. v-model="loginForm.passwd"
  74. :type="visible ? 'text' : 'password'"
  75. placeholder="비밀번호를 입력해주세요"
  76. class="custom-input"
  77. id="password"
  78. @keyup.enter="
  79. loginAction(loginForm.userId, loginForm.passwd, loginForm.loginType)
  80. "
  81. @input="setInputField('main_passwd')"
  82. ></v-text-field>
  83. <i
  84. class="ico-eye"
  85. @click.stop="toggleVisibility"
  86. :class="visible ? 'eye-on' : 'eye-off'"
  87. ></i>
  88. <i class="ico"></i>
  89. </div>
  90. <!-- <p class="error-txt" v-if="!loginForm.validCheck.inputErrorCheck">
  91. {{ loginForm.validCheck.passwd }}
  92. </p> -->
  93. </div>
  94. <div class="login-btn-wrap">
  95. <v-btn
  96. v-if="loginForm.loginType == 'influence'"
  97. class="custom-btn btn-blue"
  98. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd, 'influence')"
  99. @click="loginAction(loginForm.userId, loginForm.passwd, 'influence')"
  100. >로그인</v-btn
  101. >
  102. <v-btn
  103. v-else-if="loginForm.loginType == 'vendor'"
  104. class="custom-btn btn-blue"
  105. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd, 'vendor')"
  106. @click="loginAction(loginForm.userId, loginForm.passwd, 'vendor')"
  107. >로그인</v-btn
  108. >
  109. <v-btn
  110. v-else-if="loginForm.loginType == 'brand'"
  111. class="custom-btn btn-blue"
  112. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd, 'brand')"
  113. @click="loginAction(loginForm.userId, loginForm.passwd, 'brand')"
  114. >로그인</v-btn
  115. >
  116. </div>
  117. <div class="join--btn--wrap">
  118. <v-btn class="custom-btn text--btn">아이디 찾기</v-btn>
  119. <v-btn class="custom-btn text--btn">비밀번호 찾기</v-btn>
  120. <v-btn class="custom-btn text--btn" @click="location('join')">회원가입</v-btn>
  121. </div>
  122. <div class="short--login--wrap" v-if="loginForm.loginType == 'influence'">
  123. <v-btn class="btn--google" @click.stop="onGoogleLogin"></v-btn>
  124. <v-btn class="btn--kakao" @click.stop="onKakaoLogin"></v-btn>
  125. <v-btn class="btn--naver" @click.stop="onNaverLogin"></v-btn>
  126. </div>
  127. </div>
  128. </div>
  129. <!-- footer -->
  130. <div class="login-footer">
  131. <div class="login--footer--l">
  132. <p>COPYRIGHT@2025 SHOPDELI INC. ALL RIGHTS RESERVED.</p>
  133. <p>마포구 합정동</p>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. </template>
  139. <script setup>
  140. /************************
  141. * import
  142. ************************/
  143. //import PrivacyPop from "@/components/login/privacyPop.vue";
  144. //import AgrNPop from "@/components/terms/agreeNListPop.vue";
  145. import { useI18n } from "vue-i18n";
  146. /************************
  147. * layout setting
  148. ************************/
  149. definePageMeta({
  150. layout: "loginlayout",
  151. });
  152. /************************
  153. * plugins inject
  154. ************************/
  155. const { $dayjs, $log, $eventBus, $toast, $userAgent } = useNuxtApp();
  156. const useStore = useDetailStore();
  157. const route = useRoute();
  158. /************************
  159. * data & created
  160. ************************/
  161. // 현재 입력 중인 필드를 설정하는 함수
  162. const setInputField = (name) => {
  163. fnValidCheck(name);
  164. };
  165. const pageId = "login";
  166. const gate1 = ref(false);
  167. const gate2 = ref(false);
  168. const loginVisible = ref("N");
  169. const i18n = useI18n();
  170. // 다국어
  171. let listObj = ref({
  172. langTypeList: {},
  173. });
  174. // 로그인 정보
  175. const loginForm = ref({
  176. userId: "",
  177. passwd: "",
  178. otpNum: "",
  179. username: "",
  180. authType: "GOOGLE",
  181. userAgent: "",
  182. loginType: "",
  183. validCheck: {
  184. input: {
  185. userId: true,
  186. passwd: true,
  187. },
  188. otp: {
  189. otpNum: true,
  190. },
  191. inputErrorCheck: true,
  192. inputValidTxt: "",
  193. otpValidTxt: "",
  194. loginValidCheck: false,
  195. btnTxt: "",
  196. btnTxtType: "",
  197. },
  198. });
  199. // 구글 OTP 1차 팝업
  200. const authPop1 = ref({
  201. popYn: false,
  202. certifyYN: false,
  203. userId: "",
  204. passwd: "",
  205. otpNum: "",
  206. validOtpKey: true,
  207. validOtpTxt: "",
  208. btnTxt: "",
  209. btnTxtType: "",
  210. applyBtn: false,
  211. succOtpYn: false,
  212. businessName: "",
  213. agreeChk1: false,
  214. agreeChk2: false,
  215. validCheck: {
  216. userId: true,
  217. passwd: true,
  218. },
  219. validTxt: "",
  220. errorCheck: false,
  221. });
  222. // 구글 OTP 2차 팝업
  223. const authPop2 = ref({
  224. popYn: false,
  225. otpNum: "",
  226. validOtpKey: true,
  227. validOtpTxt: "",
  228. errorCheck: false,
  229. });
  230. // 아이디 찾기
  231. const findId = ref({
  232. popYn: false,
  233. //tenantName: '',
  234. email: "",
  235. otpNum: "",
  236. validCheck: {
  237. input: {
  238. //tenantName: true,
  239. email: true,
  240. },
  241. otp: {
  242. otpNum: true,
  243. },
  244. inputErrorCheck: true,
  245. inputValidTxt: "",
  246. otpValidTxt: "",
  247. findIdValidCheck: false,
  248. },
  249. btnTxt: "",
  250. });
  251. // 비밀번호 초기화
  252. const resetPw = ref({
  253. popYn: false,
  254. userId: "",
  255. email: "",
  256. otpNum: "",
  257. validCheck: {
  258. input: {
  259. userId: true,
  260. email: true,
  261. },
  262. otp: {
  263. otpNum: true,
  264. },
  265. inputErrorCheck: true,
  266. inputValidTxt: "",
  267. otpValidTxt: "",
  268. resetPwValidCheck: false,
  269. },
  270. btnTxt: "",
  271. });
  272. // 초기 패스워드 변경
  273. const initPw = ref({
  274. popYn: false,
  275. passwd: "",
  276. passwd2: "",
  277. validCheck: {
  278. passwd: true,
  279. passwd2: true,
  280. },
  281. passwdCheck: false,
  282. errorTxt: "",
  283. });
  284. const selectPlaceholder = ref("");
  285. const initAuthPop1 = ref({});
  286. const initAuthPop2 = ref({});
  287. const initFindId = ref({});
  288. const initResetPw = ref({});
  289. const initInitPw = ref({});
  290. const googleOtpQrCode = ref("");
  291. const googleOtpSecretKey = ref("");
  292. const loginInfo = ref({});
  293. const checkbox = ref(false);
  294. const langType = ref("");
  295. const toggleVisibility = () => {
  296. visible.value = !visible.value;
  297. };
  298. const visible = ref(false);
  299. const isAgrNPop = ref(false);
  300. const isShowAgrNPop = ref(false);
  301. let saveId = localStorage.getItem("saveId");
  302. if (saveId) {
  303. checkbox.value = true;
  304. loginForm.value.userId = saveId;
  305. }
  306. const handleInfluenceMove = (event) => {
  307. const el = event.currentTarget;
  308. const rect = el.getBoundingClientRect();
  309. const mouseX = event.clientX;
  310. // 요소 너비의 15%를 좌우 여백으로 계산 (중앙 70% 영역)
  311. const margin = rect.width * 0.15;
  312. const leftBound = rect.left + margin;
  313. const rightBound = rect.right - margin;
  314. if (mouseX >= leftBound && mouseX <= rightBound) {
  315. gate1.value = true;
  316. gate2.value = false;
  317. } else {
  318. gate1.value = false;
  319. }
  320. };
  321. const handleVendorMove = (event) => {
  322. const el = event.currentTarget;
  323. const rect = el.getBoundingClientRect();
  324. const mouseX = event.clientX;
  325. // 요소 너비의 15%를 좌우 여백으로 계산 (중앙 70% 영역)
  326. const margin = rect.width * 0.15;
  327. const leftBound = rect.left + margin;
  328. const rightBound = rect.right - margin;
  329. if (mouseX >= leftBound && mouseX <= rightBound) {
  330. gate2.value = true;
  331. gate1.value = false;
  332. } else {
  333. gate2.value = false;
  334. }
  335. };
  336. // 개인정보처리방침 이용약관 팝업
  337. //const privacyPop = ref(false);
  338. const privacyDetail = ref({
  339. kr: {
  340. title: "",
  341. contents: "",
  342. },
  343. en: {
  344. title: "",
  345. contents: "",
  346. },
  347. });
  348. const systemInfo = ref({
  349. mode: "",
  350. });
  351. const loginAction = (__ID, __PASS, __TYPE) => {
  352. let _req = {
  353. id: __ID,
  354. password: __PASS,
  355. logintype: __TYPE,
  356. };
  357. useAxios()
  358. .post("/roulette/login", _req)
  359. .then((res) => {
  360. if (res.data) {
  361. // console.log(res.data);
  362. useAuthStore().setAuth(res.data);
  363. useAuthStore().setAccessToken(res.data.accessToken);
  364. useAuthStore().setRefreshToken(res.data.refreshToken);
  365. // 디버깅: 로그인 후 사용자 정보 확인
  366. console.log('=== 로그인 성공 디버깅 ===');
  367. console.log('원본 데이터:', res.data);
  368. console.log('설정된 auth 정보:', useAuthStore().auth);
  369. console.log('COMPANY_NUMBER:', useAuthStore().auth.companyNumber);
  370. console.log('memberType:', useAuthStore().auth.memberType);
  371. console.log('===========================');
  372. localStorage.setItem("tempAccess", __ID);
  373. // vendor/brand 타입이면 dashboard로, 그 외에는 기존 item 페이지로
  374. const memberType = useAuthStore().auth.memberType;
  375. if (memberType === 'VENDOR' || memberType === 'BRAND') {
  376. useUtil.setPageMove("/view/common/dashboard");
  377. useStore.menuInfo.menuIndex = "0";
  378. useStore.menuInfo.menuId = "menu00";
  379. useStore.menuInfo.pageRtName = "대시보드";
  380. useStore.menuInfo.pageStatus = null;
  381. } else {
  382. useUtil.setPageMove("/view/common/item");
  383. useStore.menuInfo.menuIndex = "0";
  384. useStore.menuInfo.menuId = "menu01";
  385. useStore.menuInfo.pageRtName = "제품 관리";
  386. useStore.menuInfo.pageStatus = null;
  387. }
  388. }
  389. })
  390. .catch((error) => {
  391. if (error.response) {
  392. console.log("status:", error.response.status, "data:", error.response.data);
  393. // 안전하게 errCode, message 접근
  394. const errData = error.response.data || {};
  395. const errCode = errData.errCode || errData.errorCode || errData.code || "";
  396. const errMsg = errData.message || "알 수 없는 오류가 발생했습니다.";
  397. console.log("errCode:", errCode, "message:", errMsg);
  398. } else {
  399. console.log("error:", error.message, error.code);
  400. }
  401. if (error.response?.status) {
  402. fnLoginSet(error.response.data.messages.message);
  403. }
  404. $log.debug("[login][fnIdPwCheck][error]");
  405. })
  406. .finally(() => {
  407. $log.debug("[login][fnIdPwCheck][finished]");
  408. });
  409. };
  410. const location = (__id) => {
  411. switch (__id) {
  412. case "join":
  413. useUtil.setPageMove("/auth/join?type=" + loginForm.value.loginType);
  414. break;
  415. case "findId":
  416. findId.value.popYn = true;
  417. break;
  418. case "resetPw":
  419. resetPw.value.popYn = true;
  420. break;
  421. case "influence":
  422. useUtil.setPageMove("/?type=influence");
  423. loginVisible.value = "Y";
  424. break;
  425. case "vendor":
  426. useUtil.setPageMove("/?type=vendor");
  427. loginVisible.value = "N";
  428. break;
  429. default:
  430. break;
  431. }
  432. };
  433. // onMounted
  434. onMounted(() => {
  435. //로그인페이지 접근시 파라미터 체크하여 인플루언서, 밴더 구분
  436. const typeParam = route.query.type;
  437. if (typeParam == "influence") {
  438. loginForm.value.loginType = "influence";
  439. } else if (typeParam == "vendor") {
  440. loginForm.value.loginType = "vendor";
  441. } else if (typeParam == "brand") {
  442. loginForm.value.loginType = "brand";
  443. } else {
  444. loginVisible.value = "Y";
  445. }
  446. //구글 인증 프로세스
  447. function handleMessage(event) {
  448. const appBaseUrl = import.meta.env.VITE_APP_API_URL;
  449. // 개발환경이면 아래처럼 확인
  450. const allowedOrigins = [
  451. "http://0.0.0.0:3000",
  452. "http://localhost:3000",
  453. appBaseUrl,
  454. ].filter(Boolean);
  455. if (allowedOrigins.includes(event.origin)) {
  456. const { accessToken, refreshToken, user } = event.data;
  457. if (user?.JOIN === "1") {
  458. useAuthStore().setTempData(user);
  459. useUtil.setPageMove("/auth/join?type=" + loginForm.value.loginType);
  460. } else {
  461. // SNS 로그인 성공 시 인증 정보 제대로 설정
  462. const authData = {
  463. refreshToken: refreshToken,
  464. user: user,
  465. };
  466. // setAuth를 호출하여 auth 스토어에 사용자 정보 저장
  467. useAuthStore().setAuth(authData);
  468. useAuthStore().setTempData(authData);
  469. useAuthStore().setAccessToken(accessToken);
  470. useAuthStore().setRefreshToken(refreshToken);
  471. localStorage.setItem("tempAccess", user.ID || user.id || user.SEQ);
  472. useUtil.setPageMove("/view/common/item");
  473. useStore.menuInfo.menuIndex = "0";
  474. useStore.menuInfo.menuId = "menu02";
  475. useStore.menuInfo.pageRtName = "이벤트 관리";
  476. useStore.menuInfo.pageStatus = null;
  477. }
  478. }
  479. }
  480. window.addEventListener("message", handleMessage);
  481. onBeforeUnmount(() => window.removeEventListener("message", handleMessage));
  482. });
  483. watch(
  484. () => route.query.type,
  485. (newType) => {
  486. if (newType === "influence" || newType === "vendor" || newType === "brand") {
  487. loginForm.value.loginType = newType;
  488. loginVisible.value = "N"; // 로그인 폼 보이기
  489. } else {
  490. loginVisible.value = "Y"; // 게이트 페이지 보이기
  491. }
  492. },
  493. {
  494. immediate: true, // 컴포넌트가 마운트될 때 즉시 실행
  495. }
  496. );
  497. watchEffect(() => {
  498. // 감시하고자 하는 데이터를 해당 블럭내에서 사용하면 호출된다.
  499. // getLang.value를 감시하는 상태
  500. //QfnGetEnumCode(useLangStore().getLang);
  501. });
  502. // $eventBus.off("SET_SUCCESS_POPUP");
  503. // $eventBus.on("SET_SUCCESS_POPUP", () => {
  504. // // 안내 팝업 확인 클릭 팝업 초기화처리
  505. // fnOtpPopClose("findId");
  506. // fnOtpPopClose("resetPw");
  507. // });
  508. // $eventBus.off("PASSWD_CHANGE");
  509. // $eventBus.on("PASSWD_CHANGE", () => {
  510. // fnPasswdChange();
  511. // });
  512. // $eventBus.off("INIT_PASSWORD");
  513. // $eventBus.on("INIT_PASSWORD", () => {
  514. // initPw.value.popYn = true;
  515. // });
  516. // $eventBus.off("SET_LOGIN");
  517. // $eventBus.on("SET_LOGIN", () => {
  518. // fnLogin();
  519. // });
  520. /************************
  521. * Methods
  522. ************************/
  523. const fnLoginSet = (__MSG) => {
  524. let param = {
  525. id: pageId,
  526. title: "로그인",
  527. content: __MSG,
  528. yes: {
  529. text: "확인",
  530. isProc: true,
  531. event: "FN_LOGIN",
  532. param: "",
  533. },
  534. };
  535. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  536. };
  537. // 구글 로그인 인증 시퀀스
  538. function onGoogleLogin() {
  539. const appBaseUrl = import.meta.env.VITE_APP_API_URL;
  540. const clientId =
  541. "373780605211-diojebh7mug45urv9rnqdil6n0b1ogge.apps.googleusercontent.com"; // 실제 클라이언트 ID로 교체
  542. //const redirectUri = "https://shopdeli.mycafe24.com/auth/callback"; // 실제 리디렉션 URI로 교체
  543. const redirectUri = `${appBaseUrl}/auth/callback`;
  544. const scope = "openid email profile";
  545. const responseType = "code"; // 또는 'code' (백엔드 연동 시)
  546. const state = Math.random().toString(36).substring(2);
  547. const googleAuthUrl = `https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&client_id=${clientId}&redirect_uri=${encodeURIComponent(
  548. redirectUri
  549. )}&response_type=${responseType}&scope=${encodeURIComponent(scope)}&state=${state}`;
  550. const width = 500;
  551. const height = 600;
  552. const dualScreenLeft =
  553. window.screenLeft !== undefined ? window.screenLeft : window.screenX;
  554. const dualScreenTop =
  555. window.screenTop !== undefined ? window.screenTop : window.screenY;
  556. const currentWidth = window.innerWidth
  557. ? window.innerWidth
  558. : document.documentElement.clientWidth
  559. ? document.documentElement.clientWidth
  560. : screen.width;
  561. const currentHeight = window.innerHeight
  562. ? window.innerHeight
  563. : document.documentElement.clientHeight
  564. ? document.documentElement.clientHeight
  565. : screen.height;
  566. const left = dualScreenLeft + (currentWidth - width) / 2;
  567. const top = dualScreenTop + (currentHeight - height) / 2;
  568. window.open(
  569. googleAuthUrl,
  570. "googleLogin",
  571. `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  572. );
  573. }
  574. //카카오 인증 시퀀스
  575. function onKakaoLogin() {
  576. const appBaseUrl = import.meta.env.VITE_APP_API_URL;
  577. const kakaoAuthUrl = `${appBaseUrl}/auth/kakaoLogin`; // 실제 리디렉션 URI로 교체
  578. const width = 500;
  579. const height = 600;
  580. const dualScreenLeft =
  581. window.screenLeft !== undefined ? window.screenLeft : window.screenX;
  582. const dualScreenTop =
  583. window.screenTop !== undefined ? window.screenTop : window.screenY;
  584. const currentWidth = window.innerWidth
  585. ? window.innerWidth
  586. : document.documentElement.clientWidth
  587. ? document.documentElement.clientWidth
  588. : screen.width;
  589. const currentHeight = window.innerHeight
  590. ? window.innerHeight
  591. : document.documentElement.clientHeight
  592. ? document.documentElement.clientHeight
  593. : screen.height;
  594. const left = dualScreenLeft + (currentWidth - width) / 2;
  595. const top = dualScreenTop + (currentHeight - height) / 2;
  596. window.open(
  597. kakaoAuthUrl,
  598. "kakaoLogin",
  599. `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  600. );
  601. }
  602. //네이버 인증 시퀀스
  603. function onNaverLogin() {
  604. const appBaseUrl = import.meta.env.VITE_APP_API_URL;
  605. const naverAuthUrl = `${appBaseUrl}/auth/naverLogin`; // 실제 리디렉션 URI로 교체
  606. const width = 500;
  607. const height = 600;
  608. const dualScreenLeft =
  609. window.screenLeft !== undefined ? window.screenLeft : window.screenX;
  610. const dualScreenTop =
  611. window.screenTop !== undefined ? window.screenTop : window.screenY;
  612. const currentWidth = window.innerWidth
  613. ? window.innerWidth
  614. : document.documentElement.clientWidth
  615. ? document.documentElement.clientWidth
  616. : screen.width;
  617. const currentHeight = window.innerHeight
  618. ? window.innerHeight
  619. : document.documentElement.clientHeight
  620. ? document.documentElement.clientHeight
  621. : screen.height;
  622. const left = dualScreenLeft + (currentWidth - width) / 2;
  623. const top = dualScreenTop + (currentHeight - height) / 2;
  624. window.open(
  625. naverAuthUrl,
  626. "naverLogin",
  627. `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  628. );
  629. }
  630. /**
  631. * @API
  632. * 최종 로그인 버튼 클릭 시 API
  633. */
  634. function fnLogin(__USERID, __USERPASS) {
  635. // 파라미터 전달 값 [아이디, 비밀번호, otpNum, 브라우저정보]
  636. //userId: loginForm.value.userId,
  637. // let _req = {
  638. // username: loginForm.value.userId,
  639. // password: btoa(loginForm.value.passwd),
  640. // };
  641. localStorage.setItem("tempAccess", __USERID);
  642. if (__USERID == "admin" && __USERPASS == "1234") {
  643. useUtil.setPageMove("/view/media/newsList");
  644. } else {
  645. fnLoginSet("비밀번호가 맞지 않습니다. 확인해주세요.");
  646. }
  647. // useAxios()
  648. // .post(apiUrl.otpCheck, _req)
  649. // .then((res) => {
  650. // loginInfo.value = res.data.data;
  651. // useAuthStore().setAccessToken(loginInfo.value.accessToken);
  652. // useAuthStore().setRefreshToken(loginInfo.value.refreshToken);
  653. // // OTP key체크 성공 후 개인정보에 대한 API를 호출 한다.
  654. // fnServiceModeCheck();
  655. // $log.debug("[login][fnLogin][success]");
  656. // })
  657. // .catch((error) => {
  658. // $log.debug("[login][fnLogin][error]");
  659. // let errorData = error.response.data;
  660. // errorData.type = "fnLogin";
  661. // fnLoginFail(errorData);
  662. // })
  663. // .finally(() => {
  664. // $log.debug("[login][fnLogin][finished]");
  665. // });
  666. }
  667. /**
  668. * @SCRIPT
  669. * 비밀번호확인 validation
  670. */
  671. function fnValidCheck(type) {
  672. // 아이디 체크
  673. if (type === "id") {
  674. const id = loginForm.value.userId;
  675. // 1. 기본 유효성 검사
  676. if (!id) {
  677. $toast.error("아이디를 입력해주세요.");
  678. return false;
  679. }
  680. // 2. 아이디 형식 검사 (영문, 숫자 조합 6~20자)
  681. const idRegex = /^[a-zA-Z0-9]{6,20}$/;
  682. if (!idRegex.test(id)) {
  683. $toast.error("아이디는 영문, 숫자 조합 6~20자로 입력해주세요.");
  684. return false;
  685. }
  686. }
  687. // 다른 유효성 검사가 필요한 경우 여기에 추가
  688. return true;
  689. }
  690. </script>