PageSourceSearch

https://mamegyorai.jp/assets/js/common.js?ver=20260917

js mamegyorai.jp collected 2026-10-03 19:52:18 UTC 18,877 bytes, 632 lines download raw bytes

1/**
2 * 同期通信でPOSTリクエストを投げます。
3 * @param target 必須 イベント発生オブジェクト
4 * @param action 任意 コントローラのアクション名
5 * @returns
6 */
7function submit(target,action){
8	var $loading = $("#loading");
9	$loading.addClass("on");
10	try {
11		var $target = $(target)
12		var $form = $target.closest("form");
13		var url = $form.attr('action');
14	
15		var params = $form.serialize();
16		var tagName = $target[0].tagName
17		if (action === undefined) {
18			if (tagName == "INPUT") {
19				var type = $target.attr("type");
20				if (type == "button" || type == "image" || submit){
21					params += "&"+$target.attr("name") + "=" + $target.val();
22				}
23			}
24			else if (tagName == "button") {
25				params += "&"+$target.attr("name") + "=" + $target.val();
26			}
27		} else {
28			params += "&"+action + "=" + action;
29		}
30		
31		$.ajax({
32			type : "post",
33			url : url,
34			dataType : "html",
35			data:params,
36			async: true,
37			success : function(data) {
38				document.open();
39				document.write(data);
40				document.close();
41				$loading.removeClass("on");
42			},
43		    error : function(data){
44				$loading.removeClass("on");
45				console.log(data);
46		    }
47	
48		});
49		
50	} catch(e){
51		$loading.removeClass("on");
52	}
53
54}
55/**
56 * 非同期通信でPOSTリクエストを投げます。
57 * @param method メソッド名
58 * @param params パラメータ
59 * @param form form
60 * @returns
61 */
62function ajaxPost(target, callback, action){
63	var $target = $(target);
64	var $form = $target.closest("form");
65	var url = $form.attr('action');
66
67	var formData = $form.serialize();
68	if (action === undefined) {
69		formData += "&"+$target.attr("name") + "=" + $target.val();
70	} else {
71		formData += "&"+action + "=" + action;
72	}
73
74
75	var $spinners = $("#spinners");
76	$spinners.removeClass("hide");
77	$.ajax({
78		type : "post",
79		url : url,
80		dataType : "html",
81		data:formData,
82		success : function(data) {
83			$spinners.addClass("hide");
84			callback(data);
85		},
86		error : function(data){
87			$spinners.addClass("hide");
88			console.log(data);
89		}
90	});
91}
92function setCart(data,hideDailog){
93	var json = JSON.parse(data);
94	if (json.status!=0){
95		return;
96	}
97	if (json.count === undefined) {
98		return;
99	}
100	if (json.count == null) {
101		return;
102	}
103	
104	var $num = $(".cart_num");
105	var val = json.count.toInt();
106	$num.text(val);
107	
108	if (val == 0) {
109		$num.addClass("hide");
110	} else {
111		if (isEmpty(hideDailog)){
112	 		$("#confirmAddCartDialog").modal('show');
113		}
114		$num.removeClass("hide");
115	}
116}
117 
118function initPagerEvent(parent){
119/*	
120	//ページャ表示行変更
121	parent.find(".com-pager-js .com-pager-dispcount-js").change(function(){
122		$("#pageCount").val(1);
123		doSubmit(this,"doPagingSizeChange");
124		return false;
125	});
126	
127	//ページリンク
128	parent.find(".com-pager-js a:not(.btn_grid_list)").on('click',function(event){
129		var page = $(this).data('page');
130		$(this).closest("form").find("#pageCount").val(page);
131
132		doSubmit(this,"doPageChange");
133		
134		return false;
135    });
136    
137    //フィルター
138    parent.find(".com-pager-js .com-filter-js").change(function(){
139		doSubmit(this,"doPageFilter");
140		return false;
141	});
142	
143	function doSubmit(obj,action) {
144		var form = $(obj).closest("form");
145		form.find(".js-pager-hidden").remove();
146		var hidden = $("<input type='hidden' class='js-pager-hidden'>").attr("name",action).val(action);
147		form.append(hidden);
148		submit(hidden);
149	}
150*/	
151	
152}
153
154//配送料金の計算
155function calcHaisoAmount(){
156	
157	let nomalHaisoAmount = null;
158	let nomalPrice = 0;
159	let $chumonItemInfo = null;
160	let kobetuAmount=0;
161	
162	var param = getHaisoParam();
163	
164	if (param == null) {
165		return null;
166	}
167	
168	param.brandId	= $('.ctl-brandId-js').val();
169	param.shopCd	= $(".ctl-shopCd-js").val();
170	
171	//商品別配送料
172	$('.chumon-item.show-item').each(function(){
173		
174		let $haisoAmount = $(this).find('.ctl-haisoAmount-js');
175		let includeAmount= 0;
176		
177		//在庫非管理商品は配送料がかからない
178		let nonZaikoFlg =$(this).find(".ctl-nonZaikoFlg-js ").val();
179		if (nonZaikoFlg == "true" || nonZaikoFlg == true) {
180			return;
181		}
182		//個別配送料が設定されている場合は通常配送料金算出は無料
183		let kobetsuHaisoAmount = $(this).find('.ctl-kobetsuHaisoAmount-js').val();
184		if(kobetsuHaisoAmount != undefined && kobetsuHaisoAmount != ""){
185			let amount  = kobetsuHaisoAmount.toInt() * $(this).find(".ctl-chumonNum-js").val().toInt();
186			$haisoAmount.val(amount);
187			kobetuAmount = kobetuAmount + amount;
188			return;
189			
190		}else{
191			//同梱不可は別配送料金
192			let notIncludeFlg =$(this).find(".ctl-notIncludeFlg-js").val();
193			if( notIncludeFlg == "true" || notIncludeFlg == true){
194				param.price 	= $(this).find('.ctl-price-js').val();
195				includeAmount = stem.getCustomerHaisoAmount(param.shopCd,param.todofukenCd,param.zipCd,param.price);
196				$haisoAmount.val(includeAmount);
197			}
198		}
199		
200		//通常配送料を算出するための金額を加算
201		if (kobetuAmount <=0) {
202			if(includeAmount==0){
203				let price = $(this).find(".ctl-price-js").val();
204				nomalPrice = nomalPrice + price.toInt();
205				
206				if($chumonItemInfo == null){
207					//最初の1行のオブジェクトを保持する
208					$chumonItemInfo = $(this).find('.chumon-item-info');
209				}
210			}
211		}
212	});
213	
214	//同梱商品の配送料
215	if(kobetuAmount ==0 && nomalPrice > 0){
216		param.price = nomalPrice;
217		var haisoAmount = stem.getCustomerHaisoAmount(param.shopCd,param.todofukenCd,param.zipCd,param.price);
218		$chumonItemInfo.find('.ctl-haisoAmount-js').val(haisoAmount);
219	}
220}
221
222/**
223 * 配送パラメータ作成
224 */
225function getHaisoParam(){
226	var zipCd		= $(".ctl-haisoZip-js").val();
227	var todofukenCd	= $(".ctl-haisoTodofukenCd-js").val();
228
229	if (isEmpty(zipCd) || isEmpty(todofukenCd)){
230		return null;
231	}
232
233	return {
234		 zipCd       : zipCd
235		,todofukenCd : todofukenCd
236	};
237}
238
239
240//代引料金
241function calcDaibiki(shibaraiKbn){
242	
243	if(shibaraiKbn != "1"){
244		$('.chumon-item.show-item').each(function(){
245			$(this).find('.ctl-daibikiAmount-js').val("");
246		});
247		return;
248	}
249	
250//	let totalDaibikiAmount = 0;
251	let totalPrice= 0;
252	let $topDaibikiAmount = null;
253	
254	$('.chumon-item.show-item').each(function(){
255		
256		$daibikiAmount = $(this).find('.ctl-daibikiAmount-js');
257		
258		var rowPrice = $(this).find('.ctl-price-js').val().toInt();
259		var kobetsuHaisoAmount= $(this).find('.ctl-kobetsuHaisoAmount-js ').val();
260		
261		if(kobetsuHaisoAmount != undefined && kobetsuHaisoAmount != ""){
262			rowPrice += kobetsuHaisoAmount.toInt();
263		}
264		
265		//在庫非管理商品は代引き手数料がかからない
266		let nonZaikoFlg =$(this).find("nonZaikoFlg").val();
267		
268		if (nonZaikoFlg == "true" || nonZaikoFlg == true) {
269			return;
270		}
271		
272		//同梱不可は別代引手数料
273		let notIncludeFlg =$(this).find(".ctl-notIncludeFlg-js").val();
274		if( notIncludeFlg == "true" || notIncludeFlg == true){
275			var amount = daisouAmount(rowPrice);
276			if (amount != null) {
277				$daibikiAmount.val(amount);
278				
279			}
280		}else{
281			if($topDaibikiAmount == null){
282				if(notIncludeFlg == undefined || notIncludeFlg =="false"){
283					if(nonZaikoFlg == undefined || nonZaikoFlg =="false"){
284						$topDaibikiAmount = $(this).find('.ctl-daibikiAmount-js');
285					}
286				}
287			}
288			totalPrice += rowPrice.toInt();
289		}
290	});
291	
292	//同梱代引手数料
293	var amount = daisouAmount(totalPrice);
294	if ($topDaibikiAmount != null) {
295		$topDaibikiAmount.val(amount)
296	}
297	
298//	totalDaibikiAmount += amount.toInt();
299	
300//	$(".order_detail_table .showDaibikiAmount").text("ï¿¥" + totalDaibikiAmount.numFormat());
301//  	$(".order_detail_table .ctl-daibikiAmount-js").val(totalDaibikiAmount);
302}
303
304/**
305 * 代引手数料取得
306 */
307function daisouAmount(price){
308	var param		= {};
309	param.price		= price.toInt();
310	param.shopCd	= $(".ctl-shopCd-js").val();
311	if (isEmpty(param.shopCd)) {
312		return null;
313	}
314	
315	//代引手数料取得
316	 return stem.getDaibikiAmount(param.shopCd,param.price);
317	
318}
319
320//注文合計
321function calcTotalAmount(){
322	
323	//初期化
324	$(".order_detail_table .ctl-juchuAmount-js").val("");
325	$(".order_detail_table .showJuchuAmount ").text("-");
326	$(".order_detail_table .ctl-haisoAmount-js").val("");
327	$('.order_detail_table .showHaisoAmount ').text("-");
328	$(".order_detail_table .ctl-daibikiAmount-js").val("");
329	$('.order_detail_table .ctl-showPointAmount-js').text("-");
330	$(".order_detail_table .ctl-maebaraiAmount-js").val("");
331	$('.order_detail_table .showMaebaraiAmount ').text("-");
332	
333	//商品合計金額
334	let chumonAmaunt = 0;
335	let nonTaxedPrice = 0;
336	let taxAmount =0;
337	let maebarai=0;
338	let haisoAmount =0;
339	let daibikiAmount =0;
340	
341	$('.chumon-item.show-item .chumon-item-info').each(function(){
342		//アイテムの注文金額(単価*数量)
343		let itemChumonAmount = $(this).find(".ctl-price-js").val().toInt();
344		let itemNonTaxedPrice = $(this).find(".ctl-nonTaxedPrice-js").val().toInt();
345		let itemTaxAmount = $(this).find(".ctl-taxAmount-js").val().toInt();
346		let itemMaebarai = $(this).find(".ctl-maebaraiAmount-js ").val();
347	
348		chumonAmaunt = chumonAmaunt + itemChumonAmount;
349		nonTaxedPrice = nonTaxedPrice + itemNonTaxedPrice;
350		taxAmount = taxAmount + itemTaxAmount;
351		
352		//前払い金
353		if(itemMaebarai != undefined && itemMaebarai != "" && itemMaebarai != "-"){
354			maebarai = maebarai + itemMaebarai.toInt();
355		}
356		
357		//送料合計
358		let itemHaisoAmount = $(this).find(".ctl-haisoAmount-js").val();
359		haisoAmount = haisoAmount + itemHaisoAmount.toInt();		
360		//代引き合計
361		let itemDaibikiAmount = $(this).find(".ctl-daibikiAmount-js").val();
362		daibikiAmount = daibikiAmount + itemDaibikiAmount.toInt();
363	});
364	
365	$('.order_detail_table .showPrice').text("ï¿¥" + chumonAmaunt.numFormat());
366	$('.order_detail_table .ctl-price-js').val(chumonAmaunt);
367	$('.order_detail_table .ctl-nonTaxedPrice-js ').val(nonTaxedPrice);
368	$('.order_detail_table .ctl-taxAmount-js  ').val(taxAmount);
369	$(".order_detail_table .ctl-haisoAmount-js").val(haisoAmount);
370	
371	if (!$('#todokesaki-3').prop("checked")){
372		$('.order_detail_table .showHaisoAmount ').text("ï¿¥" + haisoAmount.numFormat());
373	}
374
375	
376	$(".order_detail_table .ctl-daibikiAmount-js").val(daibikiAmount);
377	if(daibikiAmount > 0){
378		$('.order_detail_table .showDaibikiAmount').text("ï¿¥" + daibikiAmount.numFormat());
379		$('.row-daibiki').removeClass('hide');
380	}else{
381		$('.row-daibiki').addClass('hide');
382	}
383	
384	//前払い金
385	$(".order_detail_table .ctl-maebaraiAmount-js").val(maebarai);
386	$(".showMaebaraiAmount").text("ï¿¥" + maebarai.numFormat());
387	if(maebarai == 0){
388		$('.order_detail_table .maebarai').addClass('hide');
389	}else{
390		$('.order_detail_table .maebarai').removeClass('hide');
391	}
392	
393	var juchuAmount = chumonAmaunt.toInt();
394	juchuAmount = juchuAmount+ haisoAmount.toInt();
395	juchuAmount = juchuAmount+ daibikiAmount.toInt();
396	
397	//ポイント設定
398	setAllPointPay(juchuAmount,maebarai);
399	
400	var pointAmount = $('.ctl-pointAmount-js').val();
401	
402	$('.chumon-item.show-item .chumon-item-info .ctl-nebikiAmount-js').val("");
403	if(pointAmount != undefined && pointAmount != "" && pointAmount !="-"){
404		pointAmount = pointAmount.toInt();
405		//受注金額より使用ポイントが多い場合は受注金額を設定
406		if(pointAmount > juchuAmount){
407			pointAmount = juchuAmount;
408			$('.ctl-pointAmount-js').val(pointAmount);
409			$('.ctl-inputPointAmount-js').val(pointAmount.numFormat());
410		}
411
412		let nebikiAmount = pointAmount;	
413		$('.chumon-item.show-item .chumon-item-info').each(function(){
414			let rowPrice 	= $(this).find(".ctl-price-js").val().toInt()
415							+ $(this).find(".ctl-haisoAmount-js").val().toInt()
416							+ $(this).find(".ctl-daibikiAmount-js").val().toInt();
417
418			let rowNebikiAmount	= 0
419			if (nebikiAmount != 0) {
420				rowNebikiAmount = Math.min(rowPrice,nebikiAmount);
421				rowPrice 		-= rowNebikiAmount;
422				nebikiAmount	-= rowNebikiAmount;
423				$(this).find(".ctl-nebikiAmount-js").val(rowNebikiAmount);
424			}				
425			
426			
427		});
428		
429		$(".order_detail_table .ctl-showPointAmount-js").text("-ï¿¥"+(pointAmount).numFormat());
430		
431		juchuAmount = juchuAmount - pointAmount.toInt();
432	}
433	
434  	//支払金額
435  	let payAmount = juchuAmount;
436  	
437  	let juchuKbn = $(".ctl-juchuKbn-js").val(); 
438  	
439  	if(juchuKbn =="3"){
440	  	payAmount = payAmount - maebarai.toInt();
441	}
442 	
443 	//受注金額(支払方法が全額ポイントの場合は支払金額が有効。それ以外は受注金額が有効)
444 	let shiharaiKbn = $('input:radio[name="dto.shiharaiMethodKbn"]:checked').val();
445 	if(shiharaiKbn == '11'){
446		$(".order_detail_table .ctl-juchuAmount-js").val(payAmount);
447	}else{
448		$(".order_detail_table .ctl-juchuAmount-js").val(juchuAmount);
449	}
450  
451  	$(".order_detail_table .ctl-payAmount-js").val(payAmount);
452  	$(".order_detail_table .showPayAmount").text("ï¿¥" + payAmount.numFormat());
453
454}
455
456//取消ボタン
457function cancelItem($target,data){
458		
459		//取消アイテムの表示処理
460		let $parent = $target.closest('.chumon-item')
461		$parent.removeClass('show-item');
462		$parent.find('.ctl-delFlg-js ').val('true');
463		
464		//カート処理
465		setCart(data,true);
466		
467		var json = JSON.parse(data);
468		
469		//お届け先区分
470		if(json.nonTenpoUketoriFlg =="true"){
471			$('#todokesaki-3').addClass('hide');
472			$('label[for="todokesaki-3"]').addClass('hide');
473		}else{
474			$('#todokesaki-3').removeClass('hide');
475			$('label[for="todokesaki-3"]').removeClass('hide');
476		}
477		
478		let shiharaiKbn = $('input:radio[name="dto.shiharaiMethodKbn"]:checked').val();
479		
480		//配送料再計算
481		calcHaisoAmount();
482		//代引き手数料取得
483		calcDaibiki(shiharaiKbn);
484		calcTotalAmount();
485		setChumonButton();
486	
487}
488
489function setChumonButton(){
490	
491	//初期状態
492	$("input[name='doConfirm']").prop("disabled", false);
493	$("input[name='doFixed']").prop("disabled", false);
494	let juchuKbn = $(".ctl-juchuKbn-js ").val();
495	
496	//戻るボタン制御
497	let maebaraiAmount = $('.order_detail_table .ctl-maebaraiAmount-js').val();
498	
499	if(juchuKbn =="1"){
500		if(maebaraiAmount == undefined || maebaraiAmount == "" || maebaraiAmount ==0){
501			$("input[name='doBack']").addClass('hide');
502		}else{
503			$("input[name='doBack']").removeClass('hide');
504		}
505	}
506		
507	//お届け先が選択されていない
508	let todokesakiKbn = $('.ctl-todokesakiKbn-js ').val();
509	if(todokesakiKbn == undefined || todokesakiKbn==""){
510		todokesakiKbn = $('input:radio[name="dto.todokesakiKbn"]:checked').val();
511	}
512	
513	if(todokesakiKbn == undefined || todokesakiKbn==""){
514		//在庫注文で都道府県が指定されていない場合は非活性
515		if(juchuKbn != 1){
516			$("input[name='doConfirm']").prop("disabled", true);
517			$("input[name='doFixed']").prop("disabled", true);
518		}
519	}
520	
521	//支払方法
522	let shiharaiKbn = $('.ctl-shiharaiMethodKbn-js').val();
523	if(shiharaiKbn == undefined || shiharaiKbn==""){
524		shiharaiKbn = $('input:radio[name="dto.shiharaiMethodKbn"]:checked').val();
525	}
526	
527	//お支払い方法が指定されていない場合は非活性
528	if(shiharaiKbn == undefined || shiharaiKbn==""){
529		//店舗受取以外
530		if(todokesakiKbn !=3){
531			$("input[name='doConfirm']").prop("disabled", true);
532			$("input[name='doFixed']").prop("disabled", true);
533		}
534	}
535		
536	//ご注文合計金額が0の場合は非活性
537	let payAmount = $(".order_detail_table .ctl-payAmount-js").val();
538	if(payAmount!==undefined && payAmount !=null && payAmount != ""){
539		if(payAmount.toInt() ==0){
540			$("input[name='doConfirm']").prop("disabled", false);
541			$("input[name='doFixed']").prop("disabled", false);
542		}
543	}
544}
545
546function setFooterPicker($datepicker){
547	var r = $.datepicker.regional["ja"];
548	r.dateFormat = "yy年mm月dd日";
549	r.changeMonth= true;
550	r.changeYear= true;
551	$.datepicker.setDefaults(r);
552
553	let base = $("#base_context").data("base");
554	if (!base && base == null) {
555		return;
556	}
557	$.get(base + "api/calendar/holiday", function(holidaysData) {
558		var r = $.datepicker.regional["ja"];
559		r.beforeShowDay = beforeShowDayEx;
560		r.beforeShow = beforeShowEx;
561		$.datepicker.setDefaults(r);
562		$datepicker.datepicker();
563
564		function beforeShowEx() {
565	        setTimeout(function(){
566	            $('.ui-datepicker').css('z-index', 10);
567	        }, 0);
568	    }
569		function beforeShowDayEx(date){
570			if (date.getDay() == 0) {
571				return [true, 'day-sunday', null];
572			} else if (date.getDay() == 6) {
573				return [true, 'day-saturday', null];
574			}
575
576			var holidays = Object.keys(holidaysData);
577			for (var i = 0; i < holidays.length; i++) {
578				var holiday = new Date(Date.parse(holidays[i]));
579				if (holiday.getYear() == date.getYear() &&
580						holiday.getMonth() == date.getMonth() &&
581						holiday.getDate() == date.getDate()) {
582					return [true, 'day-holiday', null];
583				}
584			}
585
586			return [true, 'day-weekday', null];
587		}
588	});
589}
590
591//全額ポイント払いの制御
592function setAllPointPay(juchuAmount,maebarai){
593	
594	let shiharaiKbn = $('input:radio[name="dto.shiharaiMethodKbn"]:checked').val();
595	let txtRiyouKanoPoint = $('.ctl-riyouKanoPoint-js').val();
596	let riyouKanoPoint = 0;
597	if(!isEmpty(txtRiyouKanoPoint)){
598		riyouKanoPoint = txtRiyouKanoPoint.toInt();
599	}
600	
601	let payPointAmount= juchuAmount-maebarai;
602	
603	//全額ポイント払い
604	if(!isEmpty(shiharaiKbn) && shiharaiKbn == '11'){
605		//受注金額>利用可能ポイントの場合は全額ポイント払いを解除
606		if(!isEmpty(riyouKanoPoint) && payPointAmount > riyouKanoPoint){
607			$('.ctl-pointAmount-js').val("");
608			$('.ctl-inputPointAmount-js').val("");
609			$('.ctl-inputPointAmount-js').prop('disabled', false);
610			$("input[name='doPointReflect']").prop('disabled', false);
611		}else{
612			//全額ポイント払いのため、受注金額をポイントに設定
613			$('.ctl-pointAmount-js').val(payPointAmount);
614			$('.ctl-inputPointAmount-js').val(payPointAmount.numFormat());
615			$('.ctl-inputPointAmount-js').prop('disabled', true);//自動ポイント入力後、使用不可
616			$("input[name='doPointReflect']").prop('disabled', true);//point適用ボタンを使用不可
617		}
618	}else{
619		//全額ポイント払い以外
620		var inputPointAmount = $('.ctl-pointAmount-js').val();
621		//ポイントが入力されていた場合
622		if(inputPointAmount != undefined && inputPointAmount != "" && inputPointAmount !="-" && inputPointAmount !="0"){
623			$('.ctl-pointAmount-js').val(inputPointAmount);
624			$('.ctl-inputPointAmount-js').val(inputPointAmount.numFormat());
625		}
626		
627		$('.ctl-inputPointAmount-js').prop('disabled', false);
628		$("input[name='doPointReflect']").prop('disabled', false);
629	}
630}
631
632

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.