fix : 화폐단위 변경 (원 → 円) fix : 관리자 상품 상세 - 공유버튼 제거 fix : 관리자 상품 등록/복사재등록, 구매이벤트 - 스타일 일부 변경 fix : 사용자 주문 상세 - 스타일 일부 변경
1121 lines
48 KiB
Plaintext
1121 lines
48 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
|
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
|
|
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
|
<%@ taglib prefix="ui" uri="http://www.winbit.kr/ctl/ui" %>
|
|
<%@ taglib prefix="f" uri="/WEB-INF/tlds/f.tld" %>
|
|
<%--
|
|
Class Name : GoodsSrchRForm.jsp
|
|
Description : 상품 검색 폼
|
|
Modification Information
|
|
|
|
수정일 수정자 수정내용
|
|
------- -------- ---------------------------
|
|
2024-05 리브가
|
|
--%>
|
|
<!DOCTYPE html>
|
|
<html lang="ko">
|
|
|
|
<head>
|
|
<%-- 공통 include --%>
|
|
<jsp:include page="/WEB-INF/views/comm/Include.jsp"/>
|
|
<spring:eval expression="@environment.getProperty('currency-unit.default')" var="curUnit"/>
|
|
</head>
|
|
|
|
<script>
|
|
//장바구니 버튼 선택 배열
|
|
let productArr = []
|
|
$(document).ready(function () {
|
|
|
|
let pageIndex = '<c:out value="${ resultMap.BOGoodsVO.pageIndex }"/>';
|
|
|
|
fn_select_list(pageIndex);
|
|
|
|
$('#listForm').on('keydown', function (event) {
|
|
if (event.keyCode === 13) {
|
|
//event.preventDefault();
|
|
fn_select_list(1);
|
|
}
|
|
});
|
|
|
|
//가격
|
|
$('.searchPrice__select__btn').on('click', function () {
|
|
// 모든 버튼에서 선택 표시 제거
|
|
$('.searchPrice__select__btn').removeClass('selected');
|
|
|
|
// 현재 클릭된 버튼에 selected 클래스 추가
|
|
$(this).addClass('selected');
|
|
|
|
$('#priceRange').val($(this).val());
|
|
|
|
var startPric = null;
|
|
var endPric = null;
|
|
var buttonText = $(this).text();
|
|
var curUnit = '${curUnit}';
|
|
|
|
switch (buttonText) {
|
|
case '전체':
|
|
startPric = null;
|
|
endPric = null;
|
|
break;
|
|
case '~ 1000' + curUnit:
|
|
startPric = 0;
|
|
endPric = 1000;
|
|
break;
|
|
case '1000 ~ 5000' + curUnit:
|
|
startPric = 1000;
|
|
endPric = 5000;
|
|
break;
|
|
case '5000 ~ 15000' + curUnit:
|
|
startPric = 5000;
|
|
endPric = 15000;
|
|
break;
|
|
case '15000' + curUnit + ' 이상':
|
|
startPric = 15000;
|
|
endPric = null;
|
|
break;
|
|
default:
|
|
startPric = null;
|
|
endPric = null;
|
|
break;
|
|
}
|
|
|
|
$('#startPric').val(startPric);
|
|
$('#endPric').val(endPric);
|
|
|
|
fn_select_list(1);
|
|
|
|
return false;
|
|
});
|
|
|
|
// 상품 정렬
|
|
$('.subList__sort__item').on('click', function () {
|
|
|
|
// 모든 버튼에서 선택 표시 제거
|
|
$('.subList__sort__item').removeClass('current');
|
|
|
|
// 현재 클릭된 버튼에 current 클래스 추가
|
|
$(this).addClass('current');
|
|
|
|
let sortDv = $(this).attr('data-value');
|
|
|
|
$('#sortDv').val(sortDv);
|
|
fn_select_list(1);
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
const fn_create_input = function (type, name, value, tgtForm) {
|
|
const input = document.createElement('input');
|
|
input.setAttribute("type", type);
|
|
input.setAttribute("name", name);
|
|
input.setAttribute("value", value);
|
|
tgtForm.appendChild(input);
|
|
}
|
|
|
|
/* ********************************************************
|
|
* 목록 조회
|
|
******************************************************** */
|
|
const fn_select_list = function (pageIndex, pageUnit) {
|
|
let dataStr;
|
|
if (!pageIndex) {
|
|
$('#pageIndex').val(1);
|
|
} else {
|
|
$('#pageIndex').val(pageIndex);
|
|
}
|
|
|
|
dataStr = $('#listForm').serialize() + '&pageUnit=' + 16
|
|
|
|
$.ajax({
|
|
type: "post",
|
|
url: "<c:url value="/sopmal/goods/selectGoodsSrchList"/>",
|
|
data: dataStr,
|
|
success: function (resultHtml) {
|
|
$('#pageDiv').html(resultHtml);
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
//타임이벤트시 시간 떨어뜨리는 함수
|
|
$(window).on('load',function() {
|
|
|
|
//타임이벤트 카운트다운
|
|
let evtTmeExpsrAt = 'N'
|
|
$('input[name="evtTmeExpsrAt"]').each(function() {
|
|
if ($(this).val() === "Y") {
|
|
evtTmeExpsrAt = "Y";
|
|
return false; // Y를 찾으면 순회를 멈춤
|
|
}
|
|
});
|
|
if(evtTmeExpsrAt ==='Y'){
|
|
startCountdown();
|
|
}
|
|
|
|
|
|
});
|
|
//타임 이벤트 카운트 다운
|
|
function startCountdown() {
|
|
|
|
if(fn_is_empty($('span[name^="remainTime"]'))){
|
|
return false;
|
|
}
|
|
|
|
// 각 span 태그의 remainTime을 처리합니다.
|
|
$('span[name^="remainTime"]').each(function() {
|
|
let remainTime = $(this).text().trim(); // 현재 span의 텍스트 가져오기
|
|
|
|
// 시간을 시, 분, 초로 분리
|
|
if (remainTime === 'N') {
|
|
return false; // remainTime이 'N'이면 중지
|
|
}
|
|
|
|
let [hours, minutes, seconds] = remainTime.split(':').map(Number);
|
|
|
|
// 타이머 업데이트 함수
|
|
function updateTimer() {
|
|
// 현재 시간을 표시
|
|
let formattedHours = hours < 10 ? '0' + hours : hours;
|
|
let formattedMinutes = minutes < 10 ? '0' + minutes : minutes;
|
|
let formattedSeconds = seconds < 10 ? '0' + seconds : seconds;
|
|
|
|
let result_days = Math.floor(formattedHours / 24);
|
|
let result_hours = formattedHours % 24;
|
|
|
|
let result;
|
|
|
|
if(result_days >= 1) {
|
|
result = result_days + '일 ' + result_hours + ':' + formattedMinutes + ':' + formattedSeconds;
|
|
|
|
}else {
|
|
result = result_hours + ':' + formattedMinutes + ':' + formattedSeconds;
|
|
}
|
|
|
|
// 현재 span 태그에 업데이트
|
|
$(this).text(result);
|
|
|
|
// 1초 감소
|
|
seconds--;
|
|
|
|
// 초가 0보다 작아지면 분에서 1을 빼고 초를 59로 설정
|
|
if (seconds < 0) {
|
|
seconds = 59;
|
|
minutes--;
|
|
}
|
|
|
|
// 분이 0보다 작아지면 시간에서 1을 빼고 분을 59로 설정
|
|
if (minutes < 0) {
|
|
minutes = 59;
|
|
hours--;
|
|
}
|
|
|
|
// 시간이 0보다 작아지면 타이머 중지
|
|
if (hours < 0) {
|
|
$(this).text("00:00:00");
|
|
clearInterval(timerInterval);
|
|
}
|
|
}
|
|
|
|
// `this`를 업데이트 함수에서 사용할 수 있도록 바인딩
|
|
const timerInterval = setInterval(updateTimer.bind(this), 1000);
|
|
});
|
|
}
|
|
|
|
|
|
//장바구니 버튼 팝업 모달
|
|
const fn_open_addCart_modal = function (modalDivSltr, modalSlrt, url, param, callback) {
|
|
const submitType = 'POST';
|
|
|
|
$.ajax({
|
|
type: submitType,
|
|
contentType: 'application/json',
|
|
url: url,
|
|
data: param,
|
|
success: function (data) {
|
|
//callback함수가 없을 경우 default로 지정된 영역에 모달팝업 화면을 교체하고 화면 로딩
|
|
if (!callback) {
|
|
//이전에 선택한 상품 초기화
|
|
productArr = [];
|
|
$(modalSlrt).remove();
|
|
$(modalDivSltr).html(data);
|
|
$(modalSlrt).modal();
|
|
} else {
|
|
callback(data);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/*************************************************************
|
|
장바구니 목록 이동
|
|
**************************************************************/
|
|
const fn_move_cart_list = () => {
|
|
|
|
const form = $('<form></form>');
|
|
|
|
$(form).append($('<input/>', {type: 'hidden', name: 'cartDvCd', value: $('#cartDv-cart').val()}));
|
|
|
|
$(form).attr('target', '_self');
|
|
$(form).attr('method', 'post');
|
|
$(form).attr('action', '<c:url value="/sopmal/ordr/selectSpbk"/>');
|
|
|
|
$(form).appendTo('body');
|
|
|
|
//일반옵션 체크 해제
|
|
$('input[type="radio"]').prop('checked', false)
|
|
|
|
$(form).submit();
|
|
$(form).remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
//재고옵션 다음 셀렉트 옵션 값 호출
|
|
$(document).on('change', 'select[name="selectAddCartInvntryOptn"]', function () {
|
|
const id = $(this).attr('id');
|
|
let sourceId = id.slice(-1); // 아이디로 셀렉트 옵션 순서 확인
|
|
let nextId = (parseInt(sourceId)+1).toString();
|
|
const lastId = $('select[name="selectAddCartInvntryOptn"]:last').attr('id')
|
|
if($(this).val() === '0'){
|
|
return false;
|
|
}
|
|
|
|
|
|
const selectOptnVal1 = fn_nvl($('#selectAddCartInvntryOptn1 option:selected').text(),'').replaceAll(' ','').trim()
|
|
const selectOptnVal2 = fn_nvl($('#selectAddCartInvntryOptn2 option:selected').text(),'').replaceAll(' ','').trim()
|
|
const selectOptnVal3 = fn_nvl($('#selectAddCartInvntryOptn3 option:selected').text(),'').replaceAll(' ','').trim()
|
|
const selectOptnVal4 = fn_nvl($('#selectAddCartInvntryOptn4 option:selected').text(),'').replaceAll(' ','').trim()
|
|
|
|
let optnVal1 = selectOptnVal1 === '선택'?'': selectOptnVal1
|
|
let optnVal2 = selectOptnVal2 === '선택'?'': selectOptnVal2
|
|
let optnVal3 = selectOptnVal3 === '선택'?'': selectOptnVal3
|
|
let optnVal4 = selectOptnVal4 === '선택'?'': selectOptnVal4
|
|
|
|
switch (sourceId) {
|
|
case '1':
|
|
optnVal2 = '';
|
|
optnVal3 = '';
|
|
optnVal4 = '';
|
|
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':first').each(function() {
|
|
|
|
$(this).find('option').each(function () {
|
|
// value가 빈 문자열이 아닌 경우에만 삭제
|
|
if ($(this).val() !== '') {
|
|
$(this).remove().niceSelect('update');
|
|
}
|
|
});
|
|
});
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':first').val('').niceSelect('update')
|
|
break;
|
|
case '2':
|
|
optnVal3 = '';
|
|
optnVal4 = '';
|
|
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':lt(2)').each(function() {
|
|
|
|
$(this).find('option').each(function () {
|
|
// value가 빈 문자열이 아닌 경우에만 삭제
|
|
if ($(this).val() !== '') {
|
|
$(this).remove().niceSelect('update');
|
|
}
|
|
});
|
|
});
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':lt(2)').val('')
|
|
$('select[name="selectAddCartInvntryOptn"]').niceSelect('update')
|
|
break;
|
|
case '3':
|
|
optnVal4 = '';
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':lt(3)').each(function() {
|
|
|
|
$(this).find('option').each(function () {
|
|
// value가 빈 문자열이 아닌 경우에만 삭제
|
|
if ($(this).val() !== '') {
|
|
$(this).remove().niceSelect('update');
|
|
}
|
|
});
|
|
});
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':lt(3)').val('')
|
|
$('select[name="selectAddCartInvntryOptn"]').niceSelect('update')
|
|
break;
|
|
}
|
|
|
|
$.ajax({
|
|
type: 'post',
|
|
contentType : 'application/json',
|
|
url: '/sopmal/goods/selectGoodsOptnInfo',
|
|
data: JSON.stringify(
|
|
{
|
|
'goodsInnb' : $('#addCartGoodsInnb').val()
|
|
,'optnTy' : '02'
|
|
,'optnVal1' : optnVal1
|
|
,'optnVal2' : optnVal2
|
|
,'optnVal3' : optnVal3
|
|
,'optnVal4' : optnVal4
|
|
}
|
|
),
|
|
success: function (data) {
|
|
let str = JSON.parse(data.resBody.result);
|
|
|
|
if (str.result === 'success') {
|
|
|
|
//판매가
|
|
const slepricDscntAmt = $('#slepricDscntAmt').val()
|
|
|
|
switch (sourceId){
|
|
case '1' :
|
|
//1선택하면 서버 요청해서 2번 옵션값 받아옴
|
|
//2번에 option에 옵션값 뿌리기
|
|
const uniqueData2 = [];
|
|
const seenOptnVal2 = new Set();
|
|
str.goodsOptnList.forEach(item => {
|
|
if (!seenOptnVal2.has(item.optnVal2)){
|
|
uniqueData2.push(item);
|
|
seenOptnVal2.add(item.optnVal2);
|
|
}
|
|
});
|
|
|
|
|
|
uniqueData2.forEach(function(option) {
|
|
if($('#selectAddCartInvntryOptn'+nextId).attr('id') === lastId){
|
|
|
|
//재고품절시 노출여부
|
|
if(option.invntrySldoutExpsrAt ==='N'){
|
|
//옵션 노출 안함
|
|
|
|
//품절표시
|
|
}else if(option.disableAt === 'Y'){
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal2+ '(+' + addComma((parseInt(option.slepric) - parseInt(slepricDscntAmt))) +')' + '(품절)',
|
|
disabled: true
|
|
}));
|
|
|
|
}else{
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal2 + '(+' + addComma((parseInt(option.slepric) - parseInt(slepricDscntAmt))) +')'
|
|
}));
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
//재고품절시 노출여부
|
|
if(option.invntrySldoutExpsrAt ==='N'){
|
|
//옵션 노출 안함
|
|
|
|
//품절표시
|
|
}else if(option.disableAt === 'Y'){
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal2+'(품절)',
|
|
disabled: true
|
|
}));
|
|
|
|
}else{
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal2
|
|
}));
|
|
}
|
|
|
|
|
|
}
|
|
|
|
});
|
|
$('#selectAddCartInvntryOptn'+nextId).niceSelect('update');
|
|
|
|
break;
|
|
case '2' :
|
|
const uniqueData3 = [];
|
|
const seenOptnVal3 = new Set();
|
|
str.goodsOptnList.forEach(item => {
|
|
if (!seenOptnVal3.has(item.optnVal3)){
|
|
uniqueData3.push(item);
|
|
seenOptnVal3.add(item.optnVal3);
|
|
}
|
|
});
|
|
|
|
|
|
uniqueData3.forEach(function(option) {
|
|
|
|
if($('#selectAddCartInvntryOptn'+nextId).attr('id') === lastId){
|
|
|
|
//재고품절시 노출여부
|
|
if(option.invntrySldoutExpsrAt ==='N'){
|
|
//옵션 노출 안함
|
|
|
|
//품절표시
|
|
}else if(option.disableAt === 'Y'){
|
|
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal3 + '(+' + addComma((parseInt(option.slepric) - parseInt(slepricDscntAmt))) +')' + '(품절)',
|
|
disabled: true
|
|
}));
|
|
}else{
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal3 + '(+' + addComma((parseInt(option.slepric) - parseInt(slepricDscntAmt))) +')'
|
|
}));
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
//재고품절시 노출여부
|
|
if(option.invntrySldoutExpsrAt ==='N'){
|
|
//옵션 노출 안함
|
|
|
|
//품절표시
|
|
}else if(option.disableAt === 'Y'){
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal3+'(품절)',
|
|
disabled: true
|
|
}));
|
|
|
|
}else{
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal3
|
|
}));
|
|
}
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#selectAddCartInvntryOptn'+nextId).niceSelect('update');
|
|
|
|
break;
|
|
|
|
case '3' :
|
|
const uniqueData4 = [];
|
|
const seenOptnVal4 = new Set();
|
|
str.goodsOptnList.forEach(item => {
|
|
if (!seenOptnVal4.has(item.optnVal4)){
|
|
uniqueData4.push(item);
|
|
seenOptnVal4.add(item.optnVal4);
|
|
}
|
|
});
|
|
|
|
uniqueData4.forEach(function(option) {
|
|
|
|
if($('#selectAddCartInvntryOptn'+nextId).attr('id') === lastId){
|
|
|
|
//재고품절시 노출여부
|
|
if(option.invntrySldoutExpsrAt ==='N'){
|
|
//옵션 노출 안함
|
|
|
|
//품절표시
|
|
}else if(option.disableAt === 'Y'){
|
|
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal4 + '(+' + addComma((parseInt(option.slepric) - parseInt(slepricDscntAmt))) +')' + '(품절)',
|
|
disabled: true
|
|
}));
|
|
|
|
}else{
|
|
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal4 + '(+' + addComma((parseInt(option.slepric) - parseInt(slepricDscntAmt))) +')'
|
|
}));
|
|
}
|
|
|
|
}else{
|
|
|
|
//재고품절시 노출여부
|
|
if(option.invntrySldoutExpsrAt ==='N'){
|
|
//옵션 노출 안함
|
|
|
|
//품절표시
|
|
}else if(option.disableAt === 'Y'){
|
|
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal4 + '(품절)',
|
|
disabled: true
|
|
}));
|
|
}else{
|
|
$('#selectAddCartInvntryOptn'+nextId).append($('<option>', {
|
|
value: option.slepric+'|'+option.goodsOptnInnb+'|'+option.optnInfo+'|'+option.optnTy,
|
|
text: option.optnVal4
|
|
}));
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#selectAddCartInvntryOptn'+nextId).niceSelect('update');
|
|
|
|
break;
|
|
}
|
|
|
|
//마지막 선택일 경우 셀렉트 기본값으로 되돌림
|
|
if(id === lastId){
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':first').each(function() {
|
|
$(this).find('option').each(function () {
|
|
// value가 빈 문자열이 아닌 경우에만 삭제
|
|
if ($(this).val() !== '') {
|
|
$(this).remove().niceSelect('update');
|
|
}
|
|
});
|
|
});
|
|
$('select[name="selectAddCartInvntryOptn"]').val('').niceSelect('update')
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
});
|
|
})
|
|
|
|
//자리마다 "," 추가
|
|
function addComma(num) {
|
|
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
}
|
|
|
|
//장바구니 담기 처리
|
|
const fn_add_cart = (gubun, data, goodsInnb) => {
|
|
const url = "<c:url value="/sopmal/ordr/insertSpbk"/>";
|
|
$.ajax({
|
|
type: 'post',
|
|
enctype: 'multipart/form-data',
|
|
url: url,
|
|
data: data,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (data) {
|
|
if (data.resBody != null) {
|
|
const result = JSON.parse(data.resBody.result);
|
|
|
|
if (result.result === 'success') {
|
|
if (gubun === 'cart') {
|
|
fn_cart_modal()
|
|
fn_reflesh_cart_cnt();
|
|
$('.addCart').prop("disabled", false);
|
|
}
|
|
if (gubun === 'direct') {
|
|
//구매화면 이동
|
|
fn_move_purchs_order(goodsInnb);
|
|
$('.purchsOrdr').prop('disabled', false);
|
|
}
|
|
|
|
} else {
|
|
alert('구매정보 <spring:message code="fail.common.insert"/>');
|
|
$('.addCart').prop("disabled", false);
|
|
$('.purchsOrdr').prop('disabled', false);
|
|
}
|
|
}
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
//장바구니 담기 후 모달
|
|
const fn_cart_modal = () => {
|
|
|
|
|
|
const modal = `<div id="addCartModalDiv" class="modal alert">
|
|
<div class="alert-content">
|
|
<p class="alert-content__text--sm">
|
|
상품이 장바구니에 담겼습니다.
|
|
<br>
|
|
지금 확인하시겠습니까?
|
|
</p>
|
|
</div>
|
|
<div class="alert-btn-container">
|
|
<a href="javascript:void(0);" onclick="fn_move_cart_list();" rel="modal:close" class="alert-btn alert-btn--confirm">예</a>
|
|
<a href="javascript:void(0);" onclick="fn_close_modal('addCartModalDiv')" rel="modal:close" class="alert-btn alert-btn--confirm">아니오</a>
|
|
</div>
|
|
</div>`;
|
|
|
|
//장바구니 담은 후 페이지 이동 여부 모달
|
|
$('#addCartModalDiv').remove()
|
|
$('#addCartDiv').html(modal)
|
|
$('#addCartModalDiv').modal()
|
|
|
|
}
|
|
|
|
|
|
//구매하기 클릭 후 구매목록 이동
|
|
const fn_move_purchs_order = (goodsInnb) => {
|
|
|
|
|
|
<%--/* 구매하기 버튼 선택 이벤트 */--%>
|
|
const form = $('<form></form>');
|
|
|
|
$(form).append($('<input/>', {type: 'hidden', name: 'goodsInnb', value: goodsInnb}));
|
|
$(form).append($('<input/>', {type: 'hidden', name: 'cartDvCd', value: $('#cartDv-direct').val()}));
|
|
|
|
|
|
$(form).attr('method', 'post');
|
|
$(form).attr('action', '<c:url value="/sopmal/ordr/selectMbrPurchsForm"/>');
|
|
|
|
$(form).appendTo('body');
|
|
|
|
|
|
//일반옵션 체크 해제
|
|
$('input[type="radio"]').prop('checked', false)
|
|
|
|
$(form).submit();
|
|
$(form).remove();
|
|
|
|
}
|
|
|
|
//상품 중복 선택 모달
|
|
const fn_goods_duplicate_select_modal = () => {
|
|
const modal = `<div id="goodsDuplicateModalDiv" class="modal alert">
|
|
<div class="alert-content">
|
|
<p class="alert-content__text--sm">
|
|
중복된 상품입니다.
|
|
</p>
|
|
</div>
|
|
<div class="alert-btn-container">
|
|
<a href="javascript:void(0);" rel="modal:close" class="alert-btn alert-btn--confirm">확인</a>
|
|
</div>
|
|
</div>`;
|
|
|
|
//재고옵션 옵션 값 초기화
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':first').each(function() {
|
|
$(this).find('option').each(function () {
|
|
// value가 빈 문자열이 아닌 경우에만 삭제
|
|
if ($(this).val() !== '') {
|
|
$(this).remove().niceSelect('update');
|
|
}
|
|
});
|
|
});
|
|
$('select[name="selectAddCartInvntryOptn"]').val('').niceSelect('update')
|
|
|
|
//함께하면 좋은상품 옵션 값 초기화
|
|
$('select[name="selectAddCartInvntryOptn"]').not(':first').each(function() {
|
|
$(this).find('option').each(function () {
|
|
// value가 빈 문자열이 아닌 경우에만 삭제
|
|
if ($(this).val() !== '') {
|
|
$(this).remove().niceSelect('update');
|
|
}
|
|
});
|
|
});
|
|
$('select[name="selectAddCartInvntryOptn"]').val('').niceSelect('update')
|
|
|
|
$('select[name="selectRelateAddedOptn"]').val('').niceSelect('update')
|
|
|
|
//모달 처리
|
|
$('#goodsDuplicateModalDiv').remove()
|
|
$('#goodsDuplicateDiv').html(modal)
|
|
$('#goodsDuplicateModalDiv').modal()
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
장바구니 버튼
|
|
**************************************************************/
|
|
$(document).on('click', '.addCart', function () {
|
|
$('.addCart').prop("disabled", true);
|
|
|
|
if($('#hiddenForm')!= null){
|
|
$('#hiddenForm').remove()
|
|
}
|
|
|
|
//상품 선택 확인
|
|
let goodsAddedChk = false;
|
|
for (let idx in productArr) {
|
|
if(productArr[idx][5] == '01' || productArr[idx][5] == '02'){
|
|
goodsAddedChk = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//상품 선택 확인
|
|
if(productArr.length <= 0 || !goodsAddedChk){
|
|
alert('상품옵션을 선택해 주세요');
|
|
$('.addCart').prop("disabled", false);
|
|
return;
|
|
}
|
|
|
|
//추가구성옵션 - 필수추가구성옵션 있는지 확인
|
|
var values = $('input[name="productDetailInfo__additionalSelect__otpnEssntlAt__relate__added"]').map(function() {
|
|
return $(this).val();
|
|
}).get();
|
|
|
|
if(values.includes('Y')){
|
|
var isAddedOptnEssntlAt = productArr.some(function (item) {
|
|
return item[6] === 'Y'
|
|
});
|
|
|
|
if(!isAddedOptnEssntlAt){
|
|
alert('필수추가옵션을 선택해 주세요');
|
|
$('.addCart').prop("disabled", false);
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
const hiddenForm = document.createElement('form');
|
|
hiddenForm.name = 'hiddenForm';
|
|
hiddenForm.id = 'hiddenForm';
|
|
hiddenForm.method = 'post';
|
|
hiddenForm.action = '';
|
|
|
|
const goodsInnb = $('#addCartGoodsInnb').val();
|
|
const cartDvCdCart = $('#cartDv-cart').val();
|
|
|
|
|
|
/**
|
|
* 장바구니 담기 전 옵션조회해서 같은 물품 있을 경우 confirm후
|
|
* DELETE-INSERT 수행
|
|
* */
|
|
|
|
// 1. 해당 사용자의 모든 장바구니 정보 조회(상품옵션고유번호, 갯수 조회)
|
|
$.ajax({
|
|
type: 'post',
|
|
contentType: 'application/json',
|
|
url: '<c:out value="/sopmal/ordr/selectCartList"/>',
|
|
data: JSON.stringify({}),
|
|
success: async function (data) {
|
|
const result = JSON.parse(data.resBody.result)
|
|
if(result.message === 'success'){
|
|
const resultCartList = result.cartList;
|
|
let cartDuplicateOptnAt ='N';
|
|
let duplicatedOptn = [];
|
|
|
|
for(let i = productArr.length - 1; i >= 0; i--){
|
|
for(let j = resultCartList.length - 1; j >= 0; j--){
|
|
|
|
if(parseInt(resultCartList[j].goodsOptnInnb) === parseInt(productArr[i][4])){
|
|
|
|
//중복된 상품옵션의 기존 수량 + 선택한 수량
|
|
let newCartItem = {
|
|
...resultCartList[j],
|
|
cnt: resultCartList[j].cnt + productArr[i][1]
|
|
};
|
|
|
|
duplicatedOptn.push(newCartItem);
|
|
|
|
// resultCartList에서 해당 객체 삭제
|
|
resultCartList.splice(j, 1);
|
|
|
|
// productArr에서 해당 배열 삭제
|
|
productArr.splice(i, 1);
|
|
|
|
cartDuplicateOptnAt = 'Y'
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//2. 장바구니 중복 확인 결과
|
|
if(cartDuplicateOptnAt ==='Y'){
|
|
|
|
const dupliModal = await showConfirmModal();
|
|
if(dupliModal){
|
|
|
|
|
|
//선택한 상품옵션 장바구니 저장
|
|
const formData = new FormData();
|
|
let idx = 0;
|
|
if(productArr.length > 0 ){
|
|
for (let product of productArr) {
|
|
fn_create_input('hidden', "addCartList[" + idx + "].cartDvCd", cartDvCdCart, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsInnb", goodsInnb, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].qy", product[1], hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsOptnInnb", product[4], hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].optnTy", product[5], hiddenForm);
|
|
|
|
idx++;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//기존 장바구니에 담은 상품 저장
|
|
if(resultCartList.length > 0){
|
|
for(let resultCartItem of resultCartList){
|
|
fn_create_input('hidden', "addCartList[" + idx + "].cartDvCd", resultCartItem.cartDvCd, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsInnb", resultCartItem.goodsInnb, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].qy", resultCartItem.cnt, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsOptnInnb", resultCartItem.goodsOptnInnb, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].optnTy", resultCartItem.optnTy, hiddenForm);
|
|
|
|
idx++;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//중복된 상품 옵션 저장
|
|
for(let dupliItem of duplicatedOptn){
|
|
|
|
fn_create_input('hidden', "addCartList[" + idx + "].cartDvCd", dupliItem.cartDvCd, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsInnb", dupliItem.goodsInnb, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].qy", dupliItem.cnt, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsOptnInnb", dupliItem.goodsOptnInnb, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].optnTy", dupliItem.optnTy, hiddenForm);
|
|
|
|
idx++;
|
|
}
|
|
|
|
//장바구니 중복으로 인한 수정 여부
|
|
fn_create_input('hidden', "addCartUptAt", 'Y', hiddenForm);
|
|
fn_create_input('hidden', "cartDvCd", $('#cartDv-cart').val(), hiddenForm);
|
|
|
|
document.body.appendChild(hiddenForm);
|
|
|
|
$('#hiddenForm').serializeArray().forEach(function (item) {
|
|
formData.append(item.name, item.value);
|
|
});
|
|
|
|
fn_add_cart('cart', formData, goodsInnb)
|
|
|
|
}else{
|
|
productArr = []
|
|
$('input[type="radio"]').prop('checked', false)
|
|
fn_close_modal('addCart-product-popUp')
|
|
$('.addCart').prop("disabled", false);
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
//상품 중복옵션 없을 경우 장바구니 저장 진행
|
|
const formData = new FormData();
|
|
for (let idx in productArr) {
|
|
fn_create_input('hidden', "addCartList[" + idx + "].cartDvCd", cartDvCdCart, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsInnb", goodsInnb, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].qy", productArr[idx][1], hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsOptnInnb", productArr[idx][4], hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].optnTy", productArr[idx][5], hiddenForm);
|
|
}
|
|
|
|
//장바구니 중복으로 인한 수정 여부
|
|
fn_create_input('hidden', "addCartUptAt", 'N', hiddenForm);
|
|
fn_create_input('hidden', "cartDvCd", $('#cartDv-cart').val(), hiddenForm);
|
|
|
|
document.body.appendChild(hiddenForm);
|
|
|
|
$('#hiddenForm').serializeArray().forEach(function (item) {
|
|
formData.append(item.name, item.value);
|
|
});
|
|
|
|
|
|
fn_add_cart('cart', formData, goodsInnb)
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}//result success END
|
|
}//ajax success END
|
|
});//ajax END
|
|
|
|
})
|
|
|
|
|
|
/*************************************************************
|
|
구매하기 버튼
|
|
**************************************************************/
|
|
$(document).on('click', '.purchsOrdr', function () {
|
|
$('.purchsOrdr').prop('disabled', true)
|
|
if($('#hiddenForm')!=null){
|
|
$('#hiddenForm').remove()
|
|
}
|
|
//상품 선택 확인
|
|
if(productArr.length <= 0){
|
|
alert('상품옵션을 선택해 주세요');
|
|
$('.purchsOrdr').prop('disabled', false)
|
|
return;
|
|
}
|
|
|
|
//추가구성옵션 - 필수추가구성옵션 있는지 확인
|
|
var values = $('input[name="productDetailInfo__additionalSelect__otpnEssntlAt__relate__added"]').map(function() {
|
|
return $(this).val();
|
|
}).get();
|
|
|
|
if(values.includes('Y')){
|
|
var isAddedOptnEssntlAt = productArr.some(function (item) {
|
|
return item[6] === 'Y'
|
|
});
|
|
|
|
if(!isAddedOptnEssntlAt){
|
|
alert('필수추가옵션을 선택해 주세요');
|
|
$('.purchsOrdr').prop('disabled', false)
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
const hiddenForm = document.createElement('form');
|
|
hiddenForm.name = 'hiddenForm';
|
|
hiddenForm.id = 'hiddenForm';
|
|
hiddenForm.method = 'post';
|
|
hiddenForm.action = '';
|
|
const cartDvCdDirect = $('#cartDv-direct').val();
|
|
const goodsInnb = $('#addCartGoodsInnb').val();
|
|
|
|
const formData = new FormData();
|
|
|
|
for (let idx in productArr) {
|
|
|
|
fn_create_input('hidden', "addCartList[" + idx + "].cartDvCd", cartDvCdDirect, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsInnb", goodsInnb, hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].qy", productArr[idx][1], hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].goodsOptnInnb", productArr[idx][4], hiddenForm);
|
|
fn_create_input('hidden', "addCartList[" + idx + "].optnTy", productArr[idx][5], hiddenForm);
|
|
}
|
|
|
|
fn_create_input('hidden', "cartDvCd", $('#cartDv-direct').val(), hiddenForm);
|
|
document.body.appendChild(hiddenForm);
|
|
|
|
$('#hiddenForm').serializeArray().forEach(function (item) {
|
|
formData.append(item.name, item.value);
|
|
});
|
|
|
|
fn_add_cart('direct', formData, goodsInnb)
|
|
|
|
})
|
|
|
|
//장바구니 중복 상품 추가 confirm 모달 버튼 true/false 반환
|
|
function showConfirmModal() {
|
|
return new Promise(function(resolve, reject) {
|
|
<%--상품 중복담기 모달--%>
|
|
const modal =`
|
|
<div id="modal-error-confirm-add-cart-duplicate" class="modal alert">
|
|
<div class="alert-content">
|
|
<p class="alert-content__text--sm">
|
|
장바구니에 선택한 상품이 있습니다. <br/> 장바구니에 추가하시겠습니까?
|
|
</p>
|
|
</div>
|
|
<div class="alert-btn-container">
|
|
<a type="button" class="alert-btn alert-btn--confirm" id="modal-error-confirm-yesButton" rel="modal:close">예</a>
|
|
<a type="button" class="alert-btn alert-btn--confirm" id="modal-error-confirm-noButton" rel="modal:close">아니오</a>
|
|
</div>
|
|
</div>`
|
|
$('#modal-error-confirm-add-cart-duplicate').remove()
|
|
$('#modal-error-confirm-add-cart-duplicate-div').html(modal)
|
|
$('#modal-error-confirm-add-cart-duplicate').modal()
|
|
|
|
|
|
|
|
$('#modal-error-confirm-yesButton').one('click', function() {
|
|
resolve(true); // 예를 클릭하면 true 반환
|
|
});
|
|
|
|
$('#modal-error-confirm-noButton').one('click', function() {
|
|
resolve(false); // 아니오를 클릭하면 false 반환
|
|
});
|
|
|
|
$('#modal-error-confirm-add-cart-duplicate').on('hidden.bs.modal', function () {
|
|
resolve(false); // 모달이 닫힐 때 기본적으로 false 반환
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
<body>
|
|
<%-- 공통 Header --%>
|
|
<jsp:include page="/WEB-INF/views/comm/Header.jsp"/>
|
|
<!-- 메인 컨텐츠 영역 -->
|
|
<!-- 메인 컨텐츠 영역 -->
|
|
<main>
|
|
<div class="sub-wrapper">
|
|
<div class="sub-content">
|
|
<div class="searchResult">
|
|
<form id="listForm" action="">
|
|
<input type="hidden" id="pageIndex" name="pageIndex" value="${ resultMap.BOGoodsVO.pageIndex }"/>
|
|
<input type="hidden" id="priceRange" name="priceRange" value="${resultMap.BOGoodsVO.priceRange}">
|
|
<input type="hidden" id="sortDv" name="sortDv" value="${resultMap.BOGoodsVO.sortDv}">
|
|
<input type="hidden" id="dlvyGroupInnb" name="dlvyGroupInnb" value="${resultMap.BOGoodsVO.dlvyGroupInnb}">
|
|
<input type="hidden" id="code" name="code" value="${resultMap.BOGoodsVO.code}">
|
|
<div class="page-title center">
|
|
<h2 class="page-title__title page-title__title--searchResult">
|
|
<em><c:if test="${not empty resultMap.BOGoodsVO.kwrd }">'${resultMap.BOGoodsVO.kwrd}'</c:if> </em> 검색 결과
|
|
</h2>
|
|
</div>
|
|
<div class="searchResultTop">
|
|
<div class="header-search-bar">
|
|
<input type="search" title="검색어 입력" id="kwrd" name="kwrd" placeholder="검색어를 입력해주세요."
|
|
value="${ resultMap.BOGoodsVO.kwrd }">
|
|
<button onclick="fn_select_list(1)">
|
|
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
<g clip-path="url(#clip0_5_10974)">
|
|
<path d="M23.2332 21.8602L17.5212 15.9194C18.9898 14.1735 19.7945 11.9768 19.7945 9.68999C19.7945 4.34701 15.4475 0 10.1045 0C4.76156 0 0.414551 4.34701 0.414551 9.68999C0.414551 15.033 4.76156 19.38 10.1045 19.38C12.1104 19.38 14.0218 18.775 15.6561 17.6265L21.4115 23.6124C21.6521 23.8622 21.9756 24 22.3224 24C22.6506 24 22.9619 23.8749 23.1982 23.6474C23.7004 23.1641 23.7165 22.3628 23.2332 21.8602ZM10.1045 2.52782C14.0538 2.52782 17.2667 5.74069 17.2667 9.68999C17.2667 13.6393 14.0538 16.8522 10.1045 16.8522C6.15524 16.8522 2.94237 13.6393 2.94237 9.68999C2.94237 5.74069 6.15524 2.52782 10.1045 2.52782Z">
|
|
</path>
|
|
</g>
|
|
<defs>
|
|
<clipPath id="clip0_5_10974">
|
|
<rect width="24" height="24" fill="white"></rect>
|
|
</clipPath>
|
|
</defs>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
<div class="searchPrice">
|
|
<input type="hidden" id="pricDv" name="pricDv" value="slepric">
|
|
<div class="searchPrice__select">
|
|
<button value="btnAll" class="searchPrice__select__btn <c:if test="${resultMap.BOGoodsVO.priceRange == null or resultMap.BOGoodsVO.priceRange == 'btnAll'}">selected</c:if>">전체</button>
|
|
<button value="btn1" class="searchPrice__select__btn <c:if test="${resultMap.BOGoodsVO.priceRange == 'btn1'}">selected</c:if>">~ 1000${curUnit}</button>
|
|
<button value="btn2" class="searchPrice__select__btn <c:if test="${resultMap.BOGoodsVO.priceRange == 'btn2'}">selected</c:if>">1000 ~ 5000${curUnit}</button>
|
|
<button value="btn3" class="searchPrice__select__btn <c:if test="${resultMap.BOGoodsVO.priceRange == 'btn3'}">selected</c:if>">5000 ~ 15000${curUnit}</button>
|
|
<button value="btn4" class="searchPrice__select__btn <c:if test="${resultMap.BOGoodsVO.priceRange == 'btn4'}">selected</c:if>">15000${curUnit} 이상</button>
|
|
</div>
|
|
<div class="searchPrice__range">
|
|
<div class="searchPrice__rangeInput">
|
|
<input type="text" class="searchPrice__input input-text "
|
|
title="가격 입력" placeholder="" id="startPric" name="startPric"
|
|
value="${ resultMap.BOGoodsVO.startPric }">
|
|
<span class="searchPrice__rangeWon">${curUnit}</span>
|
|
</div>
|
|
<span class="searchPrice__rangeTilde">~</span>
|
|
<div class="searchPrice__rangeInput">
|
|
<input type="text" class="searchPrice__input input-text "
|
|
title="가격 입력" placeholder="" id="endPric" name="endPric"
|
|
value="${ resultMap.BOGoodsVO.endPric }">
|
|
<span class="searchPrice__rangeWon">${curUnit}</span>
|
|
</div>
|
|
</div>
|
|
<button class="searchPrice__btn btn theme">검색</button>
|
|
</div>
|
|
</div>
|
|
<div class="form-control-container form-control-container--subList">
|
|
<div class="center">
|
|
</div>
|
|
<div class="right">
|
|
<div class="subList__sort">
|
|
<p href="javascript:void(0);" data-value="avgEvlScore" class="subList__sort__item current">인기순</p>
|
|
<a href="javascript:void(0);" data-value="cntEvlScor" class="subList__sort__item">리뷰 많은순</a>
|
|
<a href="javascript:void(0);" data-value="slepricAsc" class="subList__sort__item">낮은 가격순</a>
|
|
<a href="javascript:void(0);" data-value="slepricDesc" class="subList__sort__item">높은 가격순</a>
|
|
<a href="javascript:void(0);" data-value="GoodsInnbDesc" class="subList__sort__item">신상품순</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="pageDiv">
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
<jsp:include page="/WEB-INF/views/comm/Footer.jsp"/>
|
|
|
|
</body>
|
|
</html> |