index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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. /************************
  134. * data & created
  135. ************************/
  136. // 현재 입력 중인 필드를 설정하는 함수
  137. const setInputField = (name) => {
  138. fnValidCheck(name);
  139. };
  140. const pageId = "login";
  141. const gate1 = ref(false);
  142. const gate2 = ref(false);
  143. const loginVisible = ref("N");
  144. const i18n = useI18n();
  145. // 다국어
  146. let listObj = ref({
  147. langTypeList: {},
  148. });
  149. // 로그인 정보
  150. const loginForm = ref({
  151. userId: "",
  152. passwd: "",
  153. otpNum: "",
  154. username: "",
  155. authType: "GOOGLE",
  156. userAgent: "",
  157. loginType: "",
  158. validCheck: {
  159. input: {
  160. userId: true,
  161. passwd: true,
  162. },
  163. otp: {
  164. otpNum: true,
  165. },
  166. inputErrorCheck: true,
  167. inputValidTxt: "",
  168. otpValidTxt: "",
  169. loginValidCheck: false,
  170. btnTxt: "",
  171. btnTxtType: "",
  172. },
  173. });
  174. // 구글 OTP 1차 팝업
  175. const authPop1 = ref({
  176. popYn: false,
  177. certifyYN: false,
  178. userId: "",
  179. passwd: "",
  180. otpNum: "",
  181. validOtpKey: true,
  182. validOtpTxt: "",
  183. btnTxt: "",
  184. btnTxtType: "",
  185. applyBtn: false,
  186. succOtpYn: false,
  187. businessName: "",
  188. agreeChk1: false,
  189. agreeChk2: false,
  190. validCheck: {
  191. userId: true,
  192. passwd: true,
  193. },
  194. validTxt: "",
  195. errorCheck: false,
  196. });
  197. // 구글 OTP 2차 팝업
  198. const authPop2 = ref({
  199. popYn: false,
  200. otpNum: "",
  201. validOtpKey: true,
  202. validOtpTxt: "",
  203. errorCheck: false,
  204. });
  205. // 아이디 찾기
  206. const findId = ref({
  207. popYn: false,
  208. //tenantName: '',
  209. email: "",
  210. otpNum: "",
  211. validCheck: {
  212. input: {
  213. //tenantName: true,
  214. email: true,
  215. },
  216. otp: {
  217. otpNum: true,
  218. },
  219. inputErrorCheck: true,
  220. inputValidTxt: "",
  221. otpValidTxt: "",
  222. findIdValidCheck: false,
  223. },
  224. btnTxt: "",
  225. });
  226. // 비밀번호 초기화
  227. const resetPw = ref({
  228. popYn: false,
  229. userId: "",
  230. email: "",
  231. otpNum: "",
  232. validCheck: {
  233. input: {
  234. userId: true,
  235. email: true,
  236. },
  237. otp: {
  238. otpNum: true,
  239. },
  240. inputErrorCheck: true,
  241. inputValidTxt: "",
  242. otpValidTxt: "",
  243. resetPwValidCheck: false,
  244. },
  245. btnTxt: "",
  246. });
  247. // 초기 패스워드 변경
  248. const initPw = ref({
  249. popYn: false,
  250. passwd: "",
  251. passwd2: "",
  252. validCheck: {
  253. passwd: true,
  254. passwd2: true,
  255. },
  256. passwdCheck: false,
  257. errorTxt: "",
  258. });
  259. const selectPlaceholder = ref("");
  260. const initAuthPop1 = ref({});
  261. const initAuthPop2 = ref({});
  262. const initFindId = ref({});
  263. const initResetPw = ref({});
  264. const initInitPw = ref({});
  265. const googleOtpQrCode = ref("");
  266. const googleOtpSecretKey = ref("");
  267. const loginInfo = ref({});
  268. const checkbox = ref(false);
  269. const langType = ref("");
  270. const toggleVisibility = () => {
  271. visible.value = !visible.value;
  272. };
  273. const visible = ref(false);
  274. const isAgrNPop = ref(false);
  275. const isShowAgrNPop = ref(false);
  276. let saveId = localStorage.getItem("saveId");
  277. if (saveId) {
  278. checkbox.value = true;
  279. loginForm.value.userId = saveId;
  280. }
  281. // 개인정보처리방침 이용약관 팝업
  282. //const privacyPop = ref(false);
  283. const privacyDetail = ref({
  284. kr: {
  285. title: "",
  286. contents: "",
  287. },
  288. en: {
  289. title: "",
  290. contents: "",
  291. },
  292. });
  293. const systemInfo = ref({
  294. mode: "",
  295. });
  296. const loginAction = (__ID, __PASS) => {
  297. let _req = {
  298. id: __ID,
  299. password: __PASS,
  300. };
  301. useAxios()
  302. .post("/roulette/login", _req)
  303. .then((res) => {
  304. if (res.data) {
  305. // console.log(res.data);
  306. useAuthStore().setAuth(res.data);
  307. useAuthStore().setAccessToken(res.data.accessToken);
  308. useAuthStore().setRefreshToken(res.data.refreshToken);
  309. localStorage.setItem("tempAccess", __ID);
  310. useUtil.setPageMove("/view/item");
  311. useStore.menuInfo.menuIndex = "0";
  312. useStore.menuInfo.menuId = "menu01";
  313. useStore.menuInfo.pageRtName = "제품 관리";
  314. useStore.menuInfo.pageStatus = null;
  315. }
  316. })
  317. .catch((error) => {
  318. if (error.response) {
  319. console.log("status:", error.response.status, "data:", error.response.data);
  320. // 안전하게 errCode, message 접근
  321. const errData = error.response.data || {};
  322. const errCode = errData.errCode || errData.errorCode || errData.code || "";
  323. const errMsg = errData.message || "알 수 없는 오류가 발생했습니다.";
  324. console.log("errCode:", errCode, "message:", errMsg);
  325. } else {
  326. console.log("error:", error.message, error.code);
  327. }
  328. if (error.response?.status) {
  329. fnLoginSet(error.response.data.messages.message);
  330. }
  331. $log.debug("[login][fnIdPwCheck][error]");
  332. })
  333. .finally(() => {
  334. $log.debug("[login][fnIdPwCheck][finished]");
  335. });
  336. };
  337. const location = (__id) => {
  338. switch (__id) {
  339. case "join":
  340. useUtil.setPageMove("/auth/join?type=" + loginForm.value.loginType);
  341. break;
  342. case "findId":
  343. findId.value.popYn = true;
  344. break;
  345. case "resetPw":
  346. resetPw.value.popYn = true;
  347. break;
  348. case "influence":
  349. useUtil.setPageMove("/?type=influence");
  350. loginVisible.value = "N";
  351. break;
  352. case "vendor":
  353. useUtil.setPageMove("/?type=vendor");
  354. loginVisible.value = "N";
  355. break;
  356. default:
  357. break;
  358. }
  359. };
  360. // onMounted
  361. onMounted(() => {
  362. //로그인페이지 접근시 파라미터 체크하여 인플루언서, 밴더 구분
  363. const route = useRoute();
  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. watchEffect(() => {
  410. // 감시하고자 하는 데이터를 해당 블럭내에서 사용하면 호출된다.
  411. // getLang.value를 감시하는 상태
  412. //QfnGetEnumCode(useLangStore().getLang);
  413. });
  414. // $eventBus.off("SET_SUCCESS_POPUP");
  415. // $eventBus.on("SET_SUCCESS_POPUP", () => {
  416. // // 안내 팝업 확인 클릭 팝업 초기화처리
  417. // fnOtpPopClose("findId");
  418. // fnOtpPopClose("resetPw");
  419. // });
  420. // $eventBus.off("PASSWD_CHANGE");
  421. // $eventBus.on("PASSWD_CHANGE", () => {
  422. // fnPasswdChange();
  423. // });
  424. // $eventBus.off("INIT_PASSWORD");
  425. // $eventBus.on("INIT_PASSWORD", () => {
  426. // initPw.value.popYn = true;
  427. // });
  428. // $eventBus.off("SET_LOGIN");
  429. // $eventBus.on("SET_LOGIN", () => {
  430. // fnLogin();
  431. // });
  432. /************************
  433. * Methods
  434. ************************/
  435. const fnLoginSet = (__MSG) => {
  436. let param = {
  437. id: pageId,
  438. title: "로그인",
  439. content: __MSG,
  440. yes: {
  441. text: "확인",
  442. isProc: true,
  443. event: "FN_LOGIN",
  444. param: "",
  445. },
  446. no: {
  447. text: "취소",
  448. isProc: false,
  449. },
  450. };
  451. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  452. };
  453. // 구글 로그인 인증 시퀀스
  454. function onGoogleLogin() {
  455. const appBaseUrl = import.meta.env.VITE_APP_API_DOMAIN;
  456. const clientId =
  457. "373780605211-diojebh7mug45urv9rnqdil6n0b1ogge.apps.googleusercontent.com"; // 실제 클라이언트 ID로 교체
  458. //const redirectUri = "https://shopdeli.mycafe24.com/auth/callback"; // 실제 리디렉션 URI로 교체
  459. const redirectUri = `${appBaseUrl}/auth/callback`;
  460. const scope = "openid email profile";
  461. const responseType = "code"; // 또는 'code' (백엔드 연동 시)
  462. const state = Math.random().toString(36).substring(2);
  463. const googleAuthUrl = `https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&client_id=${clientId}&redirect_uri=${encodeURIComponent(
  464. redirectUri
  465. )}&response_type=${responseType}&scope=${encodeURIComponent(scope)}&state=${state}`;
  466. const width = 500;
  467. const height = 600;
  468. const dualScreenLeft =
  469. window.screenLeft !== undefined ? window.screenLeft : window.screenX;
  470. const dualScreenTop =
  471. window.screenTop !== undefined ? window.screenTop : window.screenY;
  472. const currentWidth = window.innerWidth
  473. ? window.innerWidth
  474. : document.documentElement.clientWidth
  475. ? document.documentElement.clientWidth
  476. : screen.width;
  477. const currentHeight = window.innerHeight
  478. ? window.innerHeight
  479. : document.documentElement.clientHeight
  480. ? document.documentElement.clientHeight
  481. : screen.height;
  482. const left = dualScreenLeft + (currentWidth - width) / 2;
  483. const top = dualScreenTop + (currentHeight - height) / 2;
  484. window.open(
  485. googleAuthUrl,
  486. "googleLogin",
  487. `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  488. );
  489. }
  490. //카카오 인증 시퀀스
  491. function onKakaoLogin() {
  492. const appBaseUrl = import.meta.env.VITE_APP_API_DOMAIN;
  493. const kakaoAuthUrl = `${appBaseUrl}/auth/kakaoLogin`; // 실제 리디렉션 URI로 교체
  494. const width = 500;
  495. const height = 600;
  496. const dualScreenLeft =
  497. window.screenLeft !== undefined ? window.screenLeft : window.screenX;
  498. const dualScreenTop =
  499. window.screenTop !== undefined ? window.screenTop : window.screenY;
  500. const currentWidth = window.innerWidth
  501. ? window.innerWidth
  502. : document.documentElement.clientWidth
  503. ? document.documentElement.clientWidth
  504. : screen.width;
  505. const currentHeight = window.innerHeight
  506. ? window.innerHeight
  507. : document.documentElement.clientHeight
  508. ? document.documentElement.clientHeight
  509. : screen.height;
  510. const left = dualScreenLeft + (currentWidth - width) / 2;
  511. const top = dualScreenTop + (currentHeight - height) / 2;
  512. window.open(
  513. kakaoAuthUrl,
  514. "kakaoLogin",
  515. `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  516. );
  517. }
  518. //네이버 인증 시퀀스
  519. function onNaverLogin() {
  520. const appBaseUrl = import.meta.env.VITE_APP_BASE_URL;
  521. const naverAuthUrl = `${appBaseUrl}/auth/naverLogin`; // 실제 리디렉션 URI로 교체
  522. const width = 500;
  523. const height = 600;
  524. const dualScreenLeft =
  525. window.screenLeft !== undefined ? window.screenLeft : window.screenX;
  526. const dualScreenTop =
  527. window.screenTop !== undefined ? window.screenTop : window.screenY;
  528. const currentWidth = window.innerWidth
  529. ? window.innerWidth
  530. : document.documentElement.clientWidth
  531. ? document.documentElement.clientWidth
  532. : screen.width;
  533. const currentHeight = window.innerHeight
  534. ? window.innerHeight
  535. : document.documentElement.clientHeight
  536. ? document.documentElement.clientHeight
  537. : screen.height;
  538. const left = dualScreenLeft + (currentWidth - width) / 2;
  539. const top = dualScreenTop + (currentHeight - height) / 2;
  540. window.open(
  541. naverAuthUrl,
  542. "naverLogin",
  543. `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  544. );
  545. }
  546. /**
  547. * @API
  548. * 최종 로그인 버튼 클릭 시 API
  549. */
  550. function fnLogin(__USERID, __USERPASS) {
  551. // 파라미터 전달 값 [아이디, 비밀번호, otpNum, 브라우저정보]
  552. //userId: loginForm.value.userId,
  553. // let _req = {
  554. // username: loginForm.value.userId,
  555. // password: btoa(loginForm.value.passwd),
  556. // };
  557. localStorage.setItem("tempAccess", __USERID);
  558. if (__USERID == "admin" && __USERPASS == "1234") {
  559. useUtil.setPageMove("/view/media/newsList");
  560. } else {
  561. fnLoginSet("비밀번호가 맞지 않습니다. 확인해주세요.");
  562. }
  563. // useAxios()
  564. // .post(apiUrl.otpCheck, _req)
  565. // .then((res) => {
  566. // loginInfo.value = res.data.data;
  567. // useAuthStore().setAccessToken(loginInfo.value.accessToken);
  568. // useAuthStore().setRefreshToken(loginInfo.value.refreshToken);
  569. // // OTP key체크 성공 후 개인정보에 대한 API를 호출 한다.
  570. // fnServiceModeCheck();
  571. // $log.debug("[login][fnLogin][success]");
  572. // })
  573. // .catch((error) => {
  574. // $log.debug("[login][fnLogin][error]");
  575. // let errorData = error.response.data;
  576. // errorData.type = "fnLogin";
  577. // fnLoginFail(errorData);
  578. // })
  579. // .finally(() => {
  580. // $log.debug("[login][fnLogin][finished]");
  581. // });
  582. }
  583. </script>