header.vue 5.8 KB

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