merge master into develop - CscListRForm.jsp FAQ 아코디언 버그 수정
This commit is contained in:
477
build/resources/main/static/js/dlvylc/dlvylc.js
Normal file
477
build/resources/main/static/js/dlvylc/dlvylc.js
Normal file
@@ -0,0 +1,477 @@
|
||||
/**********************************************
|
||||
마이페이지 > 배송지 관리
|
||||
***********************************************/
|
||||
const fn_select_dlvylcList = function (pageIndex) {
|
||||
let selectForm = $(".dlvylcList").serialize();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/selectDlvylcManagePopup',
|
||||
data: {
|
||||
selectForm
|
||||
},
|
||||
success: function (data) {
|
||||
$("#content").html(data);
|
||||
$(".mbtlnb").each(function () {
|
||||
if ($(this).text().length > 0) {
|
||||
let mbtlnb = $(this).text();
|
||||
mbtlnb = fn_format_mbtlnb(mbtlnb);
|
||||
$(this).text(mbtlnb);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**********************************************
|
||||
기본배송지 수정 (마이페이지 > 배송지 관리)
|
||||
***********************************************/
|
||||
const fn_save_dftDlvylcAt = function (msg, adbkInnb) {
|
||||
if (confirm("기본배송지를 수정하시겠습니까?")) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/updatedftDlvylcAtUpdt',
|
||||
data: {
|
||||
adbkInnb: adbkInnb
|
||||
},
|
||||
success: function () {
|
||||
alert(msg);
|
||||
fn_select_dlvylcList(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
리턴 formId 세팅
|
||||
***********************************************/
|
||||
let formIdSave;
|
||||
const fn_set_formId = function (formId) {
|
||||
if (formId !== ''){
|
||||
formIdSave = formId;
|
||||
} else {
|
||||
formId = formIdSave;
|
||||
}
|
||||
|
||||
return formId;
|
||||
}
|
||||
/**********************************************
|
||||
배송지 관리 팝업 ()
|
||||
***********************************************/
|
||||
const fn_move_dlvylc_manage_pop = function (pageIndex,callback, formId = '') {
|
||||
if (callback == undefined) {
|
||||
callback = 'fn_set_dlvylc';
|
||||
}
|
||||
formId = fn_set_formId(formId);
|
||||
console.log("배송지 관리 팝업 : ", formId);
|
||||
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/selectDlvylcManagePopup',
|
||||
data: {
|
||||
isPop: 'Y',
|
||||
pageIndex: pageIndex,
|
||||
callbackNm: callback,
|
||||
formId: formId
|
||||
},
|
||||
success: function (data) {
|
||||
fn_close_modal('dlvylcManage');
|
||||
$('#modalDiv').html(data);
|
||||
$('#dlvylcManage').modal();
|
||||
$(".mbtlnbPop").each(function () {
|
||||
if($(this).text().length > 0){
|
||||
let mbtlnb = $(this).text().replace(/\s+/g, '');
|
||||
mbtlnb = fn_format_mbtlnb(mbtlnb);
|
||||
$(this).text(mbtlnb);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**********************************************
|
||||
배송지 관리 풀스크린 모달 ()
|
||||
***********************************************/
|
||||
const fn_move_dlvylc_manage_full = function (pageIndex, callback, formId = '') {
|
||||
if (callback == undefined) {
|
||||
callback = 'fn_set_dlvylc';
|
||||
}
|
||||
formId = fn_set_formId(formId);
|
||||
console.log("모바일 배송지 팝업 formId : ", formId);
|
||||
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/selectDlvylcManagePopup',
|
||||
data: {
|
||||
isPop: 'Y',
|
||||
isMobile: 'Y',
|
||||
pageIndex: pageIndex,
|
||||
callbackNm: callback,
|
||||
formId: formId
|
||||
},
|
||||
success: function (data) {
|
||||
$('#dlvyDiv').html(data);
|
||||
openModal2("address-management");
|
||||
$(".mbtlnbPop").each(function () {
|
||||
let mbtlnb = $(this).text();
|
||||
if(mbtlnb.length > 0){
|
||||
mbtlnb = fn_format_mbtlnb(mbtlnb);
|
||||
$(this).text(mbtlnb);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**********************************************
|
||||
배송지 등록 팝업 호출
|
||||
***********************************************/
|
||||
const fn_move_dlvylc_regpage_pop = function (isPop, dftDlvylcAt) {
|
||||
$("#dlvylcUpdate").remove();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/selectDlvylcRegistForm',
|
||||
success: function (data) {
|
||||
fn_close_modal('dlvylcManage');
|
||||
fn_close_modal('dlvylcRegist');
|
||||
$('#modalDiv').html(data);
|
||||
$('#isPop').val(isPop);
|
||||
$('#dlvylcRegist').modal();
|
||||
if (dftDlvylcAt == 'Y') {
|
||||
$('#dftDlvylcAt').prop("checked", true);
|
||||
}
|
||||
fn_set_event('.telno', 'keyup', fn_fmt_telno);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**********************************************
|
||||
배송지 등록 페이지
|
||||
***********************************************/
|
||||
const fn_move_dlvylc_regpage = function (dftDlvylcAt) {
|
||||
const hiddenForm = $("#hiddenForm");
|
||||
hiddenForm.submit();
|
||||
}
|
||||
/**********************************************
|
||||
배송지 등록
|
||||
***********************************************/
|
||||
const fn_insert_dlvylc = function (msg, data, isMobile) {
|
||||
$("#dlvylcUpdate").remove();
|
||||
let paramData = null;
|
||||
const registForm = $("#dlvylcRegistForm").serialize();
|
||||
if (data != null) {
|
||||
paramData = data;
|
||||
} else {
|
||||
paramData = registForm;
|
||||
}
|
||||
/*모바일과 pc 분기*/
|
||||
if (isMobile) {
|
||||
/*등록 마이크로모달 닫기*/
|
||||
MicroModal.close("dlvyConfirmModal");
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/insertDlvylcRegist',
|
||||
data: paramData,
|
||||
success: function () {
|
||||
/*등록 성공 마이크로모달 열기*/
|
||||
MicroModal.show("successModal");
|
||||
}
|
||||
});
|
||||
} else {//
|
||||
if (confirm('배송지를 등록하시겠습니까?')) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/insertDlvylcRegist',
|
||||
data: paramData,
|
||||
//contentType: "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
//dataType: "text",
|
||||
success: function () {
|
||||
alert(msg);
|
||||
let pop = $("#isPop").val();
|
||||
fn_close_modal('dlvylcManage');
|
||||
fn_close_modal('dlvylcRegist');
|
||||
if (pop == 'Y') {
|
||||
fn_move_dlvylc_manage_pop(1, 'fn_set_dlvylc');
|
||||
} else {
|
||||
fn_select_dlvylcList(1);
|
||||
//최근 배송지 form, 버튼 활성화 삭제
|
||||
$('#resentDlvylcForm').remove();
|
||||
$("#resentDlvylcBtn").removeClass("active");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
배송지 삭제
|
||||
***********************************************/
|
||||
const fn_delete_dlvylc = function (msg, adbkInnb,isPop,isMobile) {
|
||||
if(isMobile){
|
||||
openModal("confirm_del_alert");
|
||||
$("#delCfrmBtn").attr("adbk-innb", adbkInnb);
|
||||
}else{
|
||||
if (confirm('배송지를 삭제하시겠습니까?')) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/deleteDlvylcDel',
|
||||
data: {
|
||||
adbkInnb: adbkInnb
|
||||
},
|
||||
success: function (data) {
|
||||
alert(msg);
|
||||
if (isPop == 'Y') {
|
||||
fn_move_dlvylc_manage_pop(1, 'fn_set_dlvylc');
|
||||
} else {
|
||||
fn_select_dlvylcList(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
/**********************************************
|
||||
배송지 수정 팝업 이동(페이지)
|
||||
***********************************************/
|
||||
const fn_move_dlvylc_uptpage_pop = function (pageIndex, adbkInnb, isPop) {
|
||||
$("#dlvylcRegist").remove();
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/sopmal/mpage/mbr/selectDlvylcUpdtPopupForm',
|
||||
data: {
|
||||
adbkInnb: adbkInnb,
|
||||
pageIndex: pageIndex
|
||||
},
|
||||
success: function (data) {
|
||||
fn_close_modal('dlvylcManage');
|
||||
fn_close_modal('dlvylcUpdate');
|
||||
$('#modalDiv').html(data);
|
||||
$('#isPop').val(isPop);
|
||||
$('#dlvylcUpdate').modal();
|
||||
fn_set_event('.telno', 'keyup', fn_fmt_telno);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**********************************************
|
||||
배송지 수정 팝업 이동(모달)
|
||||
***********************************************/
|
||||
const fn_pop_dlvylc_upt_pop = function (pageIndex, adbkInnb) {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/sopmal/mpage/mbr/selectDlvylcUpdtMobilePopupForm',
|
||||
data: {
|
||||
adbkInnb: adbkInnb,
|
||||
pageIndex: pageIndex
|
||||
},
|
||||
success: function (data) {
|
||||
closeModal("address-management");
|
||||
$("#dlvyDiv").html(data);
|
||||
openModal("dlvylcUpdtFormPop");
|
||||
fn_set_event('.telno', 'keyup', fn_fmt_telno);
|
||||
}
|
||||
});
|
||||
}
|
||||
/**********************************************
|
||||
배송지 수정 페이지
|
||||
***********************************************/
|
||||
const fn_move_dlvylc_uptpage = function (pageIndex, adbkInnb, isPop) {
|
||||
const hiddenForm = $("#hiddenForm");
|
||||
if (hiddenForm.length > 0) {
|
||||
hiddenForm.remove();
|
||||
}
|
||||
const form = document.createElement("form");
|
||||
form.id = "hiddenForm";
|
||||
form.action = "/sopmal/mpage/mbr/selectDlvylcUpdtPopupForm";
|
||||
form.method = "POST";
|
||||
fn_create_input("adbkInnb", adbkInnb, form);
|
||||
fn_create_input("pageIndex", pageIndex, form);
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
}
|
||||
|
||||
//input 생성 함수
|
||||
const fn_create_input = (name, value, tgtForm) => {
|
||||
const input = document.createElement('input');
|
||||
input.setAttribute("type", "hidden");
|
||||
input.setAttribute("name", name);
|
||||
input.setAttribute("value", value);
|
||||
tgtForm.appendChild(input);
|
||||
}
|
||||
/**********************************************
|
||||
배송지 수정
|
||||
***********************************************/
|
||||
const fn_update_dlvylc = function (pageIndex,msg,isMobile) {
|
||||
const updateForm = $("#dlvylcUpdtForm").serialize();
|
||||
if (isMobile !== '') {
|
||||
MicroModal.close("updtConfirmModal");
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/updateDlvylcUpdt',
|
||||
data: updateForm,
|
||||
success: function (data) {
|
||||
MicroModal.show("updtsuccessModal");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (confirm('배송지를 수정하시겠습니까?')) {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/sopmal/mpage/mbr/updateDlvylcUpdt',
|
||||
data: updateForm,
|
||||
success: function (data) {
|
||||
alert(msg);
|
||||
let pop = $("#isPop").val();
|
||||
fn_close_modal('dlvylcManage');
|
||||
fn_close_modal('dlvylcUpdate');
|
||||
if (pop == 'Y') {
|
||||
fn_move_dlvylc_manage_pop(1,'fn_set_dlvylc');
|
||||
} else {
|
||||
fn_select_dlvylcList(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
/**********************************************
|
||||
배송지 수정 팝업 밑에 취소 시 배송지 관리 팝업창으로 이동 ok
|
||||
***********************************************/
|
||||
const fn_move_dlvllcManage = function () {
|
||||
if ($("#isPop") == "Y") {
|
||||
fn_move_dlvylc_manage_pop(1);
|
||||
} else if ($("#isPop") == "N") {
|
||||
fn_close_modal('dlvylcUpdate');
|
||||
fn_select_dlvylcList(1);
|
||||
}
|
||||
}
|
||||
/**********************************************
|
||||
팝업 배송지 등록 시 도로명, 지번 주소 구분 value값 넣기 ok
|
||||
***********************************************/
|
||||
const fn_select_dlvylc_postcode = function (data) {
|
||||
$('#zip').val(data.postcode);
|
||||
$('#adresDv').val(data.addressType);
|
||||
if (data.addressType == '01') {
|
||||
$('#adres').val(data.roadAddress + data.extraAddress);
|
||||
} else {
|
||||
$('#adres').val(data.jibunAddress + data.extraAddress);
|
||||
}
|
||||
if($("#postModal").length > 0){
|
||||
closeModal("postModal");
|
||||
}
|
||||
}
|
||||
/**********************************************
|
||||
배송지 등록 시 도로명, 지번 주소 구분 value값 넣기 ok
|
||||
***********************************************/
|
||||
const fn_set_mngrOrdrDlvylc_postcode = function (data) {
|
||||
$("#ordrRecpntNm").val(data.recpntNm);
|
||||
$("#ordrDtlAdres").val(data.dtlAdres);
|
||||
$("#ordrRecpntMbtlnb").val(data.mbtlnb);
|
||||
$('#ordrDlvylcZip').val(data.postcode);
|
||||
$('#ordrAdresDvCd').val(data.addressType);
|
||||
if (data.addressType == '01') {
|
||||
$('#ordrAdres').val(data.roadAddress + data.extraAddress);
|
||||
} else {
|
||||
$('#ordrAdres').val(data.jibunAddress + data.extraAddress);
|
||||
}
|
||||
console.log("data.recpntNm", data.recpntNm);
|
||||
if (data.recpntNm == null) {
|
||||
$("#newDlvyLc").prop("checked", true);
|
||||
} else {
|
||||
$("#defaultDlvyLc").prop("checked", true);
|
||||
}
|
||||
}
|
||||
/**********************************************
|
||||
배송지 관리 팝업에서 배송 정보 가져오기
|
||||
***********************************************/
|
||||
const fn_select_mngrOrdr_postcode = function (callback, index, formId = '') {
|
||||
let extraAddress = "";
|
||||
callback({
|
||||
postcode: $(".zip").eq(index).val(),
|
||||
addressType: $(".adresDv").eq(index).val(),
|
||||
roadAddress: $(".rnmAdres").eq(index).val(),
|
||||
jibunAddress: $(".lnbAdres").eq(index).val(),
|
||||
recpntNm: $(".recpntNmR").eq(index).val(),
|
||||
dtlAdres: $(".dtlAdres").eq(index).val(),
|
||||
dlvylcAreaCd: $(".dlvylcAreaCd").eq(index).val(),
|
||||
prefcd: $(".prefcd").eq(index).val(),
|
||||
cstmclerCd: $(".cstmclerCd").eq(index).val(),
|
||||
mbtlnb: $(".mbtlnb").eq(index).val(),
|
||||
extraAddress: extraAddress
|
||||
}, formId);
|
||||
fn_close_modal("dlvylcManage");
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
배송지 관리 팝업 언어 설정
|
||||
***********************************************/
|
||||
const fn_toggle_langHeader = function () {
|
||||
var id = $('[name=dlvylcAreaCd]:checked').attr('id');
|
||||
|
||||
$('.langKr, .langJp').hide();
|
||||
$('.' + id).show();
|
||||
|
||||
if (id == 'langJp') {
|
||||
$('#zip').prop('readonly', false);
|
||||
$('#cstmclerCd').prop('disabled', true);
|
||||
$('#prefcode').prop('disabled', false);
|
||||
} else {
|
||||
$('#zip').prop('readonly', true);
|
||||
$('#cstmclerCd').prop('disabled', false);
|
||||
$('#prefcode').prop('disabled', true);
|
||||
|
||||
$('#postcodeAlert').hide();
|
||||
}
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
ibsnet api 호출
|
||||
***********************************************/
|
||||
const fn_select_postcodeJp = function () {
|
||||
$('#postcodeAlert').hide();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'https://zipcloud.ibsnet.co.jp/api/search?zipcode=' + $('#zip').val(),
|
||||
dataType: 'jsonp',
|
||||
success: function(data) {
|
||||
if(data.status == 200) {
|
||||
let result = data.results[0];
|
||||
|
||||
let adres = result.address1;
|
||||
let dtlAdres = [result.address2, result.address3].join(" ");
|
||||
let prefcode = result.prefcode;
|
||||
|
||||
$("#adres").val(adres);
|
||||
$("#dtlAdres").val(dtlAdres);
|
||||
$("#prefcode").val(prefcode);
|
||||
$("#adresDv").val("01");
|
||||
} else {
|
||||
$('#postcodeAlert').show();
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error('API 호출 실패:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**********************************************
|
||||
배송지 관리 팝업 언어별 form 초기화
|
||||
***********************************************/
|
||||
let dlvylcFormPreValues = {};
|
||||
const fn_clear_dlvylcForm = function () {
|
||||
const tableInputs = $("#dlvylcFormTable").find("input[name]");
|
||||
|
||||
if (Object.keys(dlvylcFormPreValues).length == 0) {
|
||||
tableInputs.each(function () {
|
||||
const input = $(this);
|
||||
const name = input.attr("name");
|
||||
dlvylcFormPreValues[name] = input.val();
|
||||
input.val("");
|
||||
});
|
||||
} else {
|
||||
tableInputs.each(function () {
|
||||
const input = $(this);
|
||||
const name = input.attr("name");
|
||||
const currentValue = input.val();
|
||||
input.val(dlvylcFormPreValues[name] ?? "");
|
||||
dlvylcFormPreValues[name] = currentValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user