merge master into develop - CscListRForm.jsp FAQ 아코디언 버그 수정
This commit is contained in:
@@ -0,0 +1,665 @@
|
||||
|
||||
/*********************************
|
||||
장바구니 담기 버튼
|
||||
********************************/
|
||||
|
||||
$(document).on('click', '.addCart', function() {
|
||||
|
||||
//세션스토리지 없으면 pass
|
||||
if(fn_is_empty(adScriptAddCart)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//세션스토리지에 해당 매체의 장바구니 담기가 있으면 해당 스크립트실행
|
||||
|
||||
adScriptAddCart.forEach(item =>{
|
||||
|
||||
if(item.adMediaDvCd ==='06'){
|
||||
criteoAddCart(item)
|
||||
}
|
||||
|
||||
if(item.adMediaDvCd ==='01'){
|
||||
|
||||
googleAdsAddCart(item)
|
||||
}
|
||||
if(item.adMediaDvCd ==='02') {
|
||||
googleAnalyticsAddCart(item)
|
||||
}
|
||||
if(item.adMediaDvCd ==='03'){
|
||||
googleTagManagerAddCart()
|
||||
}
|
||||
if(item.adMediaDvCd ==='05'){
|
||||
kakaoMomentsAddCart(item)
|
||||
}
|
||||
if(item.adMediaDvCd ==='04'){
|
||||
metaAddCart(item)
|
||||
}
|
||||
|
||||
if(item.adMediaDvCd ==='14'){
|
||||
naverSrchAdsAddCart(item)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
function criteoAddCart(item) {
|
||||
const adMediaId = item.adMediaId
|
||||
let addCartScript = document.createElement('script');
|
||||
|
||||
let productDataArray = [];
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
|
||||
const productData = {
|
||||
id: productArr[i][4],
|
||||
price: productArr[i][3],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
addCartScript.innerHTML = `
|
||||
window.criteo_q = window.criteo_q || [];
|
||||
var deviceType = /iPad/.test(navigator.userAgent) ? "t" : /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m" : "d";
|
||||
window.criteo_q.push(
|
||||
{ event: "setAccount", account: ${adMediaId}},
|
||||
|
||||
// To Do 1. 현재 유저의 이메일 주소(공백 제거 및 소문자로 변환 후) 전달. 유저의 이메일을 알수 없는 상황이면 빈 문자열로 전달
|
||||
{ event: "setEmail", email: "", hash_method: "sha256" },
|
||||
{ event: "setEmail", email: "", hash_method: "md5" },
|
||||
|
||||
// To Do 2. 현재 유저의 저장된 배송지 우편번호. 유저의 배송지 우편번호를 알수 없는 상황이면 빈 문자열로 전달
|
||||
{ event: "setZipcode", zipcode: "" },
|
||||
|
||||
{ event: "setSiteType", type: deviceType},
|
||||
|
||||
/*// To Do 3. 현재 유저가 추가한 상품의 정보(상품 ID, 상품 단가, 추가한 수량)를 아래 객체 포멧으로 전달
|
||||
// 상품 ID는 태그에서 전달되는 상품 ID와 피드에서 전달 주신 상품 ID가 매칭이 되어야 함
|
||||
// 상품 단가는 유저가 선택한 상품의 단가로 전달(옵션 추가 가격 및 할인 가격 포함). 통화 기호 및 천단위 구분자는 제외
|
||||
// 수량은 유저가 선택한 값으로 전달
|
||||
// Tip 1. 복잡한 추가 구성 상품 및 옵션으로 인해 제대로된 상품 단가 및 수량 전달이 어려운 경우, 최종 가격으로 전달 후 수량은 1로 전달 해주셔도 됩니다.
|
||||
*/
|
||||
{ event: "addToCart", item:${JSON.stringify(productDataArray)}
|
||||
}
|
||||
);
|
||||
`;
|
||||
|
||||
document.head.appendChild(addCartScript);
|
||||
}
|
||||
|
||||
function googleAdsAddCart(item) {
|
||||
|
||||
let addCartScript = document.createElement('script');
|
||||
|
||||
const goodsNm = $('#goodsNm').val();
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
item_id: productArr[i][4],
|
||||
item_name: goodsNm,
|
||||
item_variant: productArr[i][0],
|
||||
price: productArr[i][3],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
totalPrice += productArr[i][3]
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
addCartScript.innerHTML = `
|
||||
gtag("event", "conversion", {
|
||||
send_to: "${item.adMediaId}/${item.instlPgeLbl}",
|
||||
value: ${totalPrice},
|
||||
items: ${JSON.stringify(productDataArray)}
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(addCartScript);
|
||||
|
||||
}
|
||||
|
||||
function googleAnalyticsAddCart(item) {
|
||||
let addCartScript = document.createElement('script');
|
||||
|
||||
const goodsNm = $('#goodsNm').val()
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
item_id: productArr[i][4],
|
||||
item_name: goodsNm,
|
||||
item_variant: productArr[i][0],
|
||||
price: productArr[i][3],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
totalPrice += productArr[i][3]
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
addCartScript.innerHTML = `
|
||||
gtag("event", "add_to_cart", {
|
||||
currency: "KRW",
|
||||
value: ${totalPrice},
|
||||
items: ${JSON.stringify(productDataArray)}
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(addCartScript);
|
||||
|
||||
}
|
||||
|
||||
function googleTagManagerAddCart() {
|
||||
let addCartScript = document.createElement('script');
|
||||
|
||||
const goodsNm = $('#goodsNm').val()
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
item_id: productArr[i][4],
|
||||
item_name: goodsNm,
|
||||
item_variant: productArr[i][0],
|
||||
price: productArr[i][3],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
totalPrice += productArr[i][3]
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
addCartScript.innerHTML = `
|
||||
dataLayer.push({ ecommerce: null });
|
||||
dataLayer.push({
|
||||
event: "add_to_cart",
|
||||
ecommerce: {
|
||||
currency: "KRW",
|
||||
value: ${totalPrice},
|
||||
items: ${JSON.stringify(productDataArray)}
|
||||
}
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(addCartScript);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function kakaoMomentsAddCart(item) {
|
||||
const adMediaId = item.adMediaId;
|
||||
const goodsInnb = $('#goodsInnb').val();
|
||||
|
||||
let kakaoScript = document.createElement('script');
|
||||
kakaoScript.type = 'text/javascript';
|
||||
kakaoScript.charset = 'UTF-8';
|
||||
kakaoScript.src = '//t1.daumcdn.net/kas/static/kp.js';
|
||||
|
||||
document.head.appendChild(kakaoScript);
|
||||
|
||||
let kakaoScript2 = document.createElement('script')
|
||||
kakaoScript2.type ='text/javascript';
|
||||
kakaoScript2.innerHTML = `kakaoPixel('${adMediaId}').addToCart({
|
||||
id: '${goodsInnb}'
|
||||
});`;
|
||||
document.head.appendChild(kakaoScript2);
|
||||
}
|
||||
|
||||
function metaAddCart(item) {
|
||||
let addCartScript = document.createElement('script');
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
id: productArr[i][4],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
totalPrice += productArr[i][3]
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
addCartScript.innerHTML = `
|
||||
fbq('track', 'AddToCart', {
|
||||
value: ${totalPrice},
|
||||
currency: 'KRW',
|
||||
contents: ${JSON.stringify(productDataArray)},
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(addCartScript);
|
||||
|
||||
}
|
||||
|
||||
function naverSrchAdsAddCart(item) {
|
||||
const addCartScript = document.createElement('script');
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
const category = fn_nvl($('#ctgryNm').val(), '');
|
||||
const goodsNm = $('#goodsNm').val();
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
id: productArr[i][4],
|
||||
name: goodsNm,
|
||||
category: category,
|
||||
quantity: productArr[i][1],
|
||||
payAmount: productArr[i][3],
|
||||
option: productArr[i][0]
|
||||
};
|
||||
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
addCartScript.innerHTML = `
|
||||
if(window.wcs){
|
||||
if(!wcs_add) var wcs_add = {};
|
||||
wcs_add["wa"] = "${item.adMediaId}";
|
||||
var _conv = {};
|
||||
_conv.type = 'add_to_cart'; //(필수)
|
||||
_conv.items = [${JSON.stringify(productDataArray)}];
|
||||
wcs.trans(_conv);
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
document.head.appendChild(addCartScript);
|
||||
}
|
||||
|
||||
|
||||
/*********************************
|
||||
네이버페이 버튼
|
||||
********************************/
|
||||
$(document).on('click', '.npay_btn_link', function() {
|
||||
|
||||
//세션스토리지 없으면 pass
|
||||
if(fn_is_empty(adScriptNpayBtn)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//세션스토리지에 해당 매체의 npay 담기가 있으면 해당 스크립트 실행
|
||||
adScriptNpayBtn.forEach(item => {
|
||||
|
||||
if(item.adMediaDvCd ==='01'){
|
||||
googleAdsNpay(item)
|
||||
}
|
||||
|
||||
if(item.adMediaDvCd ==='02'){
|
||||
googleAnalyticNpay(item)
|
||||
}
|
||||
|
||||
if(item.adMediaDvCd ==='03'){
|
||||
googleTagManagerNpay(item)
|
||||
}
|
||||
|
||||
if(item.adMediaDvCd ==='04'){
|
||||
metaNpay(item)
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
function googleAdsNpay(item) {
|
||||
let npayScript = document.createElement('script');
|
||||
|
||||
const goodsNm = $('#goodsNm').val()
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
item_id: productArr[i][4],
|
||||
item_name: goodsNm,
|
||||
item_variant: productArr[i][0],
|
||||
price: productArr[i][3],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
totalPrice += productArr[i][3]
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
const npayMediaId = item.adMediaId
|
||||
const npayLbl = item.instlPgeLbl
|
||||
const naverBtnClickId = item.npayButtonId
|
||||
npayScript.innerHTML = `
|
||||
gtag("event", "conversion", {
|
||||
transaction_id: ${naverBtnClickId},
|
||||
'send_to': '${npayMediaId}/${npayLbl}',
|
||||
value: ${totalPrice},
|
||||
items: ${JSON.stringify(productDataArray)}
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(npayScript);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function googleAnalyticNpay(item) {
|
||||
let npayScript = document.createElement('script');
|
||||
|
||||
const goodsNm = $('#goodsNm').val()
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
item_id: productArr[i][4],
|
||||
item_name: goodsNm,
|
||||
item_variant: productArr[i][0],
|
||||
price: productArr[i][3],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
totalPrice += productArr[i][3]
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const npayButtonId = item.npayButtonId
|
||||
npayScript.innerHTML = `
|
||||
gtag("event", "npay_click", {
|
||||
transaction_id: ${npayButtonId},
|
||||
currency: "KRW",
|
||||
value: ${totalPrice},
|
||||
items: ${JSON.stringify(productDataArray)}
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(npayScript);
|
||||
|
||||
}
|
||||
|
||||
function googleTagManagerNpay(item) {
|
||||
let npayScript = document.createElement('script');
|
||||
|
||||
const goodsNm = $('#goodsNm').val()
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
item_id: productArr[i][4],
|
||||
item_name: goodsNm,
|
||||
item_variant: productArr[i][0],
|
||||
price: productArr[i][3],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
totalPrice += productArr[i][3]
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
npayScript.innerHTML = `
|
||||
dataLayer.push({ ecommerce: null });
|
||||
dataLayer.push({
|
||||
event: "npay_click",
|
||||
ecommerce: {
|
||||
transaction_id: ${item.npayButtonId},
|
||||
currency: "KRW",
|
||||
value: ${totalPrice},
|
||||
items: ${JSON.stringify(productDataArray)}
|
||||
}
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(npayScript);
|
||||
|
||||
}
|
||||
|
||||
function metaNpay(item) {
|
||||
let npayScript = document.createElement('script');
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
let totalPrice = 0;
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
id: productArr[i][4],
|
||||
quantity: productArr[i][1]
|
||||
};
|
||||
|
||||
totalPrice += productArr[i][3]
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}
|
||||
|
||||
npayScript.innerHTML = `
|
||||
fbq('trackCustom', 'NpayConversion', {
|
||||
value: ${totalPrice},
|
||||
currency: 'KRW',
|
||||
contents: ${JSON.stringify(productDataArray)},
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(npayScript);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*********************************
|
||||
취소/환불 요청 버튼
|
||||
********************************/
|
||||
function adscript_btnReturnRegist (data) {
|
||||
|
||||
//세션스토리지 없을 경우 pass
|
||||
if(fn_is_empty(adScriptReturnReq)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//세션스토리지에 해당 매체의 취소/환불요청이 있으면 해당 스크립트 실행
|
||||
adScriptReturnReq.forEach(item =>{
|
||||
if(item.adMediaDvCd ==='02'){
|
||||
googleAnalyticReturnReq(data)
|
||||
}
|
||||
|
||||
if(item.adMediaDvCd ==='03'){
|
||||
googleTagManagerReturnReq(data)
|
||||
}
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
function googleAnalyticReturnReq(data) {
|
||||
let refundScript = document.createElement('script');
|
||||
|
||||
|
||||
//data -> 취소/환불 완료 후 서버에서 전달받은 data로 (ajax done) 에서 받아서 처리
|
||||
refundScript.innerHTML = `
|
||||
gtag("event", "refund", {
|
||||
${JSON.stringify(data)}
|
||||
});
|
||||
`;
|
||||
|
||||
document.head.appendChild(refundScript);
|
||||
|
||||
}
|
||||
|
||||
|
||||
function googleTagManagerReturnReq(data) {
|
||||
|
||||
|
||||
//data -> 취소/환불 완료 후 서버에서 전달받은 data로 (ajax done) 에서 받아서 처리
|
||||
|
||||
let refundScript = document.createElement('script');
|
||||
|
||||
refundScript.innerHTML = `
|
||||
dataLayer.push({ ecommerce: null });
|
||||
dataLayer.push({
|
||||
event: "refund",
|
||||
ecommerce: {
|
||||
${JSON.stringify(data)}
|
||||
}
|
||||
});`
|
||||
|
||||
document.head.appendChild(refundScript);
|
||||
}
|
||||
|
||||
|
||||
/*********************************
|
||||
위시리스트 등록 버튼
|
||||
********************************/
|
||||
$(document).on('click', '#productMyWish', function() {
|
||||
|
||||
|
||||
//이미 찜이 되어있어 찜버튼을 누를 경우 찜이 취소되는 액션의 경우 제외
|
||||
if(!fn_is_empty($('#wslistInnb').val())){
|
||||
return false;
|
||||
}
|
||||
|
||||
//세션스토리지 없으면 pass
|
||||
if(fn_is_empty(adScriptWslistBtn)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//세션스토리지에 해당 매체의 npay 담기가 있으면 해당 스크립트 실행
|
||||
adScriptWslistBtn.forEach(item => {
|
||||
|
||||
if(item.adMediaDvCd ==='14'){
|
||||
naverSrchAdsAddWslist(item)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
function naverSrchAdsAddWslist(item) {
|
||||
|
||||
const wslistScript = document.createElement('script');
|
||||
wslistScript.type = 'text/javascript';
|
||||
|
||||
|
||||
// 데이터를 저장할 배열
|
||||
let productDataArray = [];
|
||||
|
||||
const goodsInnb = $('#goodsInnb').val();
|
||||
const goodsNm = $('#goodsNm').val();
|
||||
const category = fn_nvl($('#ctgryNm').val(), '');
|
||||
|
||||
if(productArr.length > 0){
|
||||
for(let i = 0; i < productArr.length; i++){
|
||||
// 객체로 저장
|
||||
const productData = {
|
||||
id: productArr[i][4],
|
||||
name: productArr[i][1],
|
||||
category: category,
|
||||
quantity: productArr[i][1],
|
||||
payAmount: productArr[i][3],
|
||||
option: productArr[i][0]
|
||||
};
|
||||
|
||||
// 배열에 추가
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
}else{
|
||||
//상품 옵션 선택없이 위시리스트 등록시 기본값 지정
|
||||
const productData = {
|
||||
id: goodsInnb,
|
||||
name: goodsNm,
|
||||
category: category,
|
||||
quantity: '0',
|
||||
payAmount: '0',
|
||||
option: ''
|
||||
};
|
||||
|
||||
productDataArray.push(productData);
|
||||
}
|
||||
|
||||
wslistScript.innerHTML = `
|
||||
if(window.wcs){
|
||||
if(!wcs_add) var wcs_add = {};
|
||||
wcs_add["wa"] = "${item.adMediaId}";
|
||||
var _conv = {};
|
||||
_conv.type = 'add_to_wishlist'; //(필수)
|
||||
_conv.items = [${JSON.stringify(productDataArray)}];
|
||||
wcs.trans(_conv);
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
document.head.appendChild(wslistScript);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user