$(() => { shopby.my = shopby.my || {}; 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', event => { event.preventDefault(); $('#gradeBenefitInfoTooltip').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, openIdMember: shopby.localStorage.getItem(shopby.cache.key.member.oauthProvider), }; }, }; const summaryHtml = `

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

등급혜택 안내 배송지 관리 {{#unless openIdMember}} 회원정보 수정 {{/unless}}

등급혜택 안내

닫기

나의 등급혜택

회원등급 {{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}}
`.trim(); });