index.vue 19 KB

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