header.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. {{ userId }} <i class="ico" :class="[proOn ? 'on' : '']">></i>
  7. <div class="id--box" v-show="proOn">
  8. <button type="button" class="btn-profile" @click="myPage(userId)">
  9. 마이페이지
  10. </button>
  11. <button type="button" class="btn-profile" @click="withdrawal">회원탈퇴</button>
  12. <button type="button" class="btn-logout" @click="fnLoguOut">로그아웃</button>
  13. </div>
  14. </div>
  15. <div class="pro--info inf">인플루언서</div>
  16. </div>
  17. <nav class="gnb">
  18. <ul class="depth1">
  19. <li v-for="(menu, index) in arrMenuInfo" :key="index">
  20. <button
  21. @click="menuAction(menu.menuId, menu.menuName, menu.linkType)"
  22. :class="{ actv: menu.linkType === $route.path }"
  23. >
  24. {{ menu.menuName }}
  25. </button>
  26. </li>
  27. </ul>
  28. </nav>
  29. </header>
  30. </template>
  31. <script setup>
  32. /************************************************************************
  33. | 전역
  34. ************************************************************************/
  35. const { $log } = useNuxtApp();
  36. const proOn = ref(false);
  37. const pageId = "header";
  38. const arrMenuInfo = ref([]); // 메뉴정보
  39. const useStore = useDetailStore();
  40. const useStoreAuth = useAuthStore();
  41. const userName = ref("");
  42. const userCompanyName = ref("");
  43. const userId = ref("");
  44. const route = useRoute();
  45. const router = useRouter();
  46. /************************************************************************
  47. | 함수 : 세팅
  48. ************************************************************************/
  49. const fnSetMenu = () => {
  50. let info = [];
  51. arrMenuInfo.value = [];
  52. info.push(
  53. {
  54. menuId: "menu00",
  55. parentMenuId: "menu00",
  56. menuName: "주문 관리",
  57. linkType: "/view/order",
  58. },
  59. {
  60. menuId: "menu01",
  61. parentMenuId: "menu01",
  62. menuName: "제품 관리",
  63. linkType: "/view/item",
  64. },
  65. {
  66. menuId: "menu02",
  67. parentMenuId: "menu02",
  68. menuName: "배송 관리",
  69. linkType: "/view/deli",
  70. },
  71. {
  72. menuId: "menu03",
  73. parentMenuId: "menu03",
  74. menuName: "벤더 관리",
  75. linkType: "/view/vendor",
  76. },
  77. {
  78. menuId: "menu04",
  79. parentMenuId: "menu04",
  80. menuName: "정산 관리",
  81. linkType: "/view/settle",
  82. },
  83. {
  84. menuId: "menu05",
  85. parentMenuId: "menu05",
  86. menuName: "고객센터",
  87. linkType: "/view/cs",
  88. }
  89. );
  90. arrMenuInfo.value = info;
  91. $log.debug("[header][fnSetMenu][success]");
  92. };
  93. const menuAction = (__MENUID, _MENUROOTNAME, __URL) => {
  94. useStore.menuInfo.menuIndex = "0";
  95. useStore.menuInfo.menuId = __MENUID;
  96. useStore.menuInfo.pageRtName = _MENUROOTNAME;
  97. useStore.menuInfo.pageStatus = null;
  98. useUtil.setPageMove(__URL);
  99. };
  100. const fnLoguOut = () => {
  101. localStorage.removeItem("tempAccess");
  102. useAuthStore().setLogout();
  103. router.push({
  104. path: "/",
  105. });
  106. };
  107. const myPage = (userId) => {
  108. router.push({
  109. path: "/view/mng/mngAdd",
  110. });
  111. useDtStore.adminInfo.adminId = userId;
  112. useDtStore.adminInfo.pageType = "U";
  113. };
  114. const withdrawal = () => {
  115. let _req = {
  116. SEQ: useStoreAuth.getSnsTempData.user.SEQ,
  117. GOOGLE_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.GOOGLE_REFRESH_TOKEN,
  118. };
  119. useAxios()
  120. .post("/auth/withdrawal", _req)
  121. .then((res) => {
  122. localStorage.removeItem("tempAccess");
  123. useStore.getSnsTempData = "";
  124. useAuthStore().setLogout();
  125. router.push({
  126. path: "/",
  127. });
  128. })
  129. .catch((error) => {
  130. if (error.response) {
  131. console.log("status:", error.response.status, "data:", error.response.data);
  132. // 안전하게 errCode, message 접근
  133. const errData = error.response.data || {};
  134. const errCode = errData.errCode || errData.errorCode || errData.code || "";
  135. const errMsg = errData.message || "알 수 없는 오류가 발생했습니다.";
  136. console.log("errCode:", errCode, "message:", errMsg);
  137. } else {
  138. console.log("error:", error.message, error.code);
  139. }
  140. if (error.response?.status) {
  141. fnLoginSet(error.response.data.messages.message);
  142. }
  143. $log.debug("[withdrawal][fnIdPwCheck][error]");
  144. })
  145. .finally(() => {
  146. $log.debug("[withdrawal][fnIdPwCheck][finished]");
  147. });
  148. };
  149. /************************************************************************
  150. | 라이프사이클 : onMounted
  151. ************************************************************************/
  152. onMounted(() => {
  153. userId.value = localStorage.getItem("tempAccess");
  154. userName.value = JSON.parse(localStorage.getItem("authStore"))?.auth.name;
  155. userCompanyName.value = JSON.parse(
  156. localStorage.getItem("authStore")
  157. )?.auth.companyName;
  158. fnSetMenu();
  159. });
  160. </script>