merge master into develop - CscListRForm.jsp FAQ 아코디언 버그 수정
This commit is contained in:
344
build/resources/main/static/mobile/js/bnft/common/Common_app.js
Normal file
344
build/resources/main/static/mobile/js/bnft/common/Common_app.js
Normal file
@@ -0,0 +1,344 @@
|
||||
/*******************************************
|
||||
Web-App 연동 스크립트
|
||||
*******************************************/
|
||||
|
||||
// 하단탭 메뉴제어 - 앱접근시 혜택링크 세팅
|
||||
$(document).ready(function(){
|
||||
if(window.app) {
|
||||
const $tabBar = $("#tabBarWishOrBnft");
|
||||
if ($tabBar.length > 0) {
|
||||
var sopmalcd = $tabBar.data('sopmalcd');
|
||||
if(sopmalcd == 'NC' || sopmalcd == 'DT') {
|
||||
$tabBar.attr("href", "/sopmal/bnft/bnftMain");
|
||||
$tabBar.find("i").removeClass("icon_tab-bar-wishlist").addClass("icon_tab-bar-benefit");
|
||||
$tabBar.contents().filter(function() {
|
||||
return this.nodeType === 3 && $.trim(this.nodeValue) !== "";
|
||||
}).each(function() {
|
||||
this.nodeValue = "혜택";
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 건강 데이터 이용 안내 모달 표시 (앱 진입시)
|
||||
setTimeout(function() {
|
||||
fn_show_health_data_agreement_modal();
|
||||
}, 500); // 0.5초 지연 후 실행 (페이지 로딩 완료 대기)
|
||||
});
|
||||
|
||||
// 앱접속후 로그인전 디바이스정보 입력
|
||||
function fn_save_device_info() {
|
||||
if(window.app) {
|
||||
var json_str = window.app.get_device_info();
|
||||
var result = JSON.parse(json_str);
|
||||
|
||||
var tokenKey = result.tokenKey; // push key
|
||||
var deviceId = result.deviceId; // 디바이스 고유ID(IME)
|
||||
var deviceOsNm = result.deviceOsNm; // 운영체제이름
|
||||
var deviceOsVer = result.deviceOsVer; // 운영체제버전
|
||||
var deviceAppVer = result.deviceAppVer; // 앱버전
|
||||
var pushAgreAt = result.pushAgreAt; // 알림 동의 여부
|
||||
var phacAgreAt = result.phacAgreAt; // 신체활동접근 동의 여부
|
||||
|
||||
// 현재 세션에서 저장여부
|
||||
var sessDvcId = sessionStorage.getItem("sessDvcId");
|
||||
console.log('sessDvcId : ' + sessDvcId);
|
||||
|
||||
// 앱디바이스 정보 저장
|
||||
if(typeof deviceId !== 'undefined' && deviceId !== '' && !sessDvcId) {
|
||||
$.ajax({
|
||||
url: '/sopmal/app/insertAppDeviceInfo',
|
||||
type: 'post',
|
||||
contentType: 'application/json; charset=UTF-8',
|
||||
data : JSON.stringify({
|
||||
fcmToken : tokenKey,
|
||||
pushAgreAt : pushAgreAt,
|
||||
phacAgreAt : phacAgreAt,
|
||||
deviceId : deviceId,
|
||||
deviceOsNm : deviceOsNm,
|
||||
deviceOsVer : deviceOsVer,
|
||||
deviceAppVer : deviceAppVer
|
||||
}),
|
||||
success: function (result) {
|
||||
const data = JSON.parse(result.resBody.result);
|
||||
if(data.result == 'success') {
|
||||
sessionStorage.setItem("sessDvcId", data.deviceId);
|
||||
console.log('디바이스 정보 저장');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
console.log('디바이스 정보 저장 실패');
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('[Skipped] Not in app context or already processed.');
|
||||
}
|
||||
}
|
||||
|
||||
// 엡에서 로그인후 회원-디바이스정보 한번에 입력 or 수정
|
||||
function fn_save_mbrdvc_info(isAuth) {
|
||||
console.log('[Called] fn_save_mbrdvc_info()')
|
||||
|
||||
// 로그인상태가 아니라면 리턴
|
||||
if(!isAuth) return;
|
||||
|
||||
// 저장후 sessionStorage.sessMbrId 값을 설정함으로 해당값이 없는경우에만 저장
|
||||
var sessMbrId = sessionStorage.getItem("sessMbrId");
|
||||
|
||||
if(window.app && !sessMbrId) {
|
||||
var json_str = window.app.get_device_info();
|
||||
var result = JSON.parse(json_str);
|
||||
//console.log(json_str);
|
||||
|
||||
var tokenKey = result.tokenKey; // push key
|
||||
var deviceId = result.deviceId; // 디바이스 고유ID(IME)
|
||||
var deviceOsNm = result.deviceOsNm; // 운영체제이름
|
||||
var deviceOsVer = result.deviceOsVer; // 운영체제버전
|
||||
var deviceAppVer = result.deviceAppVer; // 앱버전
|
||||
var pushAgreAt = result.pushAgreAt; // 알림 동의 여부
|
||||
var phacAgreAt = result.phacAgreAt; // 신체활동접근 동의 여부
|
||||
|
||||
// 앱디바이스 정보 저장
|
||||
if(typeof deviceId !== 'undefined' && deviceId !== '' && !sessMbrId) {
|
||||
$.ajax({
|
||||
url: '/sopmal/app/insertAppMbrDvcInfo',
|
||||
type: 'post',
|
||||
contentType: 'application/json; charset=UTF-8',
|
||||
data : JSON.stringify({
|
||||
fcmToken : tokenKey,
|
||||
pushAgreAt : pushAgreAt,
|
||||
phacAgreAt : phacAgreAt,
|
||||
deviceId : deviceId,
|
||||
deviceOsNm : deviceOsNm,
|
||||
deviceOsVer : deviceOsVer,
|
||||
deviceAppVer : deviceAppVer
|
||||
}),
|
||||
success: function (result) {
|
||||
const data = JSON.parse(result.resBody.result);
|
||||
if(data.result == 'success') {
|
||||
sessionStorage.setItem("sessDvcId", data.deviceId);
|
||||
sessionStorage.setItem("sessMbrId", data.mbrId);
|
||||
console.log('[저장] 회원-디바이스정보 정보 저장');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
console.log('[오류] 회원-디바이스정보 저장 실패');
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
console.log('[Skipped] Not in app context or already processed.');
|
||||
}
|
||||
}
|
||||
|
||||
// 푸시알림 터치 웹 콜백 - pushType : 푸시타입, data : 전달받은 data
|
||||
function callback_push_receive_process (pushType , data){
|
||||
if(window.app) {
|
||||
console.log("[Called] callback_push_receive_process()");
|
||||
console.log(data);
|
||||
try {
|
||||
// JSON 문자열 객체 파싱
|
||||
const parsedData = (typeof data === 'string') ? JSON.parse(data) : data;
|
||||
|
||||
if (pushType !== '') {
|
||||
const dataUrl = parsedData.url || '';
|
||||
const dataKey = parsedData.key || '';
|
||||
const dataExt = parsedData.ext || '';
|
||||
|
||||
if(dataUrl !== '') {
|
||||
const hasQuery = dataUrl.includes('?');
|
||||
var linkUrl = '';
|
||||
linkUrl += dataUrl;
|
||||
if (dataKey !== '') linkUrl += (hasQuery ? '&' : '?') + 'key=' + dataKey;
|
||||
if (dataExt !== '') linkUrl += '&ext=' + dataExt;
|
||||
|
||||
location.href = linkUrl;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Invalid JSON data received:", data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 푸시 발송 테스트
|
||||
function fn_push_send() {
|
||||
if(window.app) {
|
||||
var json_str = window.app.get_device_info();
|
||||
var result = JSON.parse(json_str);
|
||||
var tokenKey = result.tokenKey;
|
||||
//var tokenKey = "cKqrsjAZSXW1GlefD96MkH:APA91bH37JY5BUQx5m5PMNBdrFsapKtWk0xs8WJNAaFqra3_gj4msjLOTu3e-tRTCrczraL3N5KmRbCcSvPgOfDiQJKlc7LqmCR0WpDwFanLeZi-t-AsGwc";
|
||||
var pushSj = "테스트 발송";
|
||||
var pushCn = "테스트 발송입니다.";
|
||||
var pushType = "notice";
|
||||
var imgFilCours = "https://img.soju1sake1.com/NC/goods/1/2017/06/116_tmp_2a6add67ad603d452d32743dac0410112327view.jpg";
|
||||
var dataUrl = "/sopmal/goods/selectGoodsDtl?goodsInnb=857";
|
||||
var dataKey = "";
|
||||
var dataExt = "";
|
||||
|
||||
var arrFcmToken = [tokenKey];
|
||||
|
||||
if(typeof tokenKey !== 'undefined' && tokenKey !== '') {
|
||||
$.ajax({
|
||||
url: '/sopmal/app/procTestPushNotification',
|
||||
type: 'post',
|
||||
contentType: 'application/json; charset=UTF-8',
|
||||
data : JSON.stringify({
|
||||
fcmToken : tokenKey,
|
||||
arrFcmToken : arrFcmToken,
|
||||
pushSj : pushSj,
|
||||
pushCn : pushCn,
|
||||
pushType : pushType,
|
||||
imgFilCours : imgFilCours,
|
||||
dataUrl : dataUrl,
|
||||
dataKey : dataKey,
|
||||
dataExt : dataExt
|
||||
}),
|
||||
success: function (result) {
|
||||
const data = JSON.parse(result.resBody.result);
|
||||
if(data.result == 'success') {
|
||||
console.log('테스트 푸시 발송 성공');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
console.log('테스트 푸시 발송 실패');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 딥링크 페이지 이동
|
||||
function callback_link(shopcd , type , data){
|
||||
if(window.app) {
|
||||
// http://dev.nutricore.co.kr/sopmal/app/openApp?linkType=reward&bnfDvCd=150&strInnb=1527
|
||||
// var strparam = '?type=' + linkType + '&data=' + bnfDvCd + '|' + strInnb;
|
||||
|
||||
console.log("[Called] callback_link()");
|
||||
console.log('callback_link shopcd : ' + shopcd);
|
||||
console.log('callback_link type : ' + type);
|
||||
console.log('callback_link data : ' + data);
|
||||
|
||||
var arrData = data.split('|');
|
||||
var bnfDvCd = arrData[0]; // 혜택구분코드
|
||||
var strInnb = arrData[1]; // 스토어고유번호
|
||||
|
||||
// 보상 처리
|
||||
if(type == 'reward'){
|
||||
location.href = '/sopmal/bnft/rewardProc?sopmalCd='+ shopcd +'&bnfDvCd='+ bnfDvCd +'&strInnb='+ strInnb;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 건강 데이터 이용 안내 모달 표시
|
||||
function fn_show_health_data_agreement_modal() {
|
||||
console.log('[Called] fn_show_health_data_agreement_modal()');
|
||||
|
||||
// 앱 환경에서만 실행
|
||||
if(!window.app) {
|
||||
console.log('[Skipped] Not in app context.');
|
||||
return;
|
||||
}
|
||||
|
||||
// sessionStorage 체크 - 이미 표시한 경우 스킵
|
||||
var healthDataAgreementShown = sessionStorage.getItem("hdaShown");
|
||||
if(healthDataAgreementShown === 'Y') {
|
||||
console.log('[Skipped] Health data agreement modal already shown.');
|
||||
return;
|
||||
}
|
||||
|
||||
// sopmalCd 가져오기
|
||||
const $tabBar = $("#tabBarWishOrBnft");
|
||||
var sopmalCd = '';
|
||||
if ($tabBar.length > 0) {
|
||||
sopmalCd = $tabBar.data('sopmalcd');
|
||||
}
|
||||
|
||||
// 개인정보처리방침 링크 설정
|
||||
var privacyPolicyUrl = '';
|
||||
if(sopmalCd == 'NC') {
|
||||
privacyPolicyUrl = 'https://nutricore.co.kr/sopmal/main/selectClause?stplatDvCd=02';
|
||||
} else if(sopmalCd == 'DT') {
|
||||
privacyPolicyUrl = 'https://doctorlean.co.kr/sopmal/main/selectClause?stplatDvCd=02';
|
||||
}
|
||||
|
||||
// 모달 HTML 생성
|
||||
var modalHtml = `
|
||||
<div id="healthDataAgreementModal" class="microModal microAlert" aria-modal="true">
|
||||
<div class="microModal__overlay" tabindex="-1">
|
||||
<div class="microModal__container" role="dialog" aria-modal="true">
|
||||
<div class="microModal__body">
|
||||
<div class="microModal__top">
|
||||
<div class="modal-header__title">건강 데이터 이용 안내</div>
|
||||
</div>
|
||||
<div class="microModal__content ck-content">
|
||||
<p>본 앱은 만보기 서비스를 위해 Google Fit에서 제공하는 걸음 수 데이터를 수집·이용합니다.</p>
|
||||
<br>
|
||||
<p>수집된 데이터는 만보기 기능 제공, 이동거리 계산, 마일리지 적립 조건 판단에만 사용되며, 다른 목적으로는 이용되지 않습니다.</p>
|
||||
<br>
|
||||
<p>자세한 내용은 <a href="${privacyPolicyUrl}" target="_blank" style="color: #007bff; text-decoration: underline;">개인정보처리방침</a>에서 확인하실 수 있습니다.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="microModal__btnContainer">
|
||||
<button class="microModal__btn microModal__btn-primary" onclick="fn_confirm_health_data_agreement()">확인</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// 기존 모달이 있다면 제거
|
||||
$('#healthDataAgreementModal').remove();
|
||||
|
||||
// 모달 HTML을 body에 추가
|
||||
$('body').append(modalHtml);
|
||||
|
||||
// MicroModal 초기화 (혹시 없다면)
|
||||
if(typeof MicroModal !== 'undefined') {
|
||||
MicroModal.init({
|
||||
disableScroll: true,
|
||||
awaitCloseAnimation: true
|
||||
});
|
||||
}
|
||||
|
||||
// 모달 표시
|
||||
if(typeof openModal === 'function') {
|
||||
openModal('healthDataAgreementModal');
|
||||
} else if(typeof MicroModal !== 'undefined') {
|
||||
MicroModal.show('healthDataAgreementModal');
|
||||
}
|
||||
|
||||
console.log('[Shown] Health data agreement modal displayed.');
|
||||
}
|
||||
|
||||
// 건강 데이터 이용 안내 모달 확인 버튼 클릭
|
||||
function fn_confirm_health_data_agreement() {
|
||||
console.log('[Called] fn_confirm_health_data_agreement()');
|
||||
|
||||
// sessionStorage에 표시 완료 저장
|
||||
sessionStorage.setItem("hdaShown", "Y");
|
||||
|
||||
// 모달 닫기
|
||||
fn_close_health_data_agreement_modal();
|
||||
|
||||
console.log('[Confirmed] Health data agreement confirmed and saved.');
|
||||
}
|
||||
|
||||
// 건강 데이터 이용 안내 모달 닫기
|
||||
function fn_close_health_data_agreement_modal() {
|
||||
console.log('[Called] fn_close_health_data_agreement_modal()');
|
||||
|
||||
// 모달 닫기
|
||||
if(typeof closeModal === 'function') {
|
||||
closeModal('healthDataAgreementModal');
|
||||
} else if(typeof MicroModal !== 'undefined') {
|
||||
MicroModal.close('healthDataAgreementModal');
|
||||
}
|
||||
|
||||
// DOM에서 모달 제거
|
||||
setTimeout(function() {
|
||||
$('#healthDataAgreementModal').remove();
|
||||
}, 300); // 애니메이션 완료 후 제거
|
||||
}
|
||||
Reference in New Issue
Block a user