PageSourceSearch

https://www.jrbeauty-tw.com/assets/js/common/web_cart.js?041305

js jrbeauty-tw.com collected 2026-10-07 08:13:55 UTC 10,984 bytes, 275 lines download raw bytes

1/*
2| -------------------------------------------------------------------
3| 定義購物車JS
4| -------------------------------------------------------------------
5| 購物車整個專案可用的皆可定義於此,方便管理
6|
7| -------------------------------------------------------------------
8*/
9
10// 引入要用到的js檔---------------------------------------------------------------------------------------------------------------------
11//fancybox
12document.write('<script src="/plugin/fancybox/jquery.mousewheel-3.0.6.pack.js"><\/script>');
13document.write('<script src="/plugin/fancybox/jquery.fancybox.pack.js?v=2.1.5"><\/script>');
14
15
16
17// 加入購物車---------------------------------------------------------------------------------------------------------------------
18function ajax_add_cart(cart_type, type_id, category_id, product_id, spec_id, amount, is_msg, pay_type) {
19
20    if (category_id > 0 && spec_id > 0 && amount > 0){
21        $.post("/ajax_cart/ajax_add_cart",{'cart_type':cart_type, 'type_id':type_id, 'category_id':category_id, 'product_id':product_id, 'spec_id':spec_id, 'amount':amount},function(data) {
22            var obj = JSON.parse(data);
23
24            //修改顯示的購物車數量
25            ajax_modify_cart_show_count();
26
27            if(is_msg == 1) {
28                if (alert(obj['msg'])){
29					$(".aqbg").fadeIn();
30					$(".aqalert-car").fadeIn();
31				}else{
32					$(".aqbg").fadeIn();
33					$(".aqalert-car").fadeIn();
34				}
35            }
36
37            // 處理即時顯示購物車動態
38            if(Object.keys(obj['product_list']).length > 0) {
39                var append_html = '';
40				var append_html_new = '';
41				
42				if (Object.keys(obj['product_list']['spec_list']).length > 0){
43                    
44                    $.each(obj.product_list['spec_list'],function(key, value) {
45						var option_array = '';
46						var selected = '';
47						for(i=1; i<=10; i++){
48							if(i == value['amount']){
49								selected = 'selected="selected"';
50							}else{
51								selected = '';
52							}
53							
54							
55							
56							option_array+='<option value="'+i+'" '+selected+'>'+i+'</option>';
57						}
58						
59						if($('#buy_one_get_one').val() == 1){
60							append_new_buy_one_get_one = '<tr>'+
61															'<td>'+
62																'<a href="' + value["url"] + '"><label class="label_give">贈品</label>' + value["product_name"] + '</a>'+
63															'</td>'+
64															'<td>'+
65																'數量'+value['amount']+
66															'</td>'+
67														'</tr>';
68						}else{
69							append_new_buy_one_get_one = '';
70						}
71						
72                        append_html_new += '<tr>'+
73												'<td>'+
74													'<a href="' + value["url"] + '">' + value["product_name"] + '</a>'+
75												'</td>'+
76												'<td>'+
77													'數量'+value['amount']+
78												'</td>'+
79											'</tr>' + append_new_buy_one_get_one;
80                    });
81                }
82				
83                if (Object.keys(obj['product_list']['spec_list']).length > 0){
84
85                    append_html += '<ul class="cart_list"><li class="cart_list_title">一般商品</li>';
86                    $.each(obj.product_list['spec_list'],function(key, value) {
87		
88						if($('#buy_one_get_one').val() == 1){
89							append_buy_one_get_one = '<li class="cfx">\
90														<a href="' + value["url"] + '">\
91															<div class="pic q_dar_head_car_yin_after_li">\
92																<img src="' + value["list_pic1_src"] + '" alt="">\
93																<p class="com_name  right q_dar_head_car_yin_after_li_text"><label class="label_give">贈品</label> ' + value["product_name"] + '---X' + value["amount"] + '</p>\
94															</div>\
95														</a>\
96													</li>';
97						}else{
98							append_buy_one_get_one = '';
99						}
100			
101                        append_html += '<li class="cfx">\
102                                            <a href="' + value["url"] + '">\
103                                                <div class="pic q_dar_head_car_yin_after_li">\
104                                                    <img src="' + value["list_pic1_src"] + '" alt="">\
105													<p class="com_name right q_dar_head_car_yin_after_li_text">' + value["product_name"] + '---X' + value["amount"] + '</p>\
106                                                </div>\
107                                            </a>\
108                                        </li>'+append_buy_one_get_one;
109                    });
110                    append_html += '</ul>';
111                }
112                if ("onepage_list" in obj['product_list']){
113                    append_html += '<ul class="cart_list"><li class="cart_list_title">活動商品</li>';
114
115                    $.each(obj.product_list['onepage_list'],function(key, value) {
116                        $.each(obj.product_list['onepage_list'][key]['spec_list'],function(key2, value2) {
117
118                            append_html += '<li class="cfx">\
119                                                <a href="' + value2["url"] + '">\
120                                                    <div class="pic">\
121                                                        <img src="' + value2["list_pic1_src"] + '" alt="">\
122                                                    </div>\
123                                                    <p class="com_name">' + value2["product_name"] + '---X' + value2["amount"] + '</p>\
124                                                </a>\
125                                            </li>';
126                        });
127                    });
128                    append_html += '</ul>';
129                }
130
131                $('#header_cart_bk').html(append_html);
132				$('#new_car_tb').html(append_html_new);
133                $('.cart_list .no_shop').hide();
134                $('.total_box .total_nt').text('NT.' + obj['orders_price']['number_format']['discount_sub_total']);
135				
136				$('#price_new_car').text('NT.' + obj['orders_price']['number_format']['discount_sub_total']);
137				$('#count_new_car').text(Object.keys(obj['product_list']).length);
138				
139				$('.checkout').show();
140				
141            }
142
143            //一頁式活動
144            if (cart_type == 3) {
145                ajax_rebuild_buy_product_bk();
146            }
147
148            if(pay_type == 2) {
149                document.location.href="/website_shopping/shopping_cart";
150            }
151
152            if(pay_type == 3) {
153                document.location.href="/website_member/login";
154            }
155        });
156		
157    }
158    else{
159        alert('無規格');
160    }
161}
162
163// 移除購物車---------------------------------------------------------------------------------------------------------------------
164function ajax_del_cart(cart_type, type_id, product_id, spec_id) {
165	if(confirm("確定要刪除該產品嗎??")){
166		if (spec_id > 0){
167			$.post("/ajax_cart/ajax_del_cart",{'cart_type':cart_type,'type_id':type_id,'product_id':product_id,'spec_id':spec_id},function(data) {
168				var obj = JSON.parse(data);
169				alert(obj['msg']);
170				window.location.reload();
171			});
172		}
173		else{
174			alert('無規格');
175		}
176		//修改顯示的購物車數量
177		ajax_modify_cart_show_count();
178	}
179}
180
181// 移除購物車---------------------------------------------------------------------------------------------------------------------
182function ajax_del_cart_new(cart_type, type_id, product_id, spec_id) {
183	if(confirm("確定要刪除該產品嗎??")){
184		if (spec_id > 0){
185			$.post("/ajax_cart/ajax_del_cart",{'cart_type':cart_type,'type_id':type_id,'product_id':product_id,'spec_id':spec_id},function(data) {
186				var obj = JSON.parse(data);
187				alert(obj['msg']);
188			});
189			
190			$(".aqbg").fadeOut();
191			$(".aqalert-car").fadeOut();
192			window.location.reload();
193		}
194		else{
195			alert('無規格');
196		}
197		//修改顯示的購物車數量
198		ajax_modify_cart_show_count();
199	}
200}
201// 修改購物車數量---------------------------------------------------------------------------------------------------------------------
202function ajax_modify_cart_amount(cart_type, type_id, product_id, spec_id, amount) {
203    if (spec_id > 0 && amount > 0){
204        $.post("/ajax_cart/ajax_modify_cart_amount",{'cart_type':cart_type,'type_id':type_id,'product_id':product_id,'spec_id':spec_id,'amount':amount},function(data) {
205            var obj = JSON.parse(data);
206            alert(obj['msg']);
207            window.location.reload();
208        });
209    }
210    else{
211        alert('無規格');
212    }
213}
214
215function ajax_modify_cart_amount_new(cart_type, type_id, product_id, spec_id, amount) {
216    if (spec_id > 0 && amount > 0){
217        $.post("/ajax_cart/ajax_modify_cart_amount",{'cart_type':cart_type,'type_id':type_id,'product_id':product_id,'spec_id':spec_id,'amount':amount},function(data) {
218            var obj = JSON.parse(data);
219            alert(obj['msg']);
220			
221			$(".aqbg").fadeOut();
222			$(".aqalert-car").fadeOut();
223			window.location.reload();
224			
225        });
226		
227    }
228    else{
229        alert('無規格');
230    }
231}
232// 修改顯示的購物車數量
233function ajax_modify_cart_show_count(){
234    if ($('.cart_num').length > 0){
235        $.post("/ajax_cart/ajax_modify_cart_show_count",{},function(data) {
236            $('.cart_num').html('( ' + data.cart_num + ' )');
237			$('#label_look_pd').text('購物車(' + data.cart_num + ')');
238			$('#cart_num_mob_span').text(data.cart_num);
239			$('#cart_num_mob_em').text(data.cart_num);
240			$('#count_new_car').text(data.cart_num);
241			$('#look_pd').attr('href', '/website_shopping/shopping_cart');
242			$('#no_pd_car').attr('href', '/website_shopping/shopping_cart');
243
244            $('.buy_title').text(data.buy_title);
245            $('.buy_url').attr('href',data.buy_url);
246			
247
248            // 電腦版的處理
249            $('#car_continue_shopping').attr('href',data.car_continue_shopping_url);
250            if(data.car_continue_shopping_url == 'javascript:;') {
251                $('#car_continue_shopping').addClass(data.car_continue_shopping_class);
252
253                $('#car_continue_shopping').on('click',function() {
254                    $('#sign_in_block').show();
255                    $('#sign_in_block').css('display', 'block');
256                    $('.cart_btn').removeClass('active');
257                });
258            } else {
259                $('#car_continue_shopping').removeClass(data.car_continue_shopping_class);
260            }
261
262            // 手機版的處理
263            $('.car_continue_shopping_mobile').attr('href',data.car_continue_shopping_mobile_url);
264
265            if(data.cart_num > 0) {
266                $('.sign_prompt_y').show();
267                $('.sign_prompt_n').hide();
268            } else {
269                $('.sign_prompt_n').show();
270                $('.sign_prompt_y').hide();
271            }
272        },'json');
273
274    }
275}

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.