97 lines
2.3 KiB
TypeScript
97 lines
2.3 KiB
TypeScript
/**
|
|
* Stove 유틸리티 함수
|
|
* @description Stove 관련 유틸리티 함수를 제공합니다.
|
|
*/
|
|
|
|
import { csrFormatJWT } from '#layers/utils/formatUtil'
|
|
|
|
/**
|
|
* Stove 로그인
|
|
*/
|
|
export const csrGoStoveLogin = () => {
|
|
const runtimeConfig = useRuntimeConfig()
|
|
const gameDataStore = useGameDataStore()
|
|
|
|
const loginUrl = runtimeConfig.public.stoveLoginUrl
|
|
const stoveGameId = gameDataStore.gameData?.game_id
|
|
const stoveGameNo = gameDataStore.gameData?.game_code
|
|
const redirectUrl = encodeURIComponent(location.href)
|
|
|
|
const url = `${loginUrl}?redirect_url=${redirectUrl}&inflow_path=${stoveGameId}&game_no=${stoveGameNo}`
|
|
location.href = url
|
|
}
|
|
|
|
/**
|
|
* Stove memberNo 조회
|
|
*/
|
|
export const csrGetStoveMemberNo = () => {
|
|
let memberNo = 0
|
|
try {
|
|
const suat = useCookie('SUAT')
|
|
|
|
if (suat.value && suat.value !== '') {
|
|
const base64Payload = suat.value?.split('.')[1] ?? ''
|
|
const decodeVal = csrFormatJWT(base64Payload)
|
|
memberNo = Number(`${decodeVal.member_no}`) || 0
|
|
} else {
|
|
memberNo = 0
|
|
}
|
|
} catch (e) {
|
|
console.error('[Exception] stoveUtil.csrGetStoveMemberNo: ', e)
|
|
return 0
|
|
}
|
|
return memberNo
|
|
}
|
|
|
|
/**
|
|
* AccessToken 조회
|
|
*/
|
|
export const csrGetAccessToken = () => {
|
|
let accessToken = ''
|
|
try {
|
|
const suat = useCookie('SUAT')
|
|
|
|
if (suat.value && suat.value !== '') {
|
|
accessToken = `${suat.value || ''}`
|
|
} else {
|
|
accessToken = ''
|
|
}
|
|
} catch (e) {
|
|
console.error('[Exception] stoveUtil.csrGetAccessToken: ', e)
|
|
return ''
|
|
}
|
|
return accessToken
|
|
}
|
|
|
|
/**
|
|
* 국가 코드 조회
|
|
*/
|
|
export const csrGetCountry = () => {
|
|
let countryCode = ''
|
|
try {
|
|
const nnto = useCookie('NNTO')
|
|
|
|
if (nnto.value !== undefined && nnto.value !== '') {
|
|
countryCode = `${nnto.value || ''}`
|
|
} else {
|
|
countryCode = ''
|
|
}
|
|
} catch (e) {
|
|
console.error('[Exception] stoveUtil.csrGetCountry: ', e)
|
|
return ''
|
|
}
|
|
return countryCode
|
|
}
|
|
|
|
/**
|
|
* STOVE 쿠폰함 링크 조회
|
|
*/
|
|
export const getStoveCouponUrl = (device: string) => {
|
|
const runtimeConfig = useRuntimeConfig()
|
|
|
|
const stoveCouponUrl = runtimeConfig.public.stoveCouponUrl as string
|
|
const stoveMCouponUrl = runtimeConfig.public.stoveMCouponUrl as string
|
|
|
|
return device === 'desktop' ? stoveCouponUrl : stoveMCouponUrl
|
|
}
|