$(() => { shopby.my = shopby.my || {}; shopby.my.menu = { init(selector) { $('#contents').addClass('visible'); $(selector).renderTemplateWithRawHtml(this._getMenuData(), menuHtml); }, _getMenuData() { const config = shopby.cache.getBoardsConfig(); const { accumulationConfig: { accumulationName }, } = shopby.cache.getMall(); const { includesPreviousOrder } = shopby.cache.getOrderConfigs(); return { accumulationName, includesPreviousOrder, inquiryConfig: { used: config.inquiryConfig.used, name: config.inquiryConfig.name, }, productInquiryConfig: { used: config.productInquiryConfig.used, name: config.productInquiryConfig.name, }, productReviewConfig: { used: config.productReviewConfig.used, name: config.productReviewConfig.name, }, openIdMember: shopby.localStorage.getItem(shopby.cache.key.member.oauthProvider), }; }, }; shopby.my.summary = { async init(selector, summary, summaryAmount, likeCount = 0, grade = null) { let gradeInfo = null; if (!grade) { const { data } = await shopby.api.member.getProfileGrade(); gradeInfo = data; } else { gradeInfo = grade; } $(selector).renderTemplateWithRawHtml( this._getSummaryData(summary, summaryAmount, likeCount, gradeInfo), summaryHtml, ); this.bindEventForSummary(); }, bindEventForSummary() { $('#gradeBenefitInfo,#gradeBenefitCloseBtn').on('click', () => $('.grade_benefit_info').toggle()); $('#allGradeBenefitInfo').on('click', () => $('#allGradeBenefit').toggle()); }, _getSummaryData(summary, summaryAmount, likeCount, grade) { const { mall, accumulationConfig } = shopby.cache.getMall(); // 등급 적립금 (자동) const gradeAutoSupplyingAmt = grade.reserveAutoSupplying.used ? grade.reserveAutoSupplying.amount : 0; // 구매 적립금 (구매시) const gradeBuyReserveRate = grade.reserveBenefit.used ? grade.reserveBenefit.reserveRate : 0; return { name: summary.memberName, gradeLabel: grade.label, orderAmtlastHalfYear: summaryAmount.lastPayAmt, orderCntlastHalfYear: summaryAmount.orderCnt, gradeCoupons: grade.coupons, gradeReserveText: `${shopby.utils.toCurrencyString(gradeAutoSupplyingAmt)}원, ${gradeBuyReserveRate}%`, mallGrades: mall.grades, accumulationName: accumulationConfig && accumulationConfig.accumulationName ? accumulationConfig.accumulationName : '마일리지', accumulationUnit: accumulationConfig && accumulationConfig.accumulationName ? accumulationConfig.accumulationName : '원', accumulationTotalAmt: summary.accumulations.totalAmt, availableCoupons: summary.availableCoupons.totalCount, likeProductsCnt: likeCount, }; }, }; const summaryHtml = `

{{name}} 님은 {{gradeLabel}}입니다.

구매금액{{toCurrencyString orderAmtlastHalfYear}}

구매횟수{{orderCntlastHalfYear}}

등급혜택 안내 회원정보 수정

등급혜택 안내

닫기

나의 등급혜택

회원등급 {{gradeLabel}}
등급 쿠폰 혜택 {{couponName}} / {{#ifEq discountType 'AMOUNT'}}{{toCurrencyString discountAmount}}원{{else}}{{discountPercent}}%{{/ifEq}}
등급 적립금 혜택 {{gradeReserveText}}
전체 등급혜택 {{#if used}} {{/if}}
{{label}} {{#each coupons}} - {{couponName}} / {{#ifEq discountType 'AMOUNT'}}{{toCurrencyString discountAmount}}원{{else}}{{discountPercent}}%{{/ifEq}} 쿠폰
{{/each}} {{#if reserveAutoSupplying.used}} - 등급 적립금 {{toCurrencyString reserveAutoSupplying.amount}}원
{{/if}} {{#if reserveBenefit.used}} - 구매 금액의 {{reserveBenefit.reserveRate}}%
{{/if}}
사용 가능 {{accumulationName}}
{{toCurrencyString accumulationTotalAmt}}{{accumulationUnit}}
보유중인 쿠폰
{{toCurrencyString availableCoupons}}
찜리스트
{{toCurrencyString likeProductsCnt}}
`.trim(); const menuHtml = ` `.trim(); });