index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. <template>
  2. <div class="mypage-container">
  3. <!-- 프로필 섹션 -->
  4. <div class="profile-section">
  5. <div class="profile-card">
  6. <div class="profile-header">
  7. <div class="profile-avatar">
  8. {{ getMemberTypeName(userInfo.memberType) === "인플루언서" ? '❤️' : '💜' }}
  9. </div>
  10. <div class="profile-info">
  11. <h2>{{ userInfo.companyName || userInfo.nickName || userInfo.name }}</h2>
  12. <span class="member-type-badge">{{ getMemberTypeName(userInfo.memberType) }}</span>
  13. </div>
  14. <button
  15. class="edit-btn"
  16. @click="toggleEditMode"
  17. :class="{ active: isEditMode }"
  18. >
  19. {{ isEditMode ? '취소' : '수정' }}
  20. </button>
  21. </div>
  22. <!-- 정보 표시/수정 폼 -->
  23. <div class="profile-content">
  24. <div v-if="!isEditMode" class="info-display">
  25. <div class="info-row">
  26. <label>이름</label>
  27. <span>{{ myInfo.name }}</span>
  28. </div>
  29. <div class="info-row" v-if="userInfo.memberType === 'INFLUENCER'">
  30. <label>닉네임</label>
  31. <span>{{ myInfo.nickName }}</span>
  32. </div>
  33. <div class="info-row">
  34. <label>이메일</label>
  35. <span>{{ myInfo.email }}</span>
  36. </div>
  37. <div class="info-row" v-if="userInfo.memberType !== 'INFLUENCER'">
  38. <label>회사명</label>
  39. <span>{{ userInfo.companyName }}</span>
  40. </div>
  41. <div class="info-row">
  42. <label>전화번호</label>
  43. <span>{{ myInfo.phone || '미등록' }}</span>
  44. </div>
  45. <div class="info-row" v-if="userInfo.memberType === 'INFLUENCER'">
  46. <label>SNS</label>
  47. <span>{{ myInfo.sns_type || '미등록' }} {{ myInfo.sns_link || '미등록' }}</span>
  48. </div>
  49. </div>
  50. <div v-else class="info-edit">
  51. <div class="info-row">
  52. <label>이름</label>
  53. <span>{{ myInfo.name }}</span>
  54. </div>
  55. <div class="info-row" v-if="userInfo.memberType === 'INFLUENCER'">
  56. <label>닉네임</label>
  57. <input
  58. type="text"
  59. v-model="editForm.nickName"
  60. placeholder="닉네임을 입력하세요"
  61. class="edit-input w--20"
  62. />
  63. </div>
  64. <div class="info-row">
  65. <label>비밀번호 변경</label>
  66. <input
  67. type="password"
  68. v-model="editForm.newPassword"
  69. placeholder="비밀번호를 입력하세요."
  70. class="edit-input"
  71. />
  72. </div>
  73. <div class="info-row" v-if="editForm.newPassword">
  74. <label>비밀번호 확인</label>
  75. <input
  76. type="password"
  77. v-model="editForm.confirmPassword"
  78. placeholder="비밀번호를 한 번 더 입력하세요."
  79. class="edit-input"
  80. />
  81. </div>
  82. <div class="info-row email-row" v-if="userInfo.memberType !== 'INFLUENCER'">
  83. <label>이메일</label>
  84. <div class="email-container">
  85. <input
  86. type="text"
  87. v-model="editForm.emailLocal"
  88. placeholder="이메일"
  89. class="edit-input email-local"
  90. />
  91. <span>@</span>
  92. <input
  93. type="text"
  94. v-model="editForm.emailDomain"
  95. placeholder="이메일"
  96. class="edit-input email-local"
  97. />
  98. </div>
  99. </div>
  100. <div class="info-row" v-if="userInfo.memberType !== 'INFLUENCER'">
  101. <label>회사명</label>
  102. <input
  103. type="text"
  104. v-model="editForm.companyName"
  105. placeholder="회사명을 입력하세요"
  106. class="edit-input"
  107. />
  108. </div>
  109. <div class="info-row phone-row">
  110. <label>전화번호</label>
  111. <div class="phone-container">
  112. <input
  113. type="tel"
  114. v-model="editForm.phone1"
  115. placeholder="010"
  116. class="edit-input phone-part"
  117. maxlength="3"
  118. />
  119. <span>-</span>
  120. <input
  121. type="tel"
  122. v-model="editForm.phone2"
  123. placeholder="1234"
  124. class="edit-input phone-part"
  125. maxlength="4"
  126. />
  127. <span>-</span>
  128. <input
  129. type="tel"
  130. v-model="editForm.phone3"
  131. placeholder="5678"
  132. class="edit-input phone-part"
  133. maxlength="4"
  134. />
  135. </div>
  136. </div>
  137. <div class="info-row sns--row" v-if="userInfo.memberType === 'INFLUENCER'">
  138. <label>SNS</label>
  139. <select v-model="editForm.snsType" class="edit-input">
  140. <option value="">선택하세요</option>
  141. <option value="youtube">유튜브</option>
  142. <option value="instagram">인스타그램</option>
  143. <option value="naver">네이버 블로그</option>
  144. <option value="tiktok">틱톡</option>
  145. <option value="twitter">트위터</option>
  146. </select>
  147. <div class="edit-input-container">
  148. <input
  149. type="text"
  150. v-model="editForm.snsLink"
  151. :placeholder="getSnsPlaceholder(editForm.snsType)"
  152. class="edit-input"
  153. />
  154. </div>
  155. </div>
  156. <div class="edit-actions">
  157. <button
  158. class="btn-save"
  159. @click="fnUpdate"
  160. >
  161. 저장
  162. </button>
  163. <button
  164. class="btn-cancel"
  165. @click="cancelEdit"
  166. >
  167. 취소
  168. </button>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. </div>
  174. <!-- 추가 정보 섹션 -->
  175. <div class="additional-info">
  176. <div class="info-card">
  177. <h3>계정 정보</h3>
  178. <div class="info-grid">
  179. <div class="info-item">
  180. <span class="info-label">계정 타입</span>
  181. <span class="info-value">{{ getMemberTypeName(userInfo.memberType) }}</span>
  182. </div>
  183. <div class="info-item">
  184. <span class="info-label">계정 ID</span>
  185. <span class="info-value">{{ userInfo.id }}</span>
  186. </div>
  187. <div class="info-item">
  188. <span class="info-label">가입일</span>
  189. <span class="info-value">{{ formatDate(myInfo.regDate) || '정보 없음' }}</span>
  190. </div>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </template>
  196. <script setup>
  197. import "@vuepic/vue-datepicker/dist/main.css";
  198. /************************************************************************
  199. | 레이아웃
  200. ************************************************************************/
  201. definePageMeta({
  202. layout: "default",
  203. });
  204. /************************************************************************
  205. | PROPS
  206. ************************************************************************/
  207. const props = defineProps({
  208. propsData: {
  209. type: Object,
  210. default: () => {},
  211. },
  212. });
  213. /************************************************************************
  214. | 스토어
  215. ************************************************************************/
  216. const useDtStore = useDetailStore();
  217. const useAtStore = useAuthStore();
  218. /************************************************************************
  219. | 전역
  220. ************************************************************************/
  221. const { $toast, $log, $dayjs, $eventBus } = useNuxtApp();
  222. const router = useRouter();
  223. const myInfo = ref({});
  224. // 사용자 정보
  225. const userInfo = ref({
  226. id: useAtStore.auth.id,
  227. name: useAtStore.auth.name,
  228. email: useAtStore.auth.email,
  229. companyName: useAtStore.auth.companyName,
  230. companyNumber: useAtStore.auth.companyNumber,
  231. phone: useAtStore.auth.phone,
  232. memberType: useAtStore.auth.memberType,
  233. regDate: null
  234. });
  235. // 편집 모드
  236. const isEditMode = ref(false);
  237. const editForm = ref({
  238. name: '',
  239. nickName: '',
  240. emailLocal: '',
  241. emailDomain: null,
  242. companyName: '',
  243. phone1: '',
  244. phone2: '',
  245. phone3: '',
  246. snsType: '',
  247. snsLink: '',
  248. newPassword: '',
  249. confirmPassword: ''
  250. });
  251. /* eslint-disable */
  252. /* prettier-ignore */
  253. /************************************************************************
  254. | 함수(METHODS)
  255. ************************************************************************/
  256. // 회원 타입 이름 반환
  257. const getMemberTypeName = (type) => {
  258. switch(type) {
  259. case 'INFLUENCER': return '인플루언서';
  260. case 'VENDOR': return '벤더사';
  261. case 'BRAND': return '브랜드사';
  262. default: return '사용자';
  263. }
  264. };
  265. // 편집 모드 토글
  266. const toggleEditMode = () => {
  267. if (isEditMode.value) {
  268. // 편집 취소
  269. isEditMode.value = false;
  270. } else {
  271. // 편집 시작 - 현재 값으로 폼 초기화
  272. const currentEmail = myInfo.value.email || userInfo.value.email || '';
  273. const [emailLocal, emailDomain] = currentEmail.includes('@') ? currentEmail.split('@') : [currentEmail, ''];
  274. const currentPhone = myInfo.value.phone || userInfo.value.phone || '';
  275. const phoneParts = currentPhone.split('-');
  276. editForm.value = {
  277. name: myInfo.value.name || userInfo.value.name,
  278. nickName: myInfo.value.nickName || '',
  279. emailLocal: emailLocal,
  280. emailDomain: emailDomain || null,
  281. companyName: userInfo.value.companyName || '',
  282. phone1: phoneParts[0] || '',
  283. phone2: phoneParts[1] || '',
  284. phone3: phoneParts[2] || '',
  285. snsType: myInfo.value.sns_type || '',
  286. snsLink: myInfo.value.sns_link || '',
  287. newPassword: '',
  288. confirmPassword: ''
  289. };
  290. isEditMode.value = true;
  291. }
  292. };
  293. // 편집 취소
  294. const cancelEdit = () => {
  295. isEditMode.value = false;
  296. };
  297. // 프로필 저장
  298. const fnUpdate = async () => {
  299. // 패스워드 유효성 검사
  300. if (editForm.value.newPassword && editForm.value.newPassword !== editForm.value.confirmPassword) {
  301. $toast.error('패스워드가 일치하지 않습니다.');
  302. return;
  303. }
  304. if (editForm.value.newPassword && editForm.value.newPassword.length < 6) {
  305. $toast.error('패스워드는 최소 6자 이상이어야 합니다.');
  306. return;
  307. }
  308. let req = {
  309. MEMBER_TYPE: useAtStore.auth.memberType,
  310. MEMBER_SEQ: useAtStore.auth.seq,
  311. EMAIL: `${editForm.value.emailLocal}@${editForm.value.emailDomain || ''}`,
  312. COMPANY_NAME: editForm.value.companyName,
  313. SNS_TYPE: editForm.value.snsType,
  314. SNS_LINK_ID: editForm.value.snsLink
  315. }
  316. // 패스워드가 입력된 경우에만 추가
  317. if (editForm.value.newPassword.trim()) {
  318. req.PASSWORD = editForm.value.newPassword;
  319. }
  320. // 전화번호 조합
  321. const combinedPhone = `${editForm.value.phone1}-${editForm.value.phone2}-${editForm.value.phone3}`;
  322. // 인플루언서인 경우 닉네임 추가
  323. if (userInfo.value.memberType === 'INFLUENCER') {
  324. req.PHONE = combinedPhone;
  325. req.NICK_NAME = editForm.value.nickName;
  326. }
  327. // 인플루언서/벤더&브랜드사 테이블 내 연락처 컬럼명이 상이해 별도로 처리
  328. if (userInfo.value.memberType !== 'INFLUENCER') {
  329. req.HP = combinedPhone;
  330. }
  331. useAxios().post('/mypage/update', req).then(async (res) => {
  332. // 로컬 데이터 업데이트
  333. myInfo.value.email = `${editForm.value.emailLocal}@${editForm.value.emailDomain || ''}`;
  334. myInfo.value.phone = combinedPhone;
  335. myInfo.value.sns_type = editForm.value.snsType;
  336. myInfo.value.sns_link = editForm.value.snsLink;
  337. if (userInfo.value.memberType === 'INFLUENCER') {
  338. myInfo.value.nickName = editForm.value.nickName;
  339. }
  340. // 스토어도 업데이트
  341. useAtStore.auth.email = `${editForm.value.emailLocal}@${editForm.value.emailDomain || ''}`;
  342. useAtStore.auth.phone = combinedPhone;
  343. if (userInfo.value.memberType !== 'INFLUENCER') {
  344. useAtStore.auth.companyName = editForm.value.companyName;
  345. }
  346. $toast.success('프로필이 성공적으로 수정되었습니다.');
  347. isEditMode.value = false;
  348. // 페이지 새로고침 (F5)
  349. location.reload();
  350. })
  351. };
  352. const formatDate = (dateStr) => {
  353. if (!dateStr) return '';
  354. const date = new Date(dateStr);
  355. const year = date.getFullYear();
  356. const month = String(date.getMonth() + 1).padStart(2, '0');
  357. const day = String(date.getDate()).padStart(2, '0');
  358. return `${year}.${month}.${day}`;
  359. };
  360. // SNS 입력 placeholder 반환
  361. const getSnsPlaceholder = (snsType) => {
  362. const placeholders = {
  363. 'youtube': '채널 ID 또는 전체 URL',
  364. 'instagram': '사용자명 또는 전체 URL',
  365. 'naver': '블로그 ID 또는 전체 URL',
  366. 'tiktok': '사용자명 또는 전체 URL',
  367. 'facebook': '페이지명 또는 전체 URL',
  368. 'twitter': '사용자명 또는 전체 URL',
  369. 'blog': '블로그 주소',
  370. 'kakao': '사용자명 또는 전체 URL'
  371. };
  372. return placeholders[snsType] || 'SNS 링크 또는 ID를 입력하세요';
  373. };
  374. // 사용자 상세 정보 로드
  375. const fnDetail = () => {
  376. let req = {
  377. MEMBER_TYPE: useAtStore.auth.memberType,
  378. MEMBER_SEQ: useAtStore.auth.seq
  379. }
  380. useAxios()
  381. .post(`/mypage/detail`, req)
  382. .then((res) => {
  383. myInfo.value.id = res.data.ID;
  384. myInfo.value.name = res.data.NAME;
  385. myInfo.value.nickName = res.data.NICK_NAME;
  386. myInfo.value.phone = res.data.PHONE || res.data.HP;
  387. myInfo.value.sns_type = res.data.SNS_TYPE;
  388. myInfo.value.sns_link = res.data.SNS_LINK_ID;
  389. myInfo.value.email = res.data.EMAIL;
  390. myInfo.value.regDate = res.data.REGDATE || res.data.REG_DATE;
  391. })
  392. };
  393. /************************************************************************
  394. | 라이프사이클
  395. ************************************************************************/
  396. onMounted(() => {
  397. fnDetail();
  398. });
  399. </script>
  400. <style scoped>
  401. .mypage-container {
  402. margin: 0 auto;
  403. padding: 20px;
  404. }
  405. .page-header {
  406. margin-bottom: 32px;
  407. text-align: center;
  408. }
  409. .page-header h1 {
  410. font-size: 2.5rem;
  411. color: #1a237e;
  412. margin-bottom: 8px;
  413. }
  414. .page-header p {
  415. color: #666;
  416. font-size: 1.1rem;
  417. }
  418. .profile-section {
  419. margin-bottom: 32px;
  420. }
  421. .profile-card {
  422. background: white;
  423. border-radius: 20px;
  424. box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  425. overflow: hidden;
  426. }
  427. .profile-header {
  428. display: flex;
  429. align-items: center;
  430. padding: 32px;
  431. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  432. color: white;
  433. }
  434. .profile-avatar {
  435. font-size: 3rem;
  436. margin-right: 24px;
  437. background: rgba(255, 255, 255, 0.2);
  438. width: 96px;
  439. height: 96px;
  440. overflow: hidden;
  441. border-radius: 50%;
  442. display: flex;
  443. align-items: center;
  444. justify-content: center;
  445. }
  446. .profile-info {
  447. flex: 1;
  448. }
  449. .profile-info h2 {
  450. margin-bottom: 15px;
  451. font-size: 1.8rem;
  452. }
  453. .member-type-badge {
  454. background: rgba(255, 255, 255, 0.2);
  455. padding: 4px 12px;
  456. border-radius: 20px;
  457. font-size: 0.9rem;
  458. }
  459. .edit-btn {
  460. background: rgba(255, 255, 255, 0.2);
  461. border: 2px solid rgba(255, 255, 255, 0.3);
  462. color: white;
  463. padding: 12px 24px;
  464. border-radius: 25px;
  465. cursor: pointer;
  466. transition: all 0.3s ease;
  467. font-weight: 500;
  468. }
  469. .edit-btn:hover, .edit-btn.active {
  470. background: white;
  471. color: #667eea;
  472. }
  473. .profile-content {
  474. padding: 32px;
  475. }
  476. /* 정보 표시 스타일 */
  477. .info-display .info-row {
  478. display: flex;
  479. padding: 16px 0;
  480. border-bottom: 1px solid #f0f0f0;
  481. }
  482. .info-display .info-row:last-child {
  483. border-bottom: none;
  484. }
  485. .info-display label {
  486. width: 150px;
  487. font-weight: 600;
  488. color: #333;
  489. }
  490. .info-display span {
  491. flex: 1;
  492. color: #666;
  493. }
  494. /* 편집 폼 스타일 */
  495. .info-edit .info-row {
  496. display: flex;
  497. padding: 16px 0;
  498. border-bottom: 1px solid #f0f0f0;
  499. align-items: center;
  500. }
  501. .info-edit .info-row.sns--row > .edit-input{
  502. width: 20%;
  503. flex: none;
  504. margin-right: 20px;
  505. }
  506. .info-edit .info-row.sns--row .edit-input-container{
  507. width: 100%;
  508. }
  509. .info-edit .info-row.sns--row .edit-input-container .edit-input{
  510. width: 100%;
  511. }
  512. .info-edit .info-row:last-child {
  513. border-bottom: none;
  514. }
  515. .info-edit label {
  516. width: 150px;
  517. font-weight: 600;
  518. color: #333;
  519. flex-shrink: 0;
  520. }
  521. .edit-input {
  522. width: 100%;
  523. padding: 12px 16px;
  524. border: 2px solid #e0e0e0;
  525. border-radius: 8px;
  526. font-size: 1rem;
  527. transition: border-color 0.3s ease;
  528. background: white;
  529. }
  530. .edit-input.w--20{
  531. width: 20%;
  532. }
  533. .edit-input:focus {
  534. outline: none;
  535. border-color: #667eea;
  536. }
  537. .edit-input:disabled {
  538. background: #f8f9fa;
  539. color: #6c757d;
  540. cursor: not-allowed;
  541. }
  542. .edit-help {
  543. display: block;
  544. margin-top: 4px;
  545. font-size: 0.8rem;
  546. color: #666;
  547. font-style: italic;
  548. }
  549. .edit-actions {
  550. display: flex;
  551. gap: 12px;
  552. margin-top: 32px;
  553. justify-content: flex-end;
  554. }
  555. .btn-save {
  556. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  557. color: white;
  558. border: none;
  559. padding: 12px 24px;
  560. border-radius: 8px;
  561. cursor: pointer;
  562. font-weight: 500;
  563. transition: all 0.3s ease;
  564. }
  565. .btn-save:hover:not(:disabled) {
  566. transform: translateY(-2px);
  567. box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  568. }
  569. .btn-save:disabled {
  570. opacity: 0.6;
  571. cursor: not-allowed;
  572. }
  573. .btn-cancel {
  574. background: #f5f5f5;
  575. color: #666;
  576. border: none;
  577. padding: 12px 24px;
  578. border-radius: 8px;
  579. cursor: pointer;
  580. font-weight: 500;
  581. transition: all 0.3s ease;
  582. }
  583. .btn-cancel:hover {
  584. background: #e0e0e0;
  585. }
  586. /* 추가 정보 섹션 */
  587. .additional-info {
  588. margin-top: 32px;
  589. }
  590. .info-card {
  591. background: white;
  592. border-radius: 16px;
  593. padding: 32px;
  594. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  595. }
  596. .info-card h3 {
  597. margin: 0 0 24px 0;
  598. color: #1a237e;
  599. font-size: 1.3rem;
  600. }
  601. .info-grid {
  602. display: grid;
  603. grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  604. gap: 24px;
  605. }
  606. .info-item {
  607. padding: 16px;
  608. background: #f8f9fa;
  609. border-radius: 12px;
  610. }
  611. .info-label {
  612. display: block;
  613. font-size: 0.9rem;
  614. color: #666;
  615. margin-bottom: 15px;
  616. }
  617. .info-value {
  618. font-weight: 600;
  619. color: #333;
  620. font-size: 1rem;
  621. }
  622. /* 이메일 입력 스타일 */
  623. .email-container {
  624. display: flex;
  625. align-items: center;
  626. gap: 8px;
  627. flex: 1;
  628. }
  629. .email-local {
  630. width: 20%;
  631. }
  632. .email-domain {
  633. }
  634. /* 전화번호 입력 스타일 */
  635. .phone-container {
  636. display: flex;
  637. align-items: center;
  638. gap: 8px;
  639. width: 20%;
  640. }
  641. .phone-part {
  642. flex: 1;
  643. text-align: center;
  644. }
  645. </style>