index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div class="mypage-container">
  3. <!-- 헤더 섹션 -->
  4. <div class="mypage-header">
  5. <div class="header-content">
  6. <div class="profile-section">
  7. <div class="profile-avatar">
  8. <div class="avatar-placeholder">
  9. <i class="mdi mdi-account"></i>
  10. </div>
  11. </div>
  12. <div class="profile-info">
  13. <h1 class="user-name">{{ useAtStore.auth.nickName || useAtStore.auth.companyName || '사용자' }}</h1>
  14. <p class="user-type">{{ memberType === 'INFLUENCER' ? '인플루언서' : memberType === 'VENDOR' ? '벤더사' : '브랜드사' }}</p>
  15. </div>
  16. </div>
  17. </div>
  18. <!-- 통계 요약 카드 -->
  19. <div class="stats-overview">
  20. <div class="stat-card">
  21. <div class="stat-icon orders">
  22. <i class="mdi mdi-cart"></i>
  23. </div>
  24. <div class="stat-info">
  25. <h3>{{ recentOrdersTotal }}</h3>
  26. <p>신규 주문</p>
  27. </div>
  28. </div>
  29. <div class="stat-card">
  30. <div class="stat-icon items">
  31. <i class="mdi mdi-package-variant"></i>
  32. </div>
  33. <div class="stat-info">
  34. <h3>{{ activeItemsCount }}</h3>
  35. <p>진행중인 공동구매</p>
  36. </div>
  37. </div>
  38. <!-- <div class="stat-card">
  39. <div class="stat-icon sales">
  40. <i class="mdi mdi-trending-up"></i>
  41. </div>
  42. <div class="stat-info">
  43. <h3>{{ totalSalesCount }}</h3>
  44. <p>총 주문 건수</p>
  45. </div>
  46. </div> -->
  47. <div class="stat-card">
  48. <div class="stat-icon influencers">
  49. <i class="mdi mdi-account-group"></i>
  50. </div>
  51. <div class="stat-info">
  52. <h3>{{ activeInfluencersCount }}</h3>
  53. <p>활성 인플루언서</p>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <!-- 대시보드 섹션 -->
  59. <div class="dashboard-section">
  60. <div class="dashboard-cards">
  61. <!-- 최근 주문 현황 카드 -->
  62. <div class="dashboard-card recent-orders">
  63. <div class="card-header">
  64. <h3>신규 주문 <span class="limit-badge">*최근 10건까지</span></h3>
  65. <i class="mdi mdi-cart-outline"></i>
  66. </div>
  67. <div class="card-content">
  68. <div class="order-list">
  69. <div v-if="recentOrders.length > 0">
  70. <div
  71. v-for="order in recentOrders"
  72. :key="order.SEQ"
  73. class="order-item recent-order"
  74. @click="goToOrderDetail(order.ITEM_SEQ)"
  75. >
  76. <div class="order-icon">
  77. 🛒
  78. </div>
  79. <div class="item-info">
  80. <h4>{{ order.ITEM_NAME }}</h4>
  81. <div class="order-meta">
  82. <span class="order-number">#{{ order.ORDER_NUMB }}</span>
  83. <span class="influencer-name">{{ order.INF_NICK_NAME || order.INF_NAME }}</span>
  84. <div class="order-date">{{ formatDateTime(order.UPDATE_DATE) }}</div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div v-else class="no-orders">
  90. <i class="mdi mdi-cart-off"></i>
  91. <p>신규 주문이 없습니다</p>
  92. </div>
  93. </div>
  94. <div class="view-all">
  95. <v-btn variant="text" class="custom-btn btn-white" @click="goToOrders()">전체 보기</v-btn>
  96. </div>
  97. </div>
  98. </div>
  99. <!-- 진행중인 공동구매 카드 -->
  100. <div class="dashboard-card active-items">
  101. <div class="card-header">
  102. <h3>진행중인 공동구매<span class="limit-badge">*최근 5건까지</span></h3>
  103. <i class="mdi mdi-package-variant-closed"></i>
  104. </div>
  105. <div class="card-content">
  106. <div class="item-list">
  107. <div v-if="activeItems.length > 0">
  108. <div
  109. v-for="item in activeItems"
  110. :key="item.SEQ"
  111. class="item-card active-item"
  112. @click="goToItemDetail(item.SEQ)"
  113. >
  114. <div class="item-header">
  115. <div class="item-icon">📦</div>
  116. </div>
  117. <div class="item-info">
  118. <h4>{{ item.NAME }}</h4>
  119. <div class="item-stats">
  120. <span class="order-count">{{ formatDate(item.ORDER_START_DATE) }} ~ {{ formatDate(item.ORDER_END_DATE) }}</span>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <div v-else class="no-items">
  126. <i class="mdi mdi-package-variant-closed-remove"></i>
  127. <p>진행중인 공동구매가 없습니다</p>
  128. </div>
  129. </div>
  130. <div class="view-all">
  131. <v-btn variant="text" class="custom-btn btn-white" @click="goToItems()">전체 보기</v-btn>
  132. </div>
  133. </div>
  134. </div>
  135. <!-- 인플루언서별 판매 통계 카드 -->
  136. <div class="dashboard-card influencer-stats">
  137. <div class="card-header">
  138. <h3>인플루언서별 주문 건수<span class="limit-badge">*상위 6명까지</span></h3>
  139. <i class="mdi mdi-account-star"></i>
  140. </div>
  141. <div class="card-content">
  142. <div class="influencer-list">
  143. <div v-if="influencerStats.length > 0" class="influencer-cards">
  144. <div
  145. v-for="(stat, index) in influencerStats"
  146. :key="stat.INF_SEQ"
  147. class="influencer-card"
  148. >
  149. <div class="rank-badge">{{ index + 1 }}</div>
  150. <div class="user-avatar">
  151. 🤝
  152. </div>
  153. <div class="influencer-info">
  154. <h4>{{ stat.INF_NAME || '인플루언서' + stat.INF_SEQ }}</h4>
  155. <div class="order-count white">
  156. <span class="count">{{ stat.ORDER_COUNT }}</span>
  157. <span class="label">건</span>
  158. </div>
  159. </div>
  160. </div>
  161. </div>
  162. <div v-else class="no-stats">
  163. <i class="mdi mdi-chart-line"></i>
  164. <p>인플루언서 정보가 없습니다.</p>
  165. </div>
  166. <div class="view-all">
  167. <v-btn variant="text" class="custom-btn btn-white" @click="goToContact()">전체 보기</v-btn>
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. </div>
  175. </template>
  176. <script setup>
  177. /************************************************************************
  178. | 레이아웃
  179. ************************************************************************/
  180. definePageMeta({
  181. layout: "default",
  182. });
  183. /************************************************************************
  184. | PROPS
  185. ************************************************************************/
  186. const props = defineProps({
  187. propsData: {
  188. type: Object,
  189. default: () => {},
  190. },
  191. });
  192. /************************************************************************
  193. | 스토어
  194. ************************************************************************/
  195. const useDtStore = useDetailStore();
  196. const useAtStore = useAuthStore();
  197. /************************************************************************
  198. | 전역
  199. ************************************************************************/
  200. const memberType = useAtStore.auth.memberType;
  201. const { $toast, $log, $dayjs, $eventBus } = useNuxtApp();
  202. const router = useRouter();
  203. const activeItemsCount = ref(0);
  204. const activeInfluencersCount = ref(0);
  205. const recentOrders = ref([]);
  206. const recentOrdersTotal = ref(0);
  207. const activeItems = ref([]);
  208. const influencerStats = ref([]);
  209. // 대시보드 관련 computed
  210. const completedInquiries = computed(() => {
  211. return csList.value.filter(item => item.STATUS === '1').length;
  212. });
  213. const totalSalesCount = computed(() => {
  214. return recentOrders.value.length;
  215. });
  216. // 문의 등록 팝업 관련
  217. const showInquiryModal = ref(false);
  218. const isSubmitting = ref(false);
  219. const inquiryForm = ref({
  220. category: '',
  221. title: '',
  222. content: '',
  223. attachments: []
  224. });
  225. const categoryOptions = ref([
  226. { title: '기능문의', value: 'D' },
  227. { title: '기타문의', value: 'E' }
  228. ]);
  229. /* eslint-disable */
  230. /* prettier-ignore */
  231. /************************************************************************
  232. | 함수(METHODS)
  233. ************************************************************************/
  234. // 대시보드 데이터 로드 함수들
  235. const loadRecentOrders = async () => {
  236. try {
  237. const _req = {
  238. COMPANY_NUMBER: useAtStore.auth.companyNumber,
  239. MEMBER_TYPE: useAtStore.auth.memberType,
  240. MEMBER_SEQ: useAtStore.auth.seq,
  241. LIMIT: 10,
  242. };
  243. const response = await useAxios().post('/dashboard/recentOrders', _req);
  244. recentOrders.value = response.data.data || response.data; // 하위호환성
  245. recentOrdersTotal.value = response.data.total || 0;
  246. } catch (error) {
  247. console.error('최근 주문 로드 실패:', error);
  248. }
  249. };
  250. const loadActiveItems = async () => {
  251. try {
  252. const _req = {
  253. SHOW_YN: "Y",
  254. TYPE: "G",
  255. //INF_SEQ: useAtStore.auth.seq,
  256. MEMBER_TYPE: memberType,
  257. MEMBER_SEQ: useAtStore.auth.seq,
  258. STATUS: 0,
  259. COMPANY_NUMBER: useAtStore.auth.companyNumber,
  260. LIMIT: 5,
  261. };
  262. const response = await useAxios().post('/dashboard/activeItems', _req);
  263. activeItems.value = response.data.data || response.data; // 하위호환성
  264. activeItemsCount.value = response.data.total || activeItems.value.length;
  265. } catch (error) {
  266. console.error('진행중인 공동구매 로드 실패:', error);
  267. }
  268. };
  269. const loadInfluencerStats = async () => {
  270. try {
  271. const _req = {
  272. COMPANY_NUMBER: useAtStore.auth.companyNumber,
  273. MEMBER_TYPE: useAtStore.auth.memberType,
  274. MEMBER_SEQ: useAtStore.auth.seq,
  275. LIMIT: 6,
  276. };
  277. const response = await useAxios().post('/dashboard/influencerStats', _req);
  278. influencerStats.value = response.data.data || response.data; // 하위호환성
  279. activeInfluencersCount.value = response.data.total || 0;
  280. } catch (error) {
  281. //console.error('인플루언서 통계 로드 실패:', error);
  282. }
  283. };
  284. const loadDashboardData = async () => {
  285. await Promise.all([
  286. loadRecentOrders(),
  287. loadActiveItems(),
  288. loadInfluencerStats(),
  289. ]);
  290. };
  291. const goToContact = () => {
  292. router.push('/view/common/dashboard/contact');
  293. };
  294. const goToItems = () => {
  295. router.push('/view/common/item');
  296. };
  297. const goToOrders = () => {
  298. router.push('/view/common/item');
  299. };
  300. const goToOrderDetail = (itemSeq) => {
  301. useDtStore.boardInfo.seq = itemSeq;
  302. useDtStore.boardInfo.pageType = "D";
  303. router.push({
  304. path: "/view/common/item/detail",
  305. query: { itemId: itemSeq }
  306. });
  307. };
  308. const goToItemDetail = (itemSeq) => {
  309. useDtStore.boardInfo.seq = itemSeq;
  310. router.push({
  311. path: "/view/common/item/detail",
  312. query: { itemId: itemSeq }
  313. });
  314. };
  315. const formatDate = (dateStr) => {
  316. if (!dateStr) return '';
  317. const date = new Date(dateStr);
  318. const year = date.getFullYear();
  319. const month = String(date.getMonth() + 1).padStart(2, '0');
  320. const day = String(date.getDate()).padStart(2, '0');
  321. return `${year}.${month}.${day}`;
  322. };
  323. const formatDateTime = (dateStr) => {
  324. if (!dateStr) return '';
  325. const date = new Date(dateStr);
  326. const month = String(date.getMonth() + 1).padStart(2, '0');
  327. const day = String(date.getDate()).padStart(2, '0');
  328. const hours = String(date.getHours()).padStart(2, '0');
  329. const minutes = String(date.getMinutes()).padStart(2, '0');
  330. return `${month}.${day} ${hours}:${minutes}`;
  331. };
  332. const showComingSoon = () => {
  333. $eventBus.emit('OPEN_CONFIRM_POP_UP', {
  334. id: 'coming-soon',
  335. title: '안내',
  336. content: '준비중입니다.',
  337. yes: {
  338. text: '확인',
  339. isProc: false
  340. }
  341. });
  342. };
  343. /************************************************************************
  344. | WATCH
  345. ************************************************************************/
  346. onMounted(() => {
  347. loadDashboardData();
  348. });
  349. </script>