PageSourceSearch

https://comprarargan.com/static/common/js/vietrue.js

js comprarargan.com collected 2026-10-03 18:23:18 UTC 8,814 bytes, 212 lines download raw bytes

1let Jie = {
2    state: {
3        xhr: '',
4        isClickEvent: true
5    },
6    tool: {
7        /**
8         * 通知信息弹窗
9         * @param msg  提示信息
10         * @param callback 回调函数
11         * @param config 参数
12         */
13        notification: function (msg, callback, config = {}) {
14            if (!config.time || parseInt(config.time) <= 0) {
15                config.time = 1400;
16            }
17            if (typeof layer === "object") {
18                layer.msg(msg, config, callback);
19            } else {
20                alert(msg);
21                let autoInterval = setInterval(function () {
22                    callback();
23                    clearInterval(autoInterval);
24                }, time);
25            }
26        },
27        /**
28         * ajax提交数据
29         * @param url 提交地址
30         * @param data 提交数据
31         * @param callback 回调函数
32         * @param isAsync 是否异步
33         */
34        ajaxRequest: function (url, data, callback, isAsync = false) {
35            if (Jie.state.xhr && isAsync) {
36                Jie.state.xhr.abort();
37            }
38            Jie.state.xhr = $.ajax({
39                type: "POST",
40                dataType: "json",
41                url: url,
42                data: data,
43                async: isAsync,
44                success: function (result) {
45                    callback(result);
46                },
47                error: function (result) {
48                    if (typeof result.responseJSON === "object") {
49                        Jie.tool.notification(result.responseJSON.msg);
50                    } else {
51                        Jie.tool.notification(result.statusText);
52                    }
53                },
54            });
55        },
56        /**
57         * ajax提交form表单
58         * @param url 提交地址
59         * @param data 提交数据
60         * @param callback 回调函数
61         * @param isAsync 是否异步
62         */
63        ajaxFormRequest: function (url, data, callback, isAsync = false) {
64            if (Jie.state.xhr && isAsync) {
65                Jie.state.xhr.abort();
66            }
67            Jie.state.xhr = $.ajax({
68                type: "POST",
69                dataType: "json",
70                url: url,
71                data: data,
72                processData: false,
73                contentType: false,
74                success: function (result) {
75                    callback(result);
76                },
77                async: isAsync,
78                error: function (result) {
79                    if (typeof result.responseJSON === "object") {
80                        Jie.tool.notification(result.responseJSON.msg);
81                    } else {
82                        Jie.tool.notification(result.statusText);
83                    }
84                }
85            });
86        }
87    },
88    events: {
89        /**
90         * 滑动到指定id位置
91         * @param id dom ID
92         * @param top 顶部偏移距离
93         */
94        scrollPosition: function (id, top = 0) {
95            let offset = $(id).offset();
96            $('body,html').animate({
97                scrollTop: offset.top + top
98            });
99        },
100        /**
101         * 点击提交数据事件
102         * @param config 参数
103         */
104        ajaxSendEvent: function (config = {}) {
105            if (config.elem) {
106                $(config.elem).on('click', config.button ? config.button : 'button', function () {
107                    if (Jie.state.isClickEvent) {
108                        Jie.state.isClickEvent = false;
109                        let dataForm, ajaxFun, _this = this;
110                        if (config.data && typeof (config.data) === "function") {
111                            dataForm = config.data();
112                            ajaxFun = Jie.tool.ajaxRequest;
113                        } else {
114                            dataForm = new FormData($(_this).parents('form')[0]);
115                            ajaxFun = Jie.tool.ajaxFormRequest;
116                        }
117                        if (config.verify && typeof (config.verify) === "function" && config.verify(dataForm) === false) {
118                            Jie.state.isClickEvent = true;
119                            return;
120                        }
121                        ajaxFun(config.url, dataForm, function (result) {
122                            if (result.code === 1) {
123                                if (config.success && typeof (config.success) === "function") {
124                                    Jie.state.isClickEvent = true;
125                                    config.success(result);
126                                } else {
127                                    Jie.tool.notification(result.msg, function () {
128                                        window.location.href = result.url ? result.url : '';
129                                    });
130                                }
131                            } else {
132                                if (config.error && typeof (config.error) === "function") {
133                                    Jie.state.isClickEvent = true;
134                                    config.error(result);
135                                } else {
136                                    // $("form .form-verify").click();
137                                    Jie.tool.notification(result.msg, function () {
138                                        Jie.state.isClickEvent = true;
139                                    });
140                                }
141                            }
142                        });
143                        return false;
144                    }
145                });
146            }
147        },
148        /**
149         * 点击加载数据事件
150         * @param config 参数
151         */
152        clickLoadMore: function (config = {}) {
153            let url = config.url ? config.url : '', template = config.template ? config.template : '',
154                page = config.page ? config.page : 1, num = config.num ? config.num : 6,
155                ajaxBox = config.box ? config.box : '#ajaxBox', button = config.button ? config.button : '#loadMore';
156            $(document).on('click', button, function () {
157                if (Jie.state.isClickEvent) {
158                    Jie.state.isClickEvent = false;
159                    page++;
160                    Jie.tool.ajaxRequest(url, {page: page, template: template}, function (result) {
161                        Jie.state.isClickEvent = true;
162                        if (result.code === 1 && result.data) {
163                            if ($('<div>').html(result.data).children().length < num) {
164                                $(button).hide();
165                            }
166                            $(ajaxBox).append(result.data);
167                        } else {
168                            $(button).hide();
169                        }
170                    });
171                }
172            });
173        },
174        /**
175         * 滚动加载数据事件
176         * @param config 参数
177         */
178        scrollLoadMore: function (config = {}) {
179            let url = config.url ? config.url : '', template = config.template ? config.template : '',
180                page = config.page ? config.page : 1, num = config.num ? config.num : 6,
181                ajaxBox = config.box ? config.box : '#ajaxBox', isScroll = true;
182            $(window).scroll(function () {
183                let pageHeight = $(window).scrollTop(),
184                    thisHeight = $(ajaxBox).offset().top + $(ajaxBox).height() - $(window).height() - 300; //容器底部距离顶部的距离
185                if (pageHeight > thisHeight && kai) {
186                    if (isScroll) {
187                        isScroll = false;
188                        page++;
189                        Jie.tool.ajaxRequest(url, {page: page, template: template}, function (result) {
190                            isScroll = true;
191                            if (result.code === 1 && result.data) {
192                                if ($('<div>').html(result.data).children().length < num) {
193                                    isScroll = false;
194                                }
195                                $(ajaxBox).append(result.data);
196                            } else {
197                                isScroll = false;
198                            }
199                        });
200                    }
201                }
202            });
203
204        }
205    }
206};
207
208$("form .form-verify").click(function () {
209    var verifyimg = $(this).attr("src");
210    $(this).attr("src", verifyimg.replace(/\?.*$/, '') + '?' + Math.random());
211});
212

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.