index.vue 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359
  1. <template>
  2. <div class="login-wrap">
  3. <!-- header -->
  4. <div class="login--header">
  5. <div class="login--header--l">
  6. <div class="logo">
  7. <!-- prettier-ignore -->
  8. SHOPDELI
  9. </div>
  10. </div>
  11. <div class="login--header--r"></div>
  12. </div>
  13. <!-- login -->
  14. <div class="login-box">
  15. <div class="login-l">
  16. <div class="login-l-center">
  17. <span class="logo">
  18. <!-- prettier-ignore -->
  19. SHOPDELI
  20. </span>
  21. <!-- <p>We Make Scalable Mobility Life</p> -->
  22. </div>
  23. </div>
  24. <div class="login-r">
  25. <div class="tit-login">
  26. <strong>로그인</strong>
  27. </div>
  28. <div class="login-input-wrap">
  29. <div
  30. class="txt-field-box"
  31. :class="!loginForm.validCheck.input.userId ? 'error' : ''"
  32. >
  33. <v-text-field
  34. v-model="loginForm.userId"
  35. placeholder="아이디를 입력해주세요"
  36. class="custom-input"
  37. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd)"
  38. @input="setInputField('main_userId')"
  39. ></v-text-field>
  40. <i class="ico"></i>
  41. </div>
  42. <div
  43. class="txt-field-box"
  44. :class="!loginForm.validCheck.input.passwd ? 'error' : ''"
  45. >
  46. <v-text-field
  47. v-model="loginForm.passwd"
  48. :type="visible ? 'text' : 'password'"
  49. placeholder="비밀번호를 입력해주세요"
  50. class="custom-input"
  51. id="password"
  52. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd)"
  53. @input="setInputField('main_passwd')"
  54. ></v-text-field>
  55. <i
  56. class="ico-eye"
  57. @click.stop="toggleVisibility"
  58. :class="visible ? 'eye-on' : 'eye-off'"
  59. ></i>
  60. <i class="ico"></i>
  61. </div>
  62. <!-- <p class="error-txt" v-if="!loginForm.validCheck.inputErrorCheck">
  63. {{ loginForm.validCheck.passwd }}
  64. </p> -->
  65. </div>
  66. <div class="login-btn-wrap">
  67. <v-btn
  68. class="custom-btn btn-blue"
  69. @keyup.enter="loginAction(loginForm.userId, loginForm.passwd)"
  70. @click="loginAction(loginForm.userId, loginForm.passwd)"
  71. >로그인</v-btn
  72. >
  73. </div>
  74. <div class="short--login--wrap">
  75. <v-btn class="btn--google" @click="onGoogleLogin"></v-btn>
  76. <v-btn class="btn--kakao"></v-btn>
  77. <v-btn class="btn--naver"></v-btn>
  78. </div>
  79. </div>
  80. </div>
  81. <!-- footer -->
  82. <div class="login-footer">
  83. <div class="login--footer--l">
  84. <p>COPYRIGHT@2025 SHOPDELI INC. ALL RIGHTS RESERVED.</p>
  85. <p>마포구 합정동</p>
  86. </div>
  87. </div>
  88. </div>
  89. </template>
  90. <script setup>
  91. /************************
  92. * import
  93. ************************/
  94. //import PrivacyPop from "@/components/login/privacyPop.vue";
  95. //import AgrNPop from "@/components/terms/agreeNListPop.vue";
  96. import apiUrl from "@/composables/useApi";
  97. import QRCode from "qrcode";
  98. import { useI18n } from "vue-i18n";
  99. /************************
  100. * layout setting
  101. ************************/
  102. definePageMeta({
  103. layout: "loginlayout",
  104. });
  105. /************************
  106. * plugins inject
  107. ************************/
  108. const { $dayjs, $log, $eventBus, $toast, $userAgent } = useNuxtApp();
  109. const useStore = useDetailStore();
  110. /************************
  111. * data & created
  112. ************************/
  113. // 현재 입력 중인 필드를 설정하는 함수
  114. const setInputField = (name) => {
  115. fnValidCheck(name);
  116. };
  117. const pageId = "login";
  118. const i18n = useI18n();
  119. // 다국어
  120. let listObj = ref({
  121. langTypeList: {},
  122. });
  123. // 로그인 정보
  124. const loginForm = ref({
  125. userId: "",
  126. passwd: "",
  127. otpNum: "",
  128. username: "",
  129. authType: "GOOGLE",
  130. userAgent: "",
  131. validCheck: {
  132. input: {
  133. userId: true,
  134. passwd: true,
  135. },
  136. otp: {
  137. otpNum: true,
  138. },
  139. inputErrorCheck: true,
  140. inputValidTxt: "",
  141. otpValidTxt: "",
  142. loginValidCheck: false,
  143. btnTxt: "",
  144. btnTxtType: "",
  145. },
  146. });
  147. // 구글 OTP 1차 팝업
  148. const authPop1 = ref({
  149. popYn: false,
  150. certifyYN: false,
  151. userId: "",
  152. passwd: "",
  153. otpNum: "",
  154. validOtpKey: true,
  155. validOtpTxt: "",
  156. btnTxt: "",
  157. btnTxtType: "",
  158. applyBtn: false,
  159. succOtpYn: false,
  160. businessName: "",
  161. agreeChk1: false,
  162. agreeChk2: false,
  163. validCheck: {
  164. userId: true,
  165. passwd: true,
  166. },
  167. validTxt: "",
  168. errorCheck: false,
  169. });
  170. // 구글 OTP 2차 팝업
  171. const authPop2 = ref({
  172. popYn: false,
  173. otpNum: "",
  174. validOtpKey: true,
  175. validOtpTxt: "",
  176. errorCheck: false,
  177. });
  178. // 아이디 찾기
  179. const findId = ref({
  180. popYn: false,
  181. //tenantName: '',
  182. email: "",
  183. otpNum: "",
  184. validCheck: {
  185. input: {
  186. //tenantName: true,
  187. email: true,
  188. },
  189. otp: {
  190. otpNum: true,
  191. },
  192. inputErrorCheck: true,
  193. inputValidTxt: "",
  194. otpValidTxt: "",
  195. findIdValidCheck: false,
  196. },
  197. btnTxt: "",
  198. });
  199. // 비밀번호 초기화
  200. const resetPw = ref({
  201. popYn: false,
  202. userId: "",
  203. email: "",
  204. otpNum: "",
  205. validCheck: {
  206. input: {
  207. userId: true,
  208. email: true,
  209. },
  210. otp: {
  211. otpNum: true,
  212. },
  213. inputErrorCheck: true,
  214. inputValidTxt: "",
  215. otpValidTxt: "",
  216. resetPwValidCheck: false,
  217. },
  218. btnTxt: "",
  219. });
  220. // 초기 패스워드 변경
  221. const initPw = ref({
  222. popYn: false,
  223. passwd: "",
  224. passwd2: "",
  225. validCheck: {
  226. passwd: true,
  227. passwd2: true,
  228. },
  229. passwdCheck: false,
  230. errorTxt: "",
  231. });
  232. const selectPlaceholder = ref("");
  233. const initAuthPop1 = ref({});
  234. const initAuthPop2 = ref({});
  235. const initFindId = ref({});
  236. const initResetPw = ref({});
  237. const initInitPw = ref({});
  238. const googleOtpQrCode = ref("");
  239. const googleOtpSecretKey = ref("");
  240. const loginInfo = ref({});
  241. const checkbox = ref(false);
  242. const langType = ref("");
  243. const toggleVisibility = () => {
  244. visible.value = !visible.value;
  245. };
  246. const visible = ref(false);
  247. const isAgrNPop = ref(false);
  248. const isShowAgrNPop = ref(false);
  249. let saveId = localStorage.getItem("saveId");
  250. if (saveId) {
  251. checkbox.value = true;
  252. loginForm.value.userId = saveId;
  253. }
  254. // 개인정보처리방침 이용약관 팝업
  255. //const privacyPop = ref(false);
  256. const privacyDetail = ref({
  257. kr: {
  258. title: "",
  259. contents: "",
  260. },
  261. en: {
  262. title: "",
  263. contents: "",
  264. },
  265. });
  266. const systemInfo = ref({
  267. mode: "",
  268. });
  269. const loginAction = (__ID, __PASS) => {
  270. let _req = {
  271. id: __ID,
  272. password: __PASS,
  273. };
  274. useAxios()
  275. .post("/roulette/login", _req)
  276. .then((res) => {
  277. if (res.data) {
  278. useAuthStore().setAuth(res.data);
  279. useAuthStore().setAccessToken(res.data.accessToken);
  280. useAuthStore().setRefreshToken(res.data.refreshToken);
  281. localStorage.setItem("tempAccess", __ID);
  282. useUtil.setPageMove("/view/item");
  283. useStore.menuInfo.menuIndex = "0";
  284. useStore.menuInfo.menuId = "menu01";
  285. useStore.menuInfo.pageRtName = "제품 관리";
  286. useStore.menuInfo.pageStatus = null;
  287. }
  288. })
  289. .catch((error) => {
  290. if (error.response) {
  291. console.log("status:", error.response.status, "data:", error.response.data);
  292. // 안전하게 errCode, message 접근
  293. const errData = error.response.data || {};
  294. const errCode = errData.errCode || errData.errorCode || errData.code || "";
  295. const errMsg = errData.message || "알 수 없는 오류가 발생했습니다.";
  296. console.log("errCode:", errCode, "message:", errMsg);
  297. } else {
  298. console.log("error:", error.message, error.code);
  299. }
  300. if (error.response?.status) {
  301. fnLoginSet(error.response.data.messages.message);
  302. }
  303. $log.debug("[login][fnIdPwCheck][error]");
  304. })
  305. .finally(() => {
  306. $log.debug("[login][fnIdPwCheck][finished]");
  307. });
  308. };
  309. // onMounted
  310. onMounted(() => {
  311. const handler = (event) => {
  312. if (event.origin !== "https://shopdeli.mycafe24.com") return;
  313. if (event.data?.accessToken) {
  314. useAuthStore().setAuth(event.data);
  315. useAuthStore().setAccessToken(event.data.accessToken);
  316. useAuthStore().setRefreshToken(event.data.refreshToken);
  317. localStorage.setItem("tempAccess", event.data.user?.ID);
  318. useUtil.setPageMove("/view/event/evtList");
  319. useStore.menuInfo.menuIndex = "0";
  320. useStore.menuInfo.menuId = "menu02";
  321. useStore.menuInfo.pageRtName = "이벤트 관리";
  322. useStore.menuInfo.pageStatus = null;
  323. }
  324. };
  325. window.addEventListener("message", handler);
  326. onBeforeUnmount(() => window.removeEventListener("message", handler));
  327. });
  328. watchEffect(() => {
  329. // 감시하고자 하는 데이터를 해당 블럭내에서 사용하면 호출된다.
  330. // getLang.value를 감시하는 상태
  331. fnGetEnumCode(useLangStore().getLang);
  332. });
  333. $eventBus.off("SET_SUCCESS_POPUP");
  334. $eventBus.on("SET_SUCCESS_POPUP", () => {
  335. // 안내 팝업 확인 클릭 팝업 초기화처리
  336. fnOtpPopClose("findId");
  337. fnOtpPopClose("resetPw");
  338. });
  339. $eventBus.off("PASSWD_CHANGE");
  340. $eventBus.on("PASSWD_CHANGE", () => {
  341. fnPasswdChange();
  342. });
  343. $eventBus.off("INIT_PASSWORD");
  344. $eventBus.on("INIT_PASSWORD", () => {
  345. initPw.value.popYn = true;
  346. });
  347. $eventBus.off("SET_LOGIN");
  348. $eventBus.on("SET_LOGIN", () => {
  349. fnLogin();
  350. });
  351. /************************
  352. * Methods
  353. ************************/
  354. // created
  355. loginForm.value.btnTxtType = "S";
  356. authPop1.value.btnTxtType = "S";
  357. loginForm.value.btnTxt = i18n.t("login.authNumSend");
  358. authPop1.value.btnTxt = i18n.t("common.sendAuthNumber");
  359. findId.value.btnTxt = i18n.t("common.sendAuthNumber");
  360. resetPw.value.btnTxt = i18n.t("common.sendAuthNumber");
  361. initAuthPop1.value = _cloneDeep(authPop1.value);
  362. initAuthPop2.value = _cloneDeep(authPop2.value);
  363. initFindId.value = _cloneDeep(findId.value);
  364. initResetPw.value = _cloneDeep(resetPw.value);
  365. initInitPw.value = _cloneDeep(initPw.value);
  366. /**
  367. * @SCRIPT
  368. * 다국어 기능 | 한글 영문 변경 이벤트
  369. */
  370. function fnLangChange() {
  371. useLangStore().setLang(langType.value);
  372. }
  373. function fnGetEnumCode(lang) {
  374. lang = useUtil.nvl(lang, "kr");
  375. langType.value = lang;
  376. let objEnum = useEnumCode.getEnumCode(lang);
  377. listObj.value.langTypeList = objEnum.langType;
  378. i18n.locale.value = lang;
  379. }
  380. /**
  381. * @SCRIPT
  382. * 라디오버튼 변경 이벤트 (버튼별 문구)
  383. */
  384. function fnChangeAuth() {
  385. if (loginForm.value.authType === "GOOGLE") {
  386. selectPlaceholder.value = i18n.t("login.googleOTPNum");
  387. } else if (loginForm.value.authType === "EMAIL") {
  388. selectPlaceholder.value = i18n.t("login.emailAuthNum");
  389. } else {
  390. selectPlaceholder.value = i18n.t("login.smsAuthNum");
  391. }
  392. loginForm.value.btnTxt = i18n.t("login.authNumSend");
  393. loginForm.value.btnTxtType = "S";
  394. if (!loginForm.value.validCheck.otp.otpNum) {
  395. fnValidCheck("main_otpNum");
  396. }
  397. }
  398. /**
  399. * @SCRIPT
  400. * 구글OTP 인증 버튼 클릭 이벤트
  401. * @param {*} type
  402. */
  403. function fnAuthCheck(type) {
  404. let issuer = ""; // 회사명
  405. let account = ""; // 아이디
  406. let otpUrl = ""; // 큐알코드 생성 URL
  407. let _req = {
  408. username: authPop1.value.userId,
  409. password: btoa(authPop1.value.passwd),
  410. mfaType: "SMS",
  411. otpNum: authPop1.value.otpNum,
  412. };
  413. if (type === "optApply1") {
  414. fnValidCheck("createOtp_userId");
  415. fnValidCheck("createOtp_passwd");
  416. if (authPop1.value.errorCheck) {
  417. fnAuth("POPUP");
  418. }
  419. } else if (type === "optApply2") {
  420. //OTP 인증 팝업2
  421. useAxios()
  422. .post(apiUrl.googleSecretKey, _req)
  423. .then((res) => {
  424. googleOtpSecretKey.value = res.data.data.secretKey;
  425. // 시크릿 키를 이용한 큐알코드 생성
  426. issuer = "[P5G]" + authPop1.value.businessName;
  427. account = authPop1.value.userId;
  428. otpUrl =
  429. "otpauth://totp/" +
  430. encodeURIComponent(issuer + ":" + account).replace(/\+/g, "%20") +
  431. "?secret=" +
  432. encodeURIComponent(googleOtpSecretKey.value).replace(/\+/g, "%20") +
  433. "&issuer=" +
  434. encodeURIComponent(issuer).replace(/\+/g, "%20");
  435. fnCreateQrCode(otpUrl);
  436. $toast.success("인증처리가 완료되었습니다.");
  437. authPop1.value.applyBtn = false;
  438. authPop1.value.agreeChk1 = true;
  439. authPop1.value.succOtpYn = true;
  440. $log.debug("[login][fnAuthCheck][success]");
  441. })
  442. .catch((error) => {
  443. $log.debug("[login][fnAuthCheck][error]");
  444. let errorData = error.response.data;
  445. errorData.type = "fnAuthCheck";
  446. fnLoginFail(errorData);
  447. })
  448. .finally(() => {
  449. $log.debug("[login][fnAuthCheck][finished]");
  450. });
  451. } else if (type === "optApply2Yn") {
  452. authPop1.value.popYn = false;
  453. authPop2.value.popYn = true;
  454. } else if (type === "findId") {
  455. //fnValidCheck('findId_tenantName')
  456. fnValidCheck("findId_email");
  457. if (findId.value.validCheck.inputErrorCheck) {
  458. fnIdPwCheck(type);
  459. }
  460. } else if (type === "resetPw") {
  461. fnValidCheck("resetPw_userId");
  462. fnValidCheck("resetPw_email");
  463. if (resetPw.value.validCheck.inputErrorCheck) {
  464. fnIdPwCheck(type);
  465. }
  466. } else if (type === "createOtp_otpNum") {
  467. // 구글OTP등록화면에서 인증번호 받기
  468. fnAuthSend(authPop1.value.btnTxtType, "createOtp_otpNum");
  469. } else {
  470. fnValidCheck("main_userId");
  471. fnValidCheck("main_passwd");
  472. if (loginForm.value.validCheck.inputErrorCheck) {
  473. fnAuth(type);
  474. }
  475. }
  476. }
  477. /**
  478. * @SCRIPT
  479. * 큐알코드 생성
  480. * @param {*} otpUrl
  481. */
  482. async function fnCreateQrCode(otpUrl) {
  483. googleOtpQrCode.value = await QRCode.toDataURL(otpUrl);
  484. }
  485. /**
  486. * @SCRIPT
  487. * 로그인 실패관련 토스트 & confirm 처리
  488. */
  489. function fnLoginFail(dataObj) {
  490. let errorMessage = "";
  491. let type = dataObj.type;
  492. if (dataObj.code === "2001" || dataObj.code === "2002") {
  493. let valieTxt = "";
  494. if (!useUtil.isNull(dataObj.reason)) {
  495. if (dataObj.reason < "4") {
  496. valieTxt += i18n.t("login.valid.isNullPw");
  497. } else {
  498. // 4회 이상 비밀번호 실패
  499. fnLoginFailConfirm(dataObj);
  500. }
  501. } else {
  502. valieTxt += i18n.t("login.valid.isNullId");
  503. }
  504. console.log("비밀번호 초기화 팝업:::" + resetPw.value.popYn);
  505. console.log("아이디찾기 팝업:::" + findId.value.popYn);
  506. console.log("OTP생성 팝업:::" + authPop1.value.popYn);
  507. if (resetPw.value.popYn) {
  508. resetPw.value.validCheck.inputErrorCheck = false;
  509. resetPw.value.validCheck.inputValidTxt = valieTxt;
  510. } else if (findId.value.popYn) {
  511. findId.value.validCheck.inputErrorCheck = false;
  512. findId.value.validCheck.inputValidTxt = valieTxt;
  513. } else if (authPop1.value.popYn) {
  514. authPop1.value.errorCheck = false;
  515. authPop1.value.validTxt = valieTxt;
  516. } else {
  517. loginForm.value.validCheck.inputErrorCheck = false;
  518. loginForm.value.validCheck.inputValidTxt = valieTxt;
  519. }
  520. } else if (dataObj.code === "2003") {
  521. let otpTxt = "";
  522. if (loginForm.value.authType === "GOOGLE") {
  523. otpTxt += i18n.t("login.valid.isNullOtp");
  524. } else if (loginForm.value.authType === "EMAIL") {
  525. otpTxt += i18n.t("login.valid.isNullEmail");
  526. } else {
  527. otpTxt += i18n.t("login.valid.isNullSms");
  528. }
  529. if (resetPw.value.popYn) {
  530. resetPw.value.validCheck.otp.otpNum = false;
  531. resetPw.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullEmail");
  532. } else if (findId.value.popYn) {
  533. findId.value.validCheck.otp.otpNum = false;
  534. findId.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullEmail");
  535. } else if (authPop1.value.popYn) {
  536. authPop1.value.validOtpKey = false;
  537. authPop1.value.validOtpTxt = i18n.t("login.valid.isNullSms");
  538. } else {
  539. loginForm.value.validCheck.otp.otpNum = false;
  540. loginForm.value.validCheck.otpValidTxt = otpTxt;
  541. }
  542. } else if (
  543. dataObj.code === "2004" ||
  544. dataObj.code === "2005" ||
  545. dataObj.code === "2006" ||
  546. dataObj.code === "2007" ||
  547. dataObj.code === "2010"
  548. ) {
  549. // 2004: 접속허용IP아님 , 2005: 사업자 접속불가 상태, 2006: 사업자 계약 만료, 2007: 접속 계정 수 초과, 2010: 계정 잠김 (비밀번호 틀림 N 회) 5회 이상 비밀번호 실패
  550. fnLoginFailConfirm(dataObj);
  551. }
  552. if (!useUtil.isNull(errorMessage)) {
  553. // 토스트 함수 (success, info, error, warn, dark)
  554. if (type === "findId" || type === "resetPw")
  555. errorMessage += i18n.t("login.failMessage.2001");
  556. else errorMessage += i18n.t("login.valid.isNull");
  557. nextTick().then(() => {
  558. $toast.error(errorMessage);
  559. });
  560. }
  561. }
  562. /**
  563. * @SCRIPT
  564. * 로그인 실패관련 토스트 & confirm 처리
  565. */
  566. function fnLoginFailConfirm(dataObj) {
  567. let confirmMessage = "";
  568. if (dataObj.code === "2002") confirmMessage = i18n.t("login.failMessage.2002");
  569. else if (dataObj.code === "2004") confirmMessage = i18n.t("login.failMessage.2004");
  570. else if (dataObj.code === "2005") confirmMessage = i18n.t("login.failMessage.2005");
  571. else if (dataObj.code === "2006") confirmMessage = i18n.t("login.failMessage.2006");
  572. else if (dataObj.code === "2007") confirmMessage = i18n.t("login.failMessage.2007");
  573. else if (dataObj.code === "2010") confirmMessage = i18n.t("login.failMessage.2010");
  574. let param = {
  575. id: pageId,
  576. title: i18n.t("common.popTitle"),
  577. content: confirmMessage,
  578. yes: {
  579. text: i18n.t("common.confirm"),
  580. isProc: true,
  581. event: "",
  582. param: {},
  583. },
  584. };
  585. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  586. }
  587. /**
  588. * @SCRIPT
  589. * 아이디 저장 체크 이벤트
  590. */
  591. function fnSaveId() {
  592. if (checkbox.value) {
  593. // 체크 시 저장
  594. localStorage.setItem("saveId", loginForm.value.userId);
  595. } else {
  596. // 미체크 시 삭제
  597. localStorage.removeItem("saveId");
  598. }
  599. }
  600. /**
  601. * @API
  602. * 아이디 찾기에서 사업자명 & 이메일 주소 체크 API
  603. * 비밀번호 초기화에서 사용자계정 & 이메일 주소 체크 API
  604. */
  605. function fnIdPwCheck(type) {
  606. let _req = {};
  607. if (type === "findId") {
  608. //_req.tenantName = findId.value.tenantName,
  609. _req.email = findId.value.email;
  610. } else {
  611. (_req.accountId = resetPw.value.userId), (_req.email = resetPw.value.email);
  612. }
  613. useAxios()
  614. .post(apiUrl.findCheck, _req)
  615. .then((res) => {
  616. if (type === "findId") {
  617. findId.value.btnTxt = i18n.t("common.sendReAuthNumber");
  618. } else {
  619. resetPw.value.btnTxt = i18n.t("common.sendReAuthNumber");
  620. }
  621. $toast.success(i18n.t("login.sendEmail"));
  622. $log.debug("[login][fnIdPwCheck][success]");
  623. })
  624. .catch((error) => {
  625. let errorData = error.response.data;
  626. errorData.type = type;
  627. fnLoginFail(errorData);
  628. $log.debug("[login][fnIdPwCheck][error]");
  629. })
  630. .finally(() => {
  631. $log.debug("[login][fnIdPwCheck][finished]");
  632. });
  633. }
  634. /**
  635. * @API
  636. * 가입된 아이디 비밀번호 체크 API
  637. */
  638. function fnAuth(type) {
  639. let _req = {};
  640. if (type === "POPUP") {
  641. _req.username = authPop1.value.userId;
  642. _req.password = btoa(authPop1.value.passwd);
  643. } else {
  644. _req.username = loginForm.value.userId;
  645. _req.password = btoa(loginForm.value.passwd);
  646. }
  647. // 아이디&비밀번호 validation체크 정상일 경우 아이디 비밀번호를 체크 하는 API를 진행한다.
  648. useAxios()
  649. .post(apiUrl.idPwCheck, _req)
  650. .then((res) => {
  651. if (type === "GOOGLE") {
  652. fnLogin();
  653. } else if (type === "POPUP") {
  654. // if(useUtil.isNull(res.data.data.tenantName)) {
  655. // authPop1.value.businessName = ''
  656. // } else {
  657. // authPop1.value.businessName = res.data.data.tenantName
  658. // }
  659. // 아이디 비밀번호 입력 영역 비활성화
  660. authPop1.value.certifyYN = true;
  661. //authPop1.value.agreeChk1 = true
  662. } else {
  663. // 아이디&비밀번호가 존재하여 이메일 발송을 진행합니다.
  664. fnAuthSend(loginForm.value.btnTxtType, "loginForm");
  665. }
  666. $log.debug("[login][fnAuth][success]");
  667. })
  668. .catch((error) => {
  669. let errorData = error.response.data;
  670. errorData.type = type;
  671. fnLoginFail(errorData);
  672. $log.debug("[login][fnAuth][error]");
  673. })
  674. .finally(() => {
  675. $log.debug("[login][fnAuth][finished]");
  676. });
  677. }
  678. /**
  679. * @API
  680. * 가입된 아이디 비밀번호 체크가 정상 일 경우 인증번호 발송
  681. * 이메일(EMAIL) & 문자(SMS)
  682. */
  683. function fnAuthSend(type, form) {
  684. let _req = {};
  685. if (form === "loginForm") {
  686. (_req.username = loginForm.value.userId),
  687. (_req.password = btoa(loginForm.value.passwd)),
  688. (_req.mfaType = loginForm.value.authType);
  689. } else {
  690. (_req.username = authPop1.value.userId),
  691. (_req.password = btoa(authPop1.value.passwd)),
  692. (_req.mfaType = "SMS");
  693. }
  694. useAxios()
  695. .post(apiUrl.otpSend, _req)
  696. .then((res) => {
  697. if (form === "loginForm") {
  698. loginForm.value.btnTxt = i18n.t("login.authNumReSend");
  699. loginForm.value.btnTxtType = "R";
  700. } else {
  701. authPop1.value.btnTxt = i18n.t("login.authNumReSend");
  702. authPop1.value.btnTxtType = "R";
  703. }
  704. if (type === "S") {
  705. if (form === "loginForm") {
  706. if (loginForm.value.authType === "EMAIL") {
  707. $toast.success(i18n.t("login.sendEmail"));
  708. } else {
  709. $toast.success(i18n.t("login.sendSms"));
  710. }
  711. } else {
  712. $toast.success(i18n.t("login.sendSms"));
  713. }
  714. } else {
  715. if (form === "loginForm") {
  716. if (loginForm.value.authType === "EMAIL") {
  717. $toast.success(i18n.t("login.sendReEmail"));
  718. } else {
  719. $toast.success(i18n.t("login.sendReSms"));
  720. }
  721. } else {
  722. $toast.success(i18n.t("login.sendReSms"));
  723. }
  724. }
  725. $log.debug("[login][fnAuthSend][success]");
  726. })
  727. .catch((error) => {
  728. $log.debug("[login][fnAuthSend][error]");
  729. // 에러 메시지 체크 팝업으로 변경
  730. let param = {
  731. id: pageId,
  732. title: i18n.t("common.popTitle"),
  733. content: i18n.t("login.sendFail"),
  734. yes: {
  735. text: i18n.t("common.confirm"),
  736. isProc: true,
  737. event: "",
  738. param: {},
  739. },
  740. };
  741. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  742. // let errorMessage = i18n.t('login.sendFail')
  743. // errorMessage += error.response.data.message
  744. // $toast.error(errorMessage)
  745. })
  746. .finally(() => {
  747. $log.debug("[login][fnAuthSend][finished]");
  748. });
  749. }
  750. const fnLoginSet = (__MSG) => {
  751. let param = {
  752. id: pageId,
  753. title: "로그인",
  754. content: __MSG,
  755. yes: {
  756. text: "확인",
  757. isProc: true,
  758. event: "FN_LOGIN",
  759. param: "",
  760. },
  761. no: {
  762. text: "취소",
  763. isProc: false,
  764. },
  765. };
  766. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  767. };
  768. // 구글 로그인 버튼 클릭 시 호출
  769. function onGoogleLogin() {
  770. const clientId =
  771. "373780605211-diojebh7mug45urv9rnqdil6n0b1ogge.apps.googleusercontent.com"; // 실제 클라이언트 ID로 교체
  772. const redirectUri = "https://shopdeli.mycafe24.com/auth/callback"; // 실제 리디렉션 URI로 교체
  773. const scope = "openid email profile";
  774. const responseType = "code"; // 또는 'code' (백엔드 연동 시)
  775. const state = Math.random().toString(36).substring(2);
  776. const googleAuthUrl = `https://accounts.google.com/o/oauth2/v2/auth?client_id=${clientId}&redirect_uri=${encodeURIComponent(
  777. redirectUri
  778. )}&response_type=${responseType}&scope=${encodeURIComponent(scope)}&state=${state}`;
  779. const width = 500;
  780. const height = 600;
  781. const dualScreenLeft =
  782. window.screenLeft !== undefined ? window.screenLeft : window.screenX;
  783. const dualScreenTop =
  784. window.screenTop !== undefined ? window.screenTop : window.screenY;
  785. const currentWidth = window.innerWidth
  786. ? window.innerWidth
  787. : document.documentElement.clientWidth
  788. ? document.documentElement.clientWidth
  789. : screen.width;
  790. const currentHeight = window.innerHeight
  791. ? window.innerHeight
  792. : document.documentElement.clientHeight
  793. ? document.documentElement.clientHeight
  794. : screen.height;
  795. const left = dualScreenLeft + (currentWidth - width) / 2;
  796. const top = dualScreenTop + (currentHeight - height) / 2;
  797. window.open(
  798. googleAuthUrl,
  799. "googleLogin",
  800. `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes`
  801. );
  802. }
  803. /**
  804. * @API
  805. * 최종 로그인 버튼 클릭 시 API
  806. */
  807. function fnLogin(__USERID, __USERPASS) {
  808. // 파라미터 전달 값 [아이디, 비밀번호, otpNum, 브라우저정보]
  809. //userId: loginForm.value.userId,
  810. // let _req = {
  811. // username: loginForm.value.userId,
  812. // password: btoa(loginForm.value.passwd),
  813. // };
  814. localStorage.setItem("tempAccess", __USERID);
  815. if (__USERID == "admin" && __USERPASS == "1234") {
  816. useUtil.setPageMove("/view/media/newsList");
  817. } else {
  818. fnLoginSet("비밀번호가 맞지 않습니다. 확인해주세요.");
  819. }
  820. // useAxios()
  821. // .post(apiUrl.otpCheck, _req)
  822. // .then((res) => {
  823. // loginInfo.value = res.data.data;
  824. // useAuthStore().setAccessToken(loginInfo.value.accessToken);
  825. // useAuthStore().setRefreshToken(loginInfo.value.refreshToken);
  826. // // OTP key체크 성공 후 개인정보에 대한 API를 호출 한다.
  827. // fnServiceModeCheck();
  828. // $log.debug("[login][fnLogin][success]");
  829. // })
  830. // .catch((error) => {
  831. // $log.debug("[login][fnLogin][error]");
  832. // let errorData = error.response.data;
  833. // errorData.type = "fnLogin";
  834. // fnLoginFail(errorData);
  835. // })
  836. // .finally(() => {
  837. // $log.debug("[login][fnLogin][finished]");
  838. // });
  839. }
  840. /**
  841. * @API
  842. * 최종 로그인 전 점검공지에 대한 정보를 가져온다.
  843. */
  844. function fnServiceModeCheck() {
  845. useAxios()
  846. .get(useApi.getServiceMode)
  847. .then((res) => {
  848. $log.debug("[login][fnServiceModeCheck][success]");
  849. let data = res.data.data;
  850. systemInfo.value.mode = data.mode;
  851. fnMyInfo();
  852. })
  853. .catch((error) => {
  854. $log.debug("[login][fnServiceModeCheck][error]");
  855. useErrorHandler().fnSetCommErrorHandle(error);
  856. })
  857. .finally(() => {
  858. $log.debug("[login][fnServiceModeCheck][finished]");
  859. });
  860. }
  861. /**
  862. * @API
  863. * 최종 로그인 버튼 클릭 후 성공 시 토큰값을 통해 개인정보 API 호출
  864. */
  865. function fnMyInfo() {
  866. useAxios()
  867. .get(apiUrl.myInfo)
  868. .then((res) => {
  869. let dataObj = {};
  870. dataObj = res.data.data;
  871. dataObj.accessToken = useAuthStore().getAccessToken;
  872. dataObj.refreshToken = useAuthStore().getRefreshToken;
  873. useAuthStore().setServiceMode(systemInfo.value.mode);
  874. useAuthStore().setAuth(dataObj);
  875. // 아이디 저장 여부 체크
  876. fnSaveId();
  877. let accountValue = useAuthStore().getAccountRole.charAt(0).toUpperCase();
  878. // 첫화면 redirect_page URL로 설정
  879. // 초기 비밀번호 사용
  880. if (useAuthStore().getFirstLoginYn === "Y") {
  881. // 최초로그인
  882. initPw.value.popYn = true;
  883. } else if (useAuthStore().getPwExpiredYN === "Y") {
  884. // 비밀번호 3개월 만료
  885. let param = {
  886. id: pageId,
  887. title: i18n.t("common.popTitle"),
  888. content: i18n.t("login.failMessage.2009"),
  889. yes: {
  890. text: i18n.t("common.confirm"),
  891. isProc: true,
  892. event: "INIT_PASSWORD", // 확인 클릭 시 비밀번호 변경 팝업 활성화
  893. param: {},
  894. },
  895. no: {
  896. text: i18n.t("common.skip"),
  897. isProc: true,
  898. event: "SET_LOGIN", // 건너뛰기 클릭 시 로그인 처리
  899. param: {},
  900. },
  901. };
  902. $eventBus.emit("OPEN_CONFIRM_POP_UP", param);
  903. } else if (useAuthStore().getTermsArgYN === "N") {
  904. // 필수약관동의여부
  905. isShowAgrNPop.value = true;
  906. nextTick().then(() => {
  907. isAgrNPop.value = true;
  908. });
  909. } else {
  910. if (systemInfo.value.mode === "INACTIVE") {
  911. // 점검모드일 경우 점검모드 페이지로 이동
  912. if (accountValue === "S") {
  913. useUtil.setPageMove("/view/home/dashboard");
  914. } else {
  915. useUtil.setPageMove("/view/home/serviceMode");
  916. }
  917. } else {
  918. if (accountValue === "A" || accountValue === "S") {
  919. useUtil.setPageMove("/view/home/dashboard");
  920. } else {
  921. useUtil.setPageMove("/view/home/tenantDashboard");
  922. }
  923. }
  924. }
  925. $log.debug("[login][fnMyInfo][success]");
  926. })
  927. .catch((error) => {
  928. $log.debug("[login][fnMyInfo][error]");
  929. useErrorHandler().fnSetCommErrorHandle(error);
  930. })
  931. .finally(() => {
  932. $log.debug("[login][fnMyInfo][finished]");
  933. });
  934. }
  935. /**
  936. * @API
  937. * 최초 비밀번호 변경 API 호출
  938. */
  939. function fnPasswdChange() {
  940. let _req = {
  941. newPassword: btoa(initPw.value.passwd2),
  942. };
  943. useAxios()
  944. .post(apiUrl.myInfoUpdate, _req)
  945. .then((res) => {
  946. localStorage.removeItem("authStore");
  947. // 세션 초기화 및 로그인 화면 이동
  948. useUtil.setPageMove("/");
  949. $log.debug("[login][fnPasswdChange][success]");
  950. })
  951. .catch((error) => {
  952. $log.debug("[login][fnPasswdChange][error]");
  953. let errorData = error.response.data;
  954. errorData.type = "fnPasswdChange";
  955. fnLoginFail(errorData);
  956. })
  957. .finally(() => {
  958. $log.debug("[login][fnPasswdChange][finished]");
  959. });
  960. }
  961. /**
  962. * @API
  963. * 로그인 FOOTER 약관 조회 API
  964. */
  965. function fnPrivacy(type) {
  966. let _req = {
  967. termsType: useUtil.nvl(type, null),
  968. };
  969. useAxios()
  970. .get(apiUrl.loginTerms, { params: _req })
  971. .then((res) => {
  972. let dataObj = res.data.data;
  973. privacyDetail.value.kr.title = dataObj.termsTitle;
  974. privacyDetail.value.kr.contents = dataObj.termsCont;
  975. privacyDetail.value.en.title = dataObj.termsTitleEn;
  976. privacyDetail.value.en.contents = dataObj.termsContEn;
  977. privacyPop.value = true;
  978. })
  979. .catch((error) => {
  980. $log.debug("[login][fnPrivacy][error]");
  981. useErrorHandler().fnSetCommErrorHandle(error, fnPrivacy);
  982. })
  983. .finally(() => {
  984. $log.debug("[login][fnPrivacy][finished]");
  985. });
  986. }
  987. /**
  988. * @SCRIPT
  989. * 아이디 & 비밀번호 & otp 값의 유효성 검사 체크 및 로그인 버튼 활성화 이벤트
  990. */
  991. function fnValidCheck(input) {
  992. if (_includes(input, "main_")) {
  993. let commonValidCheck = {
  994. inputCheck: false,
  995. otpCheck: false,
  996. };
  997. if (input === "main_userId") {
  998. if (
  999. useUtil.isNull(loginForm.value.userId) ||
  1000. !/^[a-zA-Z0-9._-]{1,20}$/.test(loginForm.value.userId)
  1001. ) {
  1002. loginForm.value.validCheck.input.userId = false;
  1003. loginForm.value.validCheck.inputValidTxt = i18n.t("login.valid.isNull");
  1004. } else {
  1005. loginForm.value.validCheck.input.userId = true;
  1006. if (!useUtil.isNull(loginForm.value.passwd)) {
  1007. fnValidCheck("main_passwd");
  1008. }
  1009. }
  1010. } else if (input === "main_passwd") {
  1011. if (
  1012. useUtil.isNull(loginForm.value.passwd) ||
  1013. !/^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{8,30}$/i.test(
  1014. loginForm.value.passwd
  1015. )
  1016. ) {
  1017. //if(useUtil.isNull(loginForm.value.passwd)) {
  1018. loginForm.value.validCheck.input.passwd = false;
  1019. loginForm.value.validCheck.inputValidTxt = i18n.t("login.valid.isNull");
  1020. } else {
  1021. loginForm.value.validCheck.input.passwd = true;
  1022. }
  1023. } else if (input === "main_otpNum") {
  1024. loginForm.value.otpNum = useValid.p5gNumCheck(loginForm.value.otpNum, "otp");
  1025. if (
  1026. useUtil.isNull(loginForm.value.otpNum) ||
  1027. loginForm.value.otpNum.length <= 5
  1028. ) {
  1029. loginForm.value.validCheck.otp.otpNum = false;
  1030. if (loginForm.value.authType === "GOOGLE") {
  1031. loginForm.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullOtp");
  1032. } else if (loginForm.value.authType === "EMAIL") {
  1033. loginForm.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullEmail");
  1034. } else {
  1035. loginForm.value.validCheck.otpValidTxt = i18n.t("login.valid.isNullSms");
  1036. }
  1037. } else {
  1038. loginForm.value.validCheck.otp.otpNum = true;
  1039. }
  1040. }
  1041. loginForm.value.validCheck.inputErrorCheck = _every(
  1042. loginForm.value.validCheck.input,
  1043. (value) => value === true
  1044. );
  1045. // 전체 항목에 대한 validation이 정상일 경우 login버튼 활성화
  1046. if (
  1047. !useUtil.isNull(loginForm.value.userId) &&
  1048. !useUtil.isNull(loginForm.value.passwd) &&
  1049. !useUtil.isNull(loginForm.value.otpNum)
  1050. ) {
  1051. commonValidCheck.inputCheck = _every(
  1052. loginForm.value.validCheck.input,
  1053. (value) => value === true
  1054. );
  1055. commonValidCheck.otpCheck = _every(
  1056. loginForm.value.validCheck.otp,
  1057. (value) => value === true
  1058. );
  1059. }
  1060. loginForm.value.validCheck.loginValidCheck = _every(
  1061. commonValidCheck,
  1062. (value) => value === true
  1063. );
  1064. } else if (_includes(input, "createOtp_")) {
  1065. if (input === "createOtp_userId") {
  1066. if (
  1067. useUtil.isNull(authPop1.value.userId) ||
  1068. !/^[a-zA-Z0-9._-]{1,20}$/.test(authPop1.value.userId)
  1069. ) {
  1070. authPop1.value.validCheck.userId = false;
  1071. authPop1.value.validTxt = i18n.t("login.valid.isNull");
  1072. } else {
  1073. authPop1.value.validCheck.userId = true;
  1074. if (!useUtil.isNull(authPop1.value.passwd)) {
  1075. fnValidCheck("createOtp_passwd");
  1076. }
  1077. }
  1078. } else if (input === "createOtp_passwd") {
  1079. if (
  1080. useUtil.isNull(authPop1.value.passwd) ||
  1081. !/^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{8,30}$/i.test(
  1082. authPop1.value.passwd
  1083. )
  1084. ) {
  1085. //if(useUtil.isNull(authPop1.value.passwd)) {
  1086. authPop1.value.validCheck.passwd = false;
  1087. authPop1.value.validTxt = i18n.t("login.valid.isNull");
  1088. } else {
  1089. authPop1.value.validCheck.passwd = true;
  1090. }
  1091. } else if (input === "createOtp_otpNum1") {
  1092. authPop1.value.otpNum = useValid.p5gNumCheck(authPop1.value.otpNum, "otp");
  1093. if (useUtil.isNull(authPop1.value.otpNum) || authPop1.value.otpNum.length <= 5) {
  1094. authPop1.value.validOtpKey = false;
  1095. authPop1.value.errorCheck = false;
  1096. authPop1.value.validOtpTxt = i18n.t("login.valid.isNullSms");
  1097. } else {
  1098. authPop1.value.validOtpKey = true;
  1099. authPop1.value.errorCheck = true;
  1100. authPop1.value.applyBtn = true;
  1101. }
  1102. } else if (input === "createOtp_otpNum") {
  1103. authPop2.value.otpNum = useValid.p5gNumCheck(authPop2.value.otpNum, "otp");
  1104. if (useUtil.isNull(authPop2.value.otpNum) || authPop2.value.otpNum.length <= 5) {
  1105. authPop2.value.validOtpKey = false;
  1106. authPop2.value.errorCheck = false;
  1107. if (loginForm.value.authType === "GOOGLE") {
  1108. authPop2.value.validOtpTxt = i18n.t("login.valid.isNullOtp");
  1109. } else if (loginForm.value.authType === "EMAIL") {
  1110. authPop2.value.validOtpTxt = i18n.t("login.valid.isNullEmail");
  1111. } else {
  1112. authPop2.value.validOtpTxt = i18n.t("login.valid.isNullSms");
  1113. }
  1114. } else {
  1115. authPop2.value.validOtpKey = true;
  1116. authPop2.value.errorCheck = true;
  1117. }
  1118. }
  1119. authPop1.value.errorCheck = _every(
  1120. authPop1.value.validCheck,
  1121. (value) => value === true
  1122. );
  1123. } else if (_includes(input, "findId_")) {
  1124. let validAllCheck = {
  1125. inputCheck: false,
  1126. otpCheck: false,
  1127. };
  1128. // if(input === 'findId_tenantName') {
  1129. // if(useUtil.isNull(findId.value.tenantName)) {
  1130. // findId.value.validCheck.input.tenantName = false
  1131. // findId.value.validCheck.inputValidTxt = i18n.t('login.findId.valid.isNullTenantName')
  1132. // } else {
  1133. // findId.value.validCheck.input.tenantName = true
  1134. // if(!useUtil.isNull(findId.value.email)) {
  1135. // fnValidCheck('findId_email')
  1136. // }
  1137. // }
  1138. // } else
  1139. if (input === "findId_email") {
  1140. if (useUtil.isNull(findId.value.email)) {
  1141. findId.value.validCheck.input.email = false;
  1142. findId.value.validCheck.inputValidTxt = i18n.t(
  1143. "login.findId.valid.isNullEmail"
  1144. );
  1145. } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(findId.value.email)) {
  1146. findId.value.validCheck.input.email = false;
  1147. findId.value.validCheck.inputValidTxt = i18n.t(
  1148. "login.findId.valid.isTypeEmail"
  1149. );
  1150. } else {
  1151. findId.value.validCheck.input.email = true;
  1152. }
  1153. } else if (input === "findId_otpNum") {
  1154. findId.value.otpNum = useValid.p5gNumCheck(findId.value.otpNum, "otp");
  1155. if (useUtil.isNull(findId.value.otpNum) || findId.value.otpNum.length <= 5) {
  1156. findId.value.validCheck.otp.otpNum = false;
  1157. findId.value.validCheck.otpValidTxt = i18n.t("login.findId.valid.isNullOtp");
  1158. } else {
  1159. findId.value.validCheck.otp.otpNum = true;
  1160. }
  1161. }
  1162. // tenantName & email validation check
  1163. findId.value.validCheck.inputErrorCheck = _every(
  1164. findId.value.validCheck.input,
  1165. (value) => value === true
  1166. );
  1167. //!useUtil.isNull(findId.value.tenantName) &&
  1168. if (!useUtil.isNull(findId.value.email) && !useUtil.isNull(findId.value.otpNum)) {
  1169. validAllCheck.inputCheck = findId.value.validCheck.inputErrorCheck;
  1170. validAllCheck.otpCheck = findId.value.validCheck.otp.otpNum;
  1171. }
  1172. findId.value.validCheck.findIdValidCheck = _every(
  1173. validAllCheck,
  1174. (value) => value === true
  1175. );
  1176. } else if (_includes(input, "resetPw_")) {
  1177. let validAllCheck = {
  1178. inputCheck: false,
  1179. otpCheck: false,
  1180. };
  1181. if (input === "resetPw_userId") {
  1182. if (useUtil.isNull(resetPw.value.userId)) {
  1183. resetPw.value.validCheck.input.userId = false;
  1184. resetPw.value.validCheck.inputValidTxt = i18n.t(
  1185. "login.resetPasswd.valid.isNullUserId"
  1186. );
  1187. } else {
  1188. resetPw.value.validCheck.input.userId = true;
  1189. if (!useUtil.isNull(resetPw.value.email)) {
  1190. fnValidCheck("resetPw_email");
  1191. }
  1192. }
  1193. } else if (input === "resetPw_email") {
  1194. if (useUtil.isNull(resetPw.value.email)) {
  1195. resetPw.value.validCheck.input.email = false;
  1196. resetPw.value.validCheck.inputValidTxt = i18n.t(
  1197. "login.resetPasswd.valid.isNullEmail"
  1198. );
  1199. } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(resetPw.value.email)) {
  1200. resetPw.value.validCheck.input.email = false;
  1201. resetPw.value.validCheck.inputValidTxt = i18n.t(
  1202. "login.resetPasswd.valid.isTypeEmail"
  1203. );
  1204. } else {
  1205. resetPw.value.validCheck.input.email = true;
  1206. }
  1207. } else if (input === "resetPw_otpNum") {
  1208. resetPw.value.otpNum = useValid.p5gNumCheck(resetPw.value.otpNum, "otp");
  1209. if (useUtil.isNull(resetPw.value.otpNum) || resetPw.value.otpNum.length <= 5) {
  1210. resetPw.value.validCheck.otp.otpNum = false;
  1211. resetPw.value.validCheck.otpValidTxt = i18n.t(
  1212. "login.resetPasswd.valid.isNullOtp"
  1213. );
  1214. } else {
  1215. resetPw.value.validCheck.otp.otpNum = true;
  1216. }
  1217. }
  1218. // tenantName & email validation check
  1219. resetPw.value.validCheck.inputErrorCheck = _every(
  1220. resetPw.value.validCheck.input,
  1221. (value) => value === true
  1222. );
  1223. if (
  1224. !useUtil.isNull(resetPw.value.userId) &&
  1225. !useUtil.isNull(resetPw.value.email) &&
  1226. !useUtil.isNull(resetPw.value.otpNum)
  1227. ) {
  1228. validAllCheck.inputCheck = resetPw.value.validCheck.inputErrorCheck;
  1229. validAllCheck.otpCheck = resetPw.value.validCheck.otp.otpNum;
  1230. }
  1231. resetPw.value.validCheck.resetPwValidCheck = _every(
  1232. validAllCheck,
  1233. (value) => value === true
  1234. );
  1235. } else {
  1236. if (input === "initPw_passwd") {
  1237. let digits1 = useAuthStore().getAuth.phoneNumber.replace(/\D/g, "");
  1238. let digits2 = initPw.value.passwd.replace(/\D/g, "");
  1239. let lastEightDigits1 = digits1.slice(-8);
  1240. let lastEightDigits2 = digits2.slice(-8);
  1241. if (useUtil.isNull(initPw.value.passwd)) {
  1242. initPw.value.validCheck.passwd = false;
  1243. initPw.value.errorTxt = i18n.t("login.valid.isNullNewPassword");
  1244. } else if (_includes(initPw.value.passwd, useAuthStore().getAuth.accountId)) {
  1245. // 아이디는 비밀번호로 사용할 수 없습니다.
  1246. initPw.value.validCheck.passwd = false;
  1247. initPw.value.errorTxt = i18n.t(
  1248. "common.header.myInfoUpdateModal.valid.includeId"
  1249. );
  1250. } else if (lastEightDigits1 === lastEightDigits2) {
  1251. // 연락처와 유사한 비밀번호는 사용할 수 없습니다.
  1252. initPw.value.validCheck.passwd = false;
  1253. initPw.value.errorTxt = i18n.t(
  1254. "common.header.myInfoUpdateModal.valid.includePhone"
  1255. );
  1256. } else if (/(.)\1{2,}/.test(initPw.value.passwd)) {
  1257. // 3자리 이상 연속 숫자, 문자는 사용 불가합니다.
  1258. initPw.value.validCheck.passwd = false;
  1259. initPw.value.errorTxt = i18n.t(
  1260. "common.header.myInfoUpdateModal.valid.continuousUse"
  1261. );
  1262. } else if (
  1263. !/^(?=.*[a-zA-Z])(?=.*[!@#$%^*+=-])(?=.*[0-9]).{8,30}$/i.test(
  1264. initPw.value.passwd
  1265. )
  1266. ) {
  1267. // 비밀번호는 문자,숫자,특수문자 조합 8~30자리로입력
  1268. initPw.value.validCheck.passwd = false;
  1269. initPw.value.errorTxt = i18n.t(
  1270. "common.header.myInfoUpdateModal.valid.validPassword"
  1271. );
  1272. } else {
  1273. initPw.value.validCheck.passwd = true;
  1274. if (!useUtil.isNull(initPw.value.passwd2)) {
  1275. fnValidCheck("initPw_passwd2");
  1276. }
  1277. }
  1278. } else {
  1279. if (initPw.value.passwd != initPw.value.passwd2) {
  1280. // 신규비밀번호가 일치 하지 않습니다.
  1281. initPw.value.validCheck.passwd2 = false;
  1282. initPw.value.errorTxt = i18n.t(
  1283. "common.header.myInfoUpdateModal.valid.missmatchPassword"
  1284. );
  1285. } else {
  1286. initPw.value.validCheck.passwd2 = true;
  1287. }
  1288. }
  1289. if (!useUtil.isNull(initPw.value.passwd) && !useUtil.isNull(initPw.value.passwd2)) {
  1290. initPw.value.passwdCheck = _every(
  1291. initPw.value.validCheck,
  1292. (value) => value === true
  1293. );
  1294. }
  1295. }
  1296. }
  1297. </script>