header.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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/order",
  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/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/settle",
  83. },
  84. {
  85. menuId: "menu05",
  86. parentMenuId: "menu05",
  87. menuName: "고객센터",
  88. linkType: "/view/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. localStorage.removeItem("tempAccess");
  109. useAuthStore().setLogout();
  110. router.push({
  111. path: "/",
  112. });
  113. };
  114. const myPage = (userId) => {
  115. router.push({
  116. path: "/view/mng/mngAdd",
  117. });
  118. useDtStore.adminInfo.adminId = userId;
  119. useDtStore.adminInfo.pageType = "U";
  120. };
  121. const withdrawal = () => {
  122. let _req = {
  123. SEQ: useStoreAuth.getSnsTempData.user.SEQ,
  124. GOOGLE_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.GOOGLE_REFRESH_TOKEN,
  125. KAKAO_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.KAKAO_REFRESH_TOKEN,
  126. NAVER_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.NAVER_REFRESH_TOKEN,
  127. };
  128. let _uri = useStoreAuth.getSnsTempData.user.GOOGLE_REFRESH_TOKEN
  129. ? "/auth/withdrawal"
  130. : useStoreAuth.getSnsTempData.user.KAKAO_REFRESH_TOKEN
  131. ? "/auth/kakaowithdrawal"
  132. : useStoreAuth.getSnsTempData.user.NAVER_REFRESH_TOKEN
  133. ? "/auth/naverwithdrawal"
  134. : "/auth/withdrawal";
  135. useAxios()
  136. .post(_uri, _req)
  137. .then((res) => {
  138. localStorage.removeItem("tempAccess");
  139. useStore.getSnsTempData = "";
  140. useAuthStore().setLogout();
  141. router.push({
  142. path: "/",
  143. });
  144. })
  145. .catch((error) => {
  146. if (error.response) {
  147. console.log("status:", error.response.status, "data:", error.response.data);
  148. // 안전하게 errCode, message 접근
  149. const errData = error.response.data || {};
  150. const errCode = errData.errCode || errData.errorCode || errData.code || "";
  151. const errMsg = errData.message || "알 수 없는 오류가 발생했습니다.";
  152. console.log("errCode:", errCode, "message:", errMsg);
  153. } else {
  154. console.log("error:", error.message, error.code);
  155. }
  156. if (error.response?.status) {
  157. fnLoginSet(error.response.data.messages.message);
  158. }
  159. $log.debug("[withdrawal][fnIdPwCheck][error]");
  160. })
  161. .finally(() => {
  162. $log.debug("[withdrawal][fnIdPwCheck][finished]");
  163. });
  164. };
  165. /************************************************************************
  166. | 라이프사이클 : onMounted
  167. ************************************************************************/
  168. onMounted(() => {
  169. console.log(useStoreAuth.getSnsTempData.user);
  170. userId.value = localStorage.getItem("tempAccess");
  171. userName.value = JSON.parse(localStorage.getItem("authStore"))?.auth.name;
  172. userCompanyName.value = JSON.parse(
  173. localStorage.getItem("authStore")
  174. )?.auth.companyName;
  175. fnSetMenu();
  176. });
  177. </script>