header.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <header class="new--header">
  3. <div class="pro--wrap">
  4. <div class="pro--img"></div>
  5. <div class="pro--id" @click="proOn ? (proOn = false) : (proOn = true)">
  6. {{ useStoreAuth.getSnsTempData?.user?.NICK_NAME || "사용자" }}
  7. <i class="ico" :class="[proOn ? 'on' : '']">></i>
  8. <div class="id--box" v-show="proOn">
  9. <button type="button" class="btn-profile" @click="myPage(userId)">
  10. 마이페이지
  11. </button>
  12. <!--
  13. <button type="button" class="btn-profile" @click="withdrawal">회원탈퇴</button>
  14. -->
  15. <button type="button" class="btn-logout" @click="fnLoguOut">로그아웃</button>
  16. </div>
  17. </div>
  18. <div class="pro--info inf">{{ memberTypeText }}</div>
  19. <!-- 알림 센터 추가 -->
  20. <NotificationCenter />
  21. </div>
  22. <nav class="gnb">
  23. <ul class="depth1">
  24. <li v-for="(menu, index) in arrMenuInfo" :key="index"
  25. :class="{ 'has-submenu': menu.subMenus && menu.subMenus.length > 0 }"
  26. @mouseenter="showSubmenu(menu.menuId)"
  27. @mouseleave="hideSubmenu(menu.menuId)">
  28. <button
  29. @click="menuAction(menu.menuId, menu.menuName, menu.linkType)"
  30. :class="{ actv: isMenuActive(menu) }"
  31. >
  32. {{ menu.menuName }}
  33. <i v-if="menu.subMenus && menu.subMenus.length > 0" class="ico-arrow">▼</i>
  34. </button>
  35. <!-- 하위 메뉴 -->
  36. <ul v-if="menu.subMenus && menu.subMenus.length > 0"
  37. class="depth2"
  38. :class="{ show: activeSubmenu === menu.menuId }">
  39. <li v-for="(subMenu, subIndex) in menu.subMenus" :key="subIndex">
  40. <button
  41. @click="menuAction(subMenu.menuId, subMenu.menuName, subMenu.linkType)"
  42. :class="{ actv: subMenu.linkType === $route.path }"
  43. >
  44. {{ subMenu.menuName }}
  45. </button>
  46. </li>
  47. </ul>
  48. </li>
  49. </ul>
  50. </nav>
  51. </header>
  52. </template>
  53. <script setup>
  54. /************************************************************************
  55. | 전역
  56. ************************************************************************/
  57. const { $log } = useNuxtApp();
  58. const proOn = ref(false);
  59. const pageId = "header";
  60. const arrMenuInfo = ref([]); // 메뉴정보
  61. const useStore = useDetailStore();
  62. const useStoreAuth = useAuthStore();
  63. const userName = ref("");
  64. const userCompanyName = ref("");
  65. const userId = ref("");
  66. const memberTypeText = ref("사용자");
  67. const route = useRoute();
  68. const router = useRouter();
  69. const activeSubmenu = ref("");
  70. /************************************************************************
  71. | 함수 : 세팅
  72. ************************************************************************/
  73. const fnSetMenu = () => {
  74. let info = [];
  75. arrMenuInfo.value = [];
  76. // 사용자 타입 확인 (memberType으로 구분)
  77. const snsUser = useStoreAuth.getSnsTempData?.user;
  78. const authUser = JSON.parse(localStorage.getItem("authStore"))?.auth;
  79. const currentUser = snsUser || authUser;
  80. let memberType = currentUser?.memberType || currentUser?.MEMBER_TYPE;
  81. // memberType이 없으면 URL로 판단
  82. if (!memberType) {
  83. const currentPath = route.path;
  84. const companyNumber = currentUser?.COMPANY_NUMBER;
  85. // 벤더 대시보드 경로이거나 COMPANY_NUMBER가 있으면 벤더사로 판단
  86. if (currentPath.includes("/vendor/dashboard") || companyNumber) {
  87. memberType = "VENDOR";
  88. } else {
  89. memberType = "INFLUENCER";
  90. }
  91. }
  92. console.log("=== 헤더 메뉴 디버깅 ===");
  93. console.log("SNS 사용자:", snsUser);
  94. console.log("Auth 사용자:", authUser);
  95. console.log("현재 사용자:", currentUser);
  96. console.log("원본 memberType:", currentUser?.memberType);
  97. console.log("원본 MEMBER_TYPE:", currentUser?.MEMBER_TYPE);
  98. console.log("최종 memberType:", memberType);
  99. console.log("현재 경로:", route.path);
  100. console.log("COMPANY_NUMBER:", currentUser?.COMPANY_NUMBER);
  101. if (memberType === "VENDOR") {
  102. // 벤더사 메뉴
  103. memberTypeText.value = "벤더사";
  104. info.push(
  105. {
  106. menuId: "menu00",
  107. parentMenuId: "menu00",
  108. menuName: "주문 관리",
  109. linkType: "/view/vendor/dashboard",
  110. },
  111. {
  112. menuId: "menu01",
  113. parentMenuId: "menu01",
  114. menuName: "제품 관리",
  115. linkType: "/view/common/item",
  116. },
  117. {
  118. menuId: "menu02",
  119. parentMenuId: "menu02",
  120. menuName: "배송 관리",
  121. linkType: "/view/common/deli",
  122. subMenus: [
  123. {
  124. menuId: "menu02-1",
  125. menuName: "배송 관리",
  126. linkType: "/view/common/deli"
  127. },
  128. {
  129. menuId: "menu02-2",
  130. menuName: "배송중",
  131. linkType: "/view/common/deli/shipping"
  132. },
  133. {
  134. menuId: "menu02-3",
  135. menuName: "배송완료",
  136. linkType: "/view/common/deli/delivered"
  137. }
  138. ]
  139. },
  140. {
  141. menuId: "menu03",
  142. parentMenuId: "menu03",
  143. menuName: "인플루언서 관리",
  144. linkType: "/view/vendor/dashboard/influencer-requests",
  145. },
  146. {
  147. menuId: "menu04",
  148. parentMenuId: "menu04",
  149. menuName: "정산 관리",
  150. linkType: "/view/common/settlement",
  151. },
  152. {
  153. menuId: "menu05",
  154. parentMenuId: "menu05",
  155. menuName: "고객센터",
  156. linkType: "/view/common/cs",
  157. }
  158. );
  159. } else {
  160. // 인플루언서 메뉴
  161. memberTypeText.value = "인플루언서";
  162. info.push(
  163. {
  164. menuId: "menu00",
  165. parentMenuId: "menu00",
  166. menuName: "주문 관리",
  167. linkType: "/view/vendor/dashboard",
  168. },
  169. {
  170. menuId: "menu01",
  171. parentMenuId: "menu01",
  172. menuName: "제품 관리",
  173. linkType: "/view/common/item",
  174. },
  175. {
  176. menuId: "menu02",
  177. parentMenuId: "menu02",
  178. menuName: "배송 관리",
  179. linkType: "/view/common/deli",
  180. subMenus: [
  181. {
  182. menuId: "menu02-1",
  183. menuName: "배송 관리",
  184. linkType: "/view/common/deli"
  185. },
  186. {
  187. menuId: "menu02-2",
  188. menuName: "배송중",
  189. linkType: "/view/common/deli/shipping"
  190. },
  191. {
  192. menuId: "menu02-3",
  193. menuName: "배송완료",
  194. linkType: "/view/common/deli/delivered"
  195. }
  196. ]
  197. },
  198. {
  199. menuId: "menu03",
  200. parentMenuId: "menu03",
  201. menuName: "벤더 관리",
  202. linkType: "/view/influencer/search",
  203. },
  204. {
  205. menuId: "menu04",
  206. parentMenuId: "menu04",
  207. menuName: "정산 관리",
  208. linkType: "/view/common/settlement",
  209. },
  210. {
  211. menuId: "menu05",
  212. parentMenuId: "menu05",
  213. menuName: "고객센터",
  214. linkType: "/view/common/cs",
  215. }
  216. );
  217. }
  218. arrMenuInfo.value = info;
  219. $log.debug("[header][fnSetMenu][success] - MEMBER_TYPE:", memberType);
  220. };
  221. const showSubmenu = (menuId) => {
  222. activeSubmenu.value = menuId;
  223. };
  224. const hideSubmenu = (menuId) => {
  225. activeSubmenu.value = "";
  226. };
  227. const isMenuActive = (menu) => {
  228. if (menu.linkType === route.path) {
  229. return true;
  230. }
  231. // 하위 메뉴 중 하나가 활성화되어 있는지 확인
  232. if (menu.subMenus && menu.subMenus.length > 0) {
  233. return menu.subMenus.some(subMenu => subMenu.linkType === route.path);
  234. }
  235. return false;
  236. };
  237. const menuAction = (__MENUID, _MENUROOTNAME, __URL) => {
  238. useStore.menuInfo.menuIndex = "0";
  239. useStore.menuInfo.menuId = __MENUID;
  240. useStore.menuInfo.pageRtName = _MENUROOTNAME;
  241. useStore.menuInfo.pageStatus = null;
  242. useUtil.setPageMove(__URL);
  243. };
  244. const fnLoguOut = () => {
  245. const { logout } = useLogout();
  246. logout();
  247. };
  248. const myPage = (userId) => {
  249. router.push({
  250. path: "/view/mng/mngAdd",
  251. });
  252. useDtStore.adminInfo.adminId = userId;
  253. useDtStore.adminInfo.pageType = "U";
  254. };
  255. const withdrawal = () => {
  256. let _req = {
  257. SEQ: useStoreAuth.getSnsTempData.user.SEQ,
  258. GOOGLE_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.GOOGLE_REFRESH_TOKEN,
  259. KAKAO_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.KAKAO_REFRESH_TOKEN,
  260. NAVER_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.NAVER_REFRESH_TOKEN,
  261. };
  262. let _uri = useStoreAuth.getSnsTempData.user.GOOGLE_REFRESH_TOKEN
  263. ? "/auth/withdrawal"
  264. : useStoreAuth.getSnsTempData.user.KAKAO_REFRESH_TOKEN
  265. ? "/auth/kakaowithdrawal"
  266. : useStoreAuth.getSnsTempData.user.NAVER_REFRESH_TOKEN
  267. ? "/auth/naverwithdrawal"
  268. : "/auth/withdrawal";
  269. useAxios()
  270. .post(_uri, _req)
  271. .then((res) => {
  272. localStorage.removeItem("tempAccess");
  273. useStore.getSnsTempData = "";
  274. useAuthStore().setLogout();
  275. router.push({
  276. path: "/",
  277. });
  278. })
  279. .catch((error) => {
  280. if (error.response) {
  281. console.log("status:", error.response.status, "data:", error.response.data);
  282. // 안전하게 errCode, message 접근
  283. const errData = error.response.data || {};
  284. const errCode = errData.errCode || errData.errorCode || errData.code || "";
  285. const errMsg = errData.message || "알 수 없는 오류가 발생했습니다.";
  286. console.log("errCode:", errCode, "message:", errMsg);
  287. } else {
  288. console.log("error:", error.message, error.code);
  289. }
  290. if (error.response?.status) {
  291. fnLoginSet(error.response.data.messages.message);
  292. }
  293. $log.debug("[withdrawal][fnIdPwCheck][error]");
  294. })
  295. .finally(() => {
  296. $log.debug("[withdrawal][fnIdPwCheck][finished]");
  297. });
  298. };
  299. /************************************************************************
  300. | 라이프사이클 : onMounted
  301. ************************************************************************/
  302. onMounted(() => {
  303. console.log(useStoreAuth.getSnsTempData.user);
  304. userId.value = localStorage.getItem("tempAccess");
  305. userName.value = JSON.parse(localStorage.getItem("authStore"))?.auth.name;
  306. userCompanyName.value = JSON.parse(
  307. localStorage.getItem("authStore")
  308. )?.auth.companyName;
  309. fnSetMenu();
  310. });
  311. </script>
  312. <style scoped>
  313. .new--header {
  314. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  315. box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  316. border-radius: 0 0 12px 12px;
  317. overflow: hidden;
  318. }
  319. .pro--wrap {
  320. display: flex;
  321. align-items: center;
  322. padding: 16px 24px;
  323. background: rgba(255, 255, 255, 0.95);
  324. backdrop-filter: blur(10px);
  325. border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  326. }
  327. .pro--img {
  328. width: 40px;
  329. height: 40px;
  330. border-radius: 50%;
  331. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  332. display: flex;
  333. align-items: center;
  334. justify-content: center;
  335. margin-right: 12px;
  336. box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  337. }
  338. /* .pro--img::before {
  339. content: "👤";
  340. color: white;
  341. font-size: 18px;
  342. } */
  343. .pro--id {
  344. position: relative;
  345. color: #374151;
  346. font-weight: 500;
  347. font-size: 16px;
  348. cursor: pointer;
  349. padding: 8px 12px;
  350. border-radius: 8px;
  351. transition: all 0.2s ease;
  352. }
  353. .pro--id:hover {
  354. background: rgba(102, 126, 234, 0.1);
  355. color: #667eea;
  356. }
  357. .ico {
  358. margin-left: 8px;
  359. transition: transform 0.2s ease;
  360. color: #9ca3af;
  361. }
  362. .ico.on {
  363. transform: rotate(90deg);
  364. color: #667eea;
  365. }
  366. .id--box {
  367. position: absolute;
  368. top: 100%;
  369. left: 0;
  370. margin-top: 8px;
  371. background: white;
  372. border: 1px solid #e5e7eb;
  373. border-radius: 12px;
  374. box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  375. z-index: 1000;
  376. overflow: hidden;
  377. min-width: 160px;
  378. }
  379. .btn-profile,
  380. .btn-logout {
  381. width: 100%;
  382. padding: 16px 20px;
  383. border: none;
  384. background: none;
  385. text-align: left;
  386. cursor: pointer;
  387. transition: all 0.2s ease;
  388. font-size: 14px;
  389. color: #374151;
  390. }
  391. .btn-profile:hover {
  392. background: #f3f4f6;
  393. color: #667eea;
  394. }
  395. .btn-logout:hover {
  396. background: #fef2f2;
  397. color: #dc2626;
  398. }
  399. .pro--info {
  400. margin-left: auto;
  401. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  402. color: white;
  403. padding: 6px 16px;
  404. border-radius: 20px;
  405. font-size: 14px;
  406. font-weight: 500;
  407. box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
  408. }
  409. .gnb {
  410. background: rgba(255, 255, 255, 0.98);
  411. backdrop-filter: blur(10px);
  412. }
  413. .depth1 {
  414. display: flex;
  415. width: 100%;
  416. list-style: none;
  417. margin: 0;
  418. padding: 0;
  419. align-items: center;
  420. }
  421. .depth1 button {
  422. width: 100%;
  423. padding: 16px 24px;
  424. border: none;
  425. background: none;
  426. font-size: 15px;
  427. font-weight: 500;
  428. color: #6b7280;
  429. cursor: pointer;
  430. transition: all 0.3s ease;
  431. position: relative;
  432. border-bottom: 3px solid transparent;
  433. text-align: left;
  434. }
  435. .depth1 button:hover {
  436. color: #667eea;
  437. transform: translateY(-1px);
  438. }
  439. .depth1 button.actv {
  440. color: #667eea;
  441. border-bottom-color: #667eea;
  442. font-weight: 600;
  443. }
  444. .depth1 button.actv::before {
  445. content: "";
  446. position: absolute;
  447. bottom: -3px;
  448. left: 50%;
  449. transform: translateX(-50%);
  450. width: 60%;
  451. height: 3px;
  452. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  453. border-radius: 2px;
  454. }
  455. /* 하위 메뉴가 있는 항목 스타일 */
  456. .has-submenu {
  457. position: relative;
  458. }
  459. .ico-arrow {
  460. font-size: 10px;
  461. margin-left: 6px;
  462. transition: transform 0.2s ease;
  463. }
  464. .has-submenu:hover .ico-arrow {
  465. transform: rotate(180deg);
  466. }
  467. /* 하위 메뉴 스타일 */
  468. .depth2 {
  469. position: absolute;
  470. top: 100%;
  471. left: 0;
  472. background: white;
  473. border: 1px solid #e5e7eb;
  474. border-radius: 8px;
  475. box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  476. z-index: 1000;
  477. min-width: 180px;
  478. list-style: none;
  479. margin: 0;
  480. padding: 8px 0;
  481. opacity: 0;
  482. visibility: hidden;
  483. transform: translateY(-10px);
  484. transition: all 0.2s ease;
  485. }
  486. .depth2.show {
  487. opacity: 1;
  488. visibility: visible;
  489. transform: translateY(0);
  490. }
  491. .depth2 button {
  492. width: 100%;
  493. padding: 12px 20px !important;
  494. border: none;
  495. background: none;
  496. font-size: 14px !important;
  497. font-weight: 400 !important;
  498. color: #374151;
  499. cursor: pointer;
  500. transition: all 0.2s ease;
  501. text-align: left;
  502. border-bottom: none !important;
  503. }
  504. .depth2 button:hover {
  505. background: #f3f4f6;
  506. color: #667eea;
  507. transform: none !important;
  508. }
  509. .depth2 button.actv {
  510. background: #f0f7ff;
  511. color: #667eea;
  512. font-weight: 500 !important;
  513. border-bottom: none !important;
  514. }
  515. .depth2 button.actv::before {
  516. display: none;
  517. }
  518. /* 호버 시 하위 메뉴 표시 */
  519. .has-submenu:hover .depth2 {
  520. opacity: 1;
  521. visibility: visible;
  522. transform: translateY(0);
  523. }
  524. </style>