PageSourceSearch

https://www.a8888.com.tw/js/front.js

js a8888.com.tw collected 2026-09-30 21:41:23 UTC 13,425 bytes, 470 lines download raw bytes

1setTimeout(function(){
2    $('#shoppingListDiv').html("");
3    $.ajax({
4        url: _jsPath+"/shopping",
5        type: "GET",
6        data: {
7            ajax: "shoppingList"
8        },
9        
10        success: function(msg) {
11            try {
12                var temp = msg;
13                if(typeof(msg)!="object"){
14                    temp = JSON.parse(msg);
15                }
16                shoppingList = temp.data;
17                listCount = 0;
18                if(typeof(shoppingList[0]) != "undefined"){
19                    listCount = shoppingList[0].listCount;
20                }
21                $("#shoppingCountSpan").html(""+(listCount*1)+"");
22            } catch (e) {
23                alert("error : " + e);
24            }
25            loadingStop();
26        }
27    });
28    
29},0);
30function shoppingListReload(shoppingList) {
31    loadingStart();
32    $('#shoppingListDiv').html("");
33    if(typeof(shoppingList) == "undefined"){
34        var shoppingList;
35        $.ajax({
36            url: _jsPath+"/shopping",
37            type: "GET",
38            data: {
39                ajax: "shoppingList"
40            },
41            
42            success: function(msg) {
43                try {
44                    var temp = msg;
45                    if(typeof(msg)!="object"){
46                        temp = JSON.parse(msg);
47                    }
48                    shoppingList = temp.data;
49                    shoppingListReload(shoppingList);
50                } catch (e) {
51                    alert("error : " + e);
52                }
53                loadingStop();
54            }
55        });
56    }else{
57        listCount = 0;
58        if(typeof(shoppingList[0]) != "undefined"){
59            listCount = shoppingList[0].listCount;
60        }
61        $("#shoppingCountSpan").html(""+(listCount*1)+"");
62        if(shoppingList.length>0){
63            $(shoppingList).each(function(k,v){
64                $('#shoppingListDiv').append($('#cartItemtDiv').html());
65                var temp = $('#shoppingListDiv').find('div.cart-item:last');
66                $(temp).find('.product-link').attr('href', _jsPath+'/product/detail/' + v.productId);
67                $(temp).find('img').attr('src', v.picture);
68                if(v.specificationsName=="default" || v.specificationsName==null){
69                    $(temp).find('.title').html(v.name);
70                }else{
71                    $(temp).find('.title').html(v.name+'('+v.specificationsName+')');
72                }
73                $(temp).find('.ng-scope').html('數量:' + v.count);
74                $(temp).find('.price-details').html('NT ' + v.price * v.count);
75                $(temp).find('.remove').data("productid",v.productId);
76                $(temp).find('.remove').data("specifications",v.specifications);
77                $(temp).find('.remove').on('click',function(){
78                    shoppingRmProduct($(temp).find('.remove'),false);
79                });
80            });
81            $('#shoppingListDiv').append('<div class="cart-chkt-btn"><button onclick="location.href=\''+_jsPath+'/shopping\'"> 訂單結帳 </button></div>');
82        }else{
83            $('#shoppingListDiv').append('<div class="ng-hide"> 你的購物車是空的 </div>');
84        }
85    }
86
87}
88/**
89 * 新增商品
90 */
91function shoppingAddProduct($obj) {
92    if(!$obj.data("specifications")){
93        alert('請選擇規格');
94        return false;
95    }
96    loadingStart();
97    $.ajax({
98        url: _jsPath+"/shopping",
99        type: "GET",
100        data: {
101            ajax: "addProduct",
102            productid: $obj.data("productid"),
103            specifications: $obj.data("specifications"),
104            count: $obj.val(),
105        },
106        
107        success: function(msg) {
108            try {
109                var temp = msg;
110                if(typeof(msg)!="object"){
111                    temp = JSON.parse(msg);
112                }
113                if (!temp.response) {
114                    alert(temp.message);
115                    if(temp.data["toUrl"]){
116                        location.href = temp.data["toUrl"];
117                    }
118                }
119                shoppingListReload(temp.data);
120                loadingStop();
121                // window.location.reload();
122                // 左側
123            } catch (e) {
124                alert("error : " + e);
125            }
126        }
127    });
128    return true;
129}
130
131/**
132 * 刪除商品
133 */
134function shoppingRmProduct($obj,flag) {
135    loadingStart();
136    $.ajax({
137        url: _jsPath+"/shopping",
138        type: "GET",
139        data: {
140            ajax: "rmProduct",
141            productid: $obj.data("productid"),
142            specifications: $obj.data("specifications")
143        },
144        
145        success: function(msg) {
146            try {
147                var temp = msg;
148                if(typeof(msg)!="object"){
149                    temp = JSON.parse(msg);
150                }
151                if(typeof(flag) == "undefined"){
152                    alert(temp.message);
153                    if (!temp.response) {
154                        loadingStop();
155                        return false;
156                    }
157                    window.location.reload();
158                }
159                shoppingListReload();
160            } catch (e) {
161                alert("error : " + e);
162            }
163        }
164    });
165}
166
167/**
168 * 修改商品數量
169 */
170function shoppingEditCount($obj) {
171    // loadingStart();
172    $.ajax({
173        url: _jsPath+"/shopping",
174        type: "GET",
175        data: {
176            ajax: "editCount",
177            productid: $obj.data("productid"),
178            specifications: $obj.data("specifications"),
179            count: $obj.val(),
180        },
181        
182        success: function(msg) {
183            // try {
184            //     loadingStop();
185            //     temp = JSON.parse(msg);
186            //     alert(temp.message);
187            //     if (!temp.response) {
188            //         return false;
189            //     }
190            //     window.location.reload();
191            // } catch (e) {
192            //     alert("error : " + e);
193            // }
194            try {
195                // loadingStop();
196                var temp = msg;
197                if(typeof(msg)!="object"){
198                    temp = JSON.parse(msg);
199                }
200                if (!temp.response) {
201                    alert(temp.message);
202                    window.location.reload()
203                    return false;
204                }
205                if (typeof(shopping_dcoo)!="undefined"){
206                    window.clearTimeout(shopping_dcoo);
207                }
208                shopping_dcoo = window.setTimeout("window.location.reload()",1000);
209                // window.location.reload();
210            } catch (e) {
211                alert("error : " + e);
212            }
213        }
214    });
215}
216
217/**
218 * 新增加價購商品
219 */
220function shoppingAddAddProduct($obj) {
221    loadingStart();
222    $.ajax({
223        url: _jsPath+"/shopping",
224        type: "GET",
225        data: {
226            ajax: "addAddProduct",
227            productid: $obj.data("productid"),
228            addProductid: $obj.data("addproductid"),
229            specifications: $obj.data("specifications"),
230            count: $obj.val(),
231        },
232        
233        success: function(msg) {
234            try {
235                var temp = msg;
236                if(typeof(msg)!="object"){
237                    temp = JSON.parse(msg);
238                }
239                alert(temp.message);
240                if (!temp.response) {
241                    if(temp.data["toUrl"]){
242                        location.href = temp.data["toUrl"];
243                    }
244                }
245                shoppingListReload(temp.data);
246                loadingStop();
247                window.location.reload();
248                // 左側
249            } catch (e) {
250                alert("error : " + e);
251            }
252        }
253    });
254}
255
256
257/**
258 * 刪除加價購商品
259 */
260function shoppingRmAddProduct($obj,flag) {
261    loadingStart();
262    $.ajax({
263        url: _jsPath+"/shopping",
264        type: "GET",
265        data: {
266            ajax: "rmAddProduct",
267            productid: $obj.data("productid"),
268            addProductid: $obj.data("addproductid"),
269            specifications: $obj.data("specifications")
270        },
271        
272        success: function(msg) {
273            try {
274                var temp = msg;
275                if(typeof(msg)!="object"){
276                    temp = JSON.parse(msg);
277                }
278                if(typeof(flag) == "undefined"){
279                    alert(temp.message);
280                    if (!temp.response) {
281                        loadingStop();
282                        return false;
283                    }
284                    window.location.reload();
285                }
286                window.location.reload();
287                shoppingListReload();
288            } catch (e) {
289                alert("error : " + e);
290            }
291        }
292    });
293}
294
295
296/**
297 * 修改加價購商品數量
298 */
299function shoppingAddEditCount($obj) {
300    loadingStart();
301    $.ajax({
302        url: _jsPath+"/shopping",
303        type: "GET",
304        data: {
305            ajax: "editAddCount",
306            productid: $obj.data("productid"),
307            addProductid: $obj.data("addproductid"),
308            specifications: $obj.data("specifications"),
309            count: $obj.val(),
310        },
311        
312        success: function(msg) {
313            try {
314                loadingStop();
315                var temp = msg;
316                if(typeof(msg)!="object"){
317                    temp = JSON.parse(msg);
318                }
319                if (!temp.response) {
320                    return false;
321                }
322                alert(temp.message);
323                window.location.reload();
324            } catch (e) {
325                alert("error : " + e);
326            }
327        }
328    });
329}
330
331/**
332 * 使用紅利
333 */
334function usePoint(point) {
335    loadingStart();
336    $.ajax({
337        url: _jsPath+"/shopping",
338        type: "GET",
339        data: {
340            ajax: "usePoint",
341            point: point,
342        },
343        
344        success: function(msg) {
345            try {
346                loadingStop();
347                var temp = msg;
348                if(typeof(msg)!="object"){
349                    temp = JSON.parse(msg);
350                }
351                if (!temp.response) {
352                    alert(temp.message);
353                    return false;
354                }
355                window.location.reload();
356            } catch (e) {
357                alert("error : " + e);
358            }
359        }
360    });
361}
362
363/**
364 * 使用折扣卷
365 */
366function useCoupon(coupon) {
367    loadingStart();
368    $.ajax({
369        url: _jsPath+"/shopping",
370        type: "GET",
371        data: {
372            ajax: "useCoupon",
373            coupon: coupon,
374        },
375        dataType: 'text',
376        success: function(msg) {
377            try {
378                loadingStop();
379                temp = JSON.parse(msg);
380                if (!temp.response) {
381                    alert(temp.message);
382                }
383                window.location.reload();
384            } catch (e) {
385                alert("error : " + e);
386            }
387        }
388    });
389}
390
391/**
392 * loading
393 */
394function loadingStart(selector,theme){
395
396    if(!selector){
397        selector = "body";
398    }
399    if(theme){
400        $(selector).loading( {
401            theme: 'dark',
402            zIndex: 99999999
403        });
404    }else{
405
406        $(selector).append('<div class="loader loader-default is-active" data-text="'+_jsMsg["LOADING"]+'"></div>');
407        $(selector).loading({
408            overlay: $(".loader"),
409            zIndex: 99999999
410        });
411    }
412}
413
414function loadingStop(selector){
415    if(!selector){
416        selector = "body";
417    }
418    $(selector).loading("stop");
419}
420
421
422$(window).keydown(function(event) {
423    if (event.which == 27){
424      loadingStop();
425    }
426});
427
428$(function(){
429    // $("img").lazyload();
430
431    $('table[data-type="basictable"]').each(function(index,obj){
432        $(this).basictable();
433    });
434});
435
436
437//https://console.firebase.google.com
438$(function(){
439    // fcm();
440});
441function fcm(){
442    if (window.location.href.search('https:')>=0 && typeof(firebase)!="undefined"){
443        const messaging = firebase.messaging();
444        //--要求授權
445        messaging.requestPermission()
446        .then(function(){
447            return messaging.getToken();
448        })
449        .then(function(token){ //--取得Token
450            $.ajax( {
451                url : _jsPath+'/fcm',
452                data: {push_token:token},
453                type:"GET",
454                dataType:'text',
455                async: true,
456                success: function(msg){
457                }
458            });
459            console.log('Token: '+token);
460        })
461        .catch(function(err){
462            console.log('Have Error: '+err); 
463        });
464        
465        messaging.onMessage(function(payload){ //--接收到通知時
466          console.log('onMessage: ', payload);
467        });
468
469    }
470}

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.