header.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <header class="new--header">
  3. <div class="pro--wrap">
  4. <div class="pro--img" style="background-image: url(/assets/img/pf_sample.svg);"></div>
  5. <div class="pro--id" @click="proOn ? (proOn = false) : (proOn = true)">
  6. {{ useStoreAuth.getSnsTempData.user.NICK_NAME }} <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. KAKAO_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.KAKAO_REFRESH_TOKEN,
  119. NAVER_REFRESH_TOKEN: useStoreAuth.getSnsTempData.user.NAVER_REFRESH_TOKEN,
  120. };
  121. let _uri = useStoreAuth.getSnsTempData.user.GOOGLE_REFRESH_TOKEN
  122. ? "/auth/withdrawal"
  123. : useStoreAuth.getSnsTempData.user.KAKAO_REFRESH_TOKEN
  124. ? "/auth/kakaowithdrawal"
  125. : useStoreAuth.getSnsTempData.user.NAVER_REFRESH_TOKEN
  126. ? "/auth/naverwithdrawal"
  127. : "/auth/withdrawal";
  128. useAxios()
  129. .post(_uri, _req)
  130. .then((res) => {
  131. localStorage.removeItem("tempAccess");
  132. useStore.getSnsTempData = "";
  133. useAuthStore().setLogout();
  134. router.push({
  135. path: "/",
  136. });
  137. })
  138. .catch((error) => {
  139. if (error.response) {
  140. console.log("status:", error.response.status, "data:", error.response.data);
  141. // 안전하게 errCode, message 접근
  142. const errData = error.response.data || {};
  143. const errCode = errData.errCode || errData.errorCode || errData.code || "";
  144. const errMsg = errData.message || "알 수 없는 오류가 발생했습니다.";
  145. console.log("errCode:", errCode, "message:", errMsg);
  146. } else {
  147. console.log("error:", error.message, error.code);
  148. }
  149. if (error.response?.status) {
  150. fnLoginSet(error.response.data.messages.message);
  151. }
  152. $log.debug("[withdrawal][fnIdPwCheck][error]");
  153. })
  154. .finally(() => {
  155. $log.debug("[withdrawal][fnIdPwCheck][finished]");
  156. });
  157. };
  158. /************************************************************************
  159. | 라이프사이클 : onMounted
  160. ************************************************************************/
  161. onMounted(() => {
  162. console.log(useStoreAuth.getSnsTempData.user);
  163. userId.value = localStorage.getItem("tempAccess");
  164. userName.value = JSON.parse(localStorage.getItem("authStore"))?.auth.name;
  165. userCompanyName.value = JSON.parse(
  166. localStorage.getItem("authStore")
  167. )?.auth.companyName;
  168. fnSetMenu();
  169. });
  170. </script>