PageSourceSearch

https://www.shzckj.cn/static/js/frontend.js?v=1791374616

js shzckj.cn collected 2026-10-07 12:03:48 UTC 55,063 bytes, 1,409 lines download raw bytes

1;(function () {
2    //全局ajax处理
3    $.ajaxSetup({
4        complete: function (jqXHR) {
5        },
6        data: {},
7        error: function (jqXHR, textStatus, errorThrown) {
8            //请求失败处理
9        }
10    });
11
12    if ($.browser && $.browser.msie) {
13        //ie 都不缓存
14        $.ajaxSetup({
15            cache: false
16        });
17    }
18
19    //不支持placeholder浏览器下对placeholder进行处理
20    if (document.createElement('input').placeholder !== '') {
21        $('[placeholder]').focus(function () {
22            var input = $(this);
23            if (input.val() == input.attr('placeholder')) {
24                input.val('');
25                input.removeClass('placeholder');
26            }
27        }).blur(function () {
28            var input = $(this);
29            if (input.val() == '' || input.val() == input.attr('placeholder')) {
30                input.addClass('placeholder');
31                input.val(input.attr('placeholder'));
32            }
33        }).blur().parents('form').submit(function () {
34            $(this).find('[placeholder]').each(function () {
35                var input = $(this);
36                if (input.val() == input.attr('placeholder')) {
37                    input.val('');
38                }
39            });
40        });
41    }
42
43
44    //所有加了dialog类名的a链接,自动弹出它的href
45    if ($('a.js-dialog').length) {
46        Wind.use('artDialog', 'iframeTools', function () {
47            $('.js-dialog').on('click', function (e) {
48                e.preventDefault();
49                var $_this = this,
50                    _this  = $($_this);
51                art.dialog.open($(this).prop('href'), {
52                    close: function () {
53                        $_this.focus(); //关闭时让触发弹窗的元素获取焦点
54                        return true;
55                    },
56                    title: _this.prop('title')
57                });
58            }).attr('role', 'button');
59
60        });
61    }
62
63    //所有的ajax form提交,由于大多业务逻辑都是一样的,故统一处理
64    var ajaxForm_list = $('form.js-ajax-form');
65    if (ajaxForm_list.length) {
66        Wind.use('ajaxForm', 'noty', 'validate', function () {
67
68            //var form = btn.parents('form.js-ajax-form');
69            var $btn;
70
71            $('button.js-ajax-submit').on('click', function (e) {
72                //e.preventDefault();
73                /*var btn = $(this).find('button.js-ajax-submit'),
74                 form = $(this);*/
75                var btn = $(this), form = btn.parents('form.js-ajax-form');
76                $btn    = btn;
77
78                if (btn.data("loading")) {
79                    return false;
80                }
81                //批量操作 判断选项
82                if (btn.data('subcheck')) {
83                    btn.parent().find('span').remove();
84                    if (form.find('input.js-check:checked').length) {
85                        var msg = btn.data('msg');
86                        if (msg) {
87                            noty({
88                                text: msg,
89                                type: 'confirm',
90                                layout: "center",
91                                timeout: false,
92                                modal: true,
93                                buttons: [
94                                    {
95                                        addClass: 'btn btn-primary',
96                                        text: '确定',
97                                        onClick: function ($noty) {
98                                            $noty.close();
99                                            btn.data('subcheck', false);
100                                            btn.click();
101                                        }
102                                    },
103                                    {
104                                        addClass: 'btn btn-danger',
105                                        text: '取消',
106                                        onClick: function ($noty) {
107                                            $noty.close();
108                                        }
109                                    }
110                                ]
111                            });
112                        } else {
113                            btn.data('subcheck', false);
114                            btn.click();
115                        }
116
117                    } else {
118                        noty({
119                            text: "请至少选择一项",
120                            type: 'error',
121                            layout: 'center'
122                        });
123                    }
124                    return false;
125                }
126
127                //ie处理placeholder提交问题
128                if ($.browser && $.browser.msie) {
129                    form.find('[placeholder]').each(function () {
130                        var input = $(this);
131                        if (input.val() == input.attr('placeholder')) {
132                            input.val('');
133                        }
134                    });
135                }
136
137            });
138
139            ajaxForm_list.each(function () {
140                $(this).validate({
141                    //是否在获取焦点时验证
142                    //onfocusout : false,
143                    //是否在敲击键盘时验证
144                    //onkeyup : false,
145                    //当鼠标点击时验证
146                    //onclick : false,
147                    //给未通过验证的元素加效果,闪烁等
148                    highlight: function (element, errorClass, validClass) {
149                        if (element.type === "radio") {
150                            this.findByName(element.name).addClass(errorClass).removeClass(validClass);
151                        } else {
152                            var $element = $(element);
153                            $element.addClass(errorClass).removeClass(validClass);
154                            $element.parent().addClass("has-error");//bootstrap3表单
155                            $element.parents('.control-group').addClass("error");//bootstrap2表单
156
157                        }
158                    },
159                    unhighlight: function (element, errorClass, validClass) {
160                        if (element.type === "radio") {
161                            this.findByName(element.name).removeClass(errorClass).addClass(validClass);
162                        } else {
163                            var $element = $(element);
164                            $element.removeClass(errorClass).addClass(validClass);
165                            $element.parent().removeClass("has-error");//bootstrap3表单
166                            $element.parents('.control-group').removeClass("error");//bootstrap2表单
167                        }
168                    },
169                    showErrors: function (errorMap, errorArr) {
170                        var i, elements, error;
171                        for (i = 0; this.errorList[i]; i++) {
172                            error = this.errorList[i];
173                            if (this.settings.highlight) {
174                                this.settings.highlight.call(this, error.element, this.settings.errorClass, this.settings.validClass);
175                            }
176                            //this.showLabel( error.element, error.message );
177                        }
178                        if (this.errorList.length) {
179                            //this.toShow = this.toShow.add( this.containers );
180                        }
181                        if (this.settings.success) {
182                            for (i = 0; this.successList[i]; i++) {
183                                //this.showLabel( this.successList[ i ] );
184                            }
185                        }
186                        if (this.settings.unhighlight) {
187                            for (i = 0, elements = this.validElements(); elements[i]; i++) {
188                                this.settings.unhighlight.call(this, elements[i], this.settings.errorClass, this.settings.validClass);
189                            }
190                        }
191                        this.toHide = this.toHide.not(this.toShow);
192                        this.hideErrors();
193                        this.addWrapper(this.toShow).show();
194                    },
195                    submitHandler: function (form) {
196                        var $form = $(form);
197                        if(!$btn){
198                            $btn=$form.find('button.js-ajax-submit');
199                        }
200                        $form.ajaxSubmit({
201                            url: $btn && $btn.data('action') ? $btn.data('action') : $form.attr('action'), //按钮上是否自定义提交地址(多按钮情况)
202                            dataType: 'json',
203                            beforeSubmit: function (arr, $form, options) {
204                                if($btn){
205                                    $btn.data("loading", true);
206                                    var text = $btn.text();
207                                    //按钮文案、状态修改
208                                    $btn.text(text + '...').prop('disabled', true).addClass('disabled');
209                                }
210                            },
211                            success: function (data, statusText, xhr, $form) {
212
213                                function _refresh() {
214                                    if (data.url) {
215                                        if (window.parent.art) {
216                                            //iframe弹出页
217                                            window.parent.location.href = data.url;
218
219                                        } else {
220                                            window.location.href = data.url;
221                                        }
222                                    } else {
223                                        if (data.code == 1) {
224                                            var wait = $btn.data("wait");
225                                            if (window.parent.art) {
226                                                reloadPage(window.parent);
227                                            } else {
228                                                //刷新当前页
229                                                reloadPage(window);
230                                            }
231                                        }
232                                    }
233                                }
234
235                                var text = $btn.text();
236                                //按钮文案、状态修改
237                                $btn.removeClass('disabled').prop('disabled', false).text(text.replace('...', '')).parent().find('span').remove();
238                                if (data.code == 1) {
239                                    if ($btn.data('success')) {
240                                        var successCallback = $btn.data('success');
241                                        window[successCallback](data, statusText, xhr, $form);
242                                        return;
243                                    }
244                                    noty({
245                                        text: data.msg,
246                                        type: 'success',
247                                        layout: 'center',
248                                        modal: true,
249                                        callback: {
250                                            afterClose: function () {
251                                                _refresh();
252                                            }
253                                        }
254                                    });
255                                } else if (data.code == 0) {
256                                    if ($btn.data('error')) {
257                                        var errorCallback = $btn.data('error');
258                                        window[errorCallback](data, statusText, xhr, $form);
259                                        return;
260                                    }
261
262                                    var $verify_img = $form.find(".verify_img");
263                                    if ($verify_img.length) {
264                                        $verify_img.attr("src", $verify_img.attr("src") + "&refresh=" + Math.random());
265                                    }
266
267                                    var $verify_input = $form.find("[name='verify']");
268                                    $verify_input.val("");
269
270                                    noty({
271                                        text: data.msg,
272                                        type: 'error',
273                                        layout: 'center',
274                                        callback: {
275                                            afterClose: function () {
276                                                _refresh();
277                                            }
278                                        }
279                                    });
280                                }
281
282
283                            },
284                            error: function (xhr, e, statusText) {
285                                noty({
286                                    text: statusText,
287                                    type: 'error',
288                                    layout: 'center',
289                                    callback: {
290                                        // afterClose: function () {
291                                        //     if (window.parent.art) {
292                                        //         reloadPage(window.parent);
293                                        //     } else {
294                                        //         //刷新当前页
295                                        //         reloadPage(window);
296                                        //     }
297                                        // }
298                                    }
299                                });
300                            },
301                            complete: function () {
302                                $btn.data("loading", false);
303                            }
304                        });
305                    }
306                });
307            });
308
309        });
310    }
311
312    //dialog弹窗内的关闭方法
313    $('#js-dialog-close').on('click', function (e) {
314        e.preventDefault();
315        try {
316            art.dialog.close();
317        } catch (err) {
318            Wind.use('artDialog', 'iframeTools', function () {
319                art.dialog.close();
320            });
321        }
322        ;
323    });
324
325    //所有的删除操作,删除数据后刷新页面
326    if ($('a.js-ajax-delete').length) {
327        Wind.use('noty', function () {
328            $('.js-ajax-delete').on('click', function (e) {
329                e.preventDefault();
330                var $_this    = this,
331                    $this     = $($_this),
332                    href      = $this.data('href'),
333                    refresh   = $this.data('refresh'),
334                    msg       = $this.data('msg');
335                okBtnText     = $this.data('ok-btn');
336                cancelBtnText = $this.data('cancel-btn');
337                href          = href ? href : $this.attr('href');
338                noty({
339                    text: msg ? msg : '确定要删除吗?',
340                    type: 'confirm',
341                    layout: "center",
342                    timeout: false,
343                    modal: true,
344                    buttons: [
345                        {
346                            addClass: 'btn btn-primary',
347                            text: okBtnText ? okBtnText : '确定',
348                            onClick: function ($noty) {
349                                $noty.close();
350                                $.getJSON(href).done(function (data) {
351                                    if (data.code == 1) {
352                                        if (data.url) {
353                                            location.href = data.url;
354                                        } else if (refresh || refresh == undefined) {
355                                            reloadPage(window);
356                                        }
357                                    } else if (data.code == 0) {
358                                        noty({
359                                            text: data.msg,
360                                            type: 'error',
361                                            layout: 'center',
362                                            callback: {
363                                                afterClose: function () {
364                                                    if (data.url) {
365                                                        location.href = data.url;
366                                                    }
367                                                }
368                                            }
369                                        });
370                                    }
371                                });
372                            }
373                        },
374                        {
375                            addClass: 'btn btn-danger',
376                            text: cancelBtnText ? cancelBtnText : '取消',
377                            onClick: function ($noty) {
378                                $noty.close();
379                            }
380                        }
381                    ]
382                });
383
384            });
385
386        });
387    }
388
389
390    if ($('a.js-ajax-dialog-btn').length) {
391        Wind.use('noty', function () {
392            $('.js-ajax-dialog-btn').on('click', function (e) {
393                e.preventDefault();
394                var $_this  = this,
395                    $this   = $($_this),
396                    href    = $this.data('href'),
397                    refresh = $this.data('refresh'),
398                    msg     = $this.data('msg');
399                href        = href ? href : $this.attr('href');
400                noty({
401                    text: msg,
402                    type: 'confirm',
403                    layout: "center",
404                    timeout: false,
405                    modal: true,
406                    buttons: [
407                        {
408                            addClass: 'btn btn-primary',
409                            text: '确定',
410                            onClick: function ($noty) {
411                                $noty.close();
412                                $.getJSON(href).done(function (data) {
413                                    if (data.code == 1) {
414                                        if (data.url) {
415                                            location.href = data.url;
416                                        } else if (refresh || refresh == undefined) {
417                                            reloadPage(window);
418                                        }
419                                    } else if (data.code == 0) {
420                                        noty({
421                                            text: data.msg,
422                                            type: 'error',
423                                            layout: 'center',
424                                            callback: {
425                                                afterClose: function () {
426                                                    if (data.url) {
427                                                        location.href = data.url;
428                                                    }
429                                                }
430                                            }
431                                        });
432                                    }
433                                });
434                            }
435                        },
436                        {
437                            addClass: 'btn btn-danger',
438                            text: '取消',
439                            onClick: function ($noty) {
440                                $noty.close();
441                            }
442                        }
443                    ]
444                });
445
446            });
447
448        });
449    }
450
451    if ($('a.js-ajax-btn').length) {
452        Wind.use('noty', function () {
453            $('.js-ajax-btn').on('click', function (e) {
454                e.preventDefault();
455                var $_this = this,
456                    $this  = $($_this),
457                    href   = $this.data('href'),
458                    msg    = $this.data('msg');
459                refresh    = $this.data('refresh');
460                href       = href ? href : $this.attr('href');
461                refresh    = refresh == undefined ? 1 : refresh;
462
463
464                $.getJSON(href).done(function (data) {
465                    if (data.code == 1) {
466                        noty({
467                            text: data.msg,
468                            type: 'success',
469                            layout: 'center',
470                            callback: {
471                                afterClose: function () {
472                                    if (data.url) {
473                                        location.href = data.url;
474                                        return;
475                                    }
476
477                                    if (refresh || refresh == undefined) {
478                                        reloadPage(window);
479                                    }
480                                }
481                            }
482                        });
483                    } else if (data.code == 0) {
484                        noty({
485                            text: data.msg,
486                            type: 'error',
487                            layout: 'center',
488                            callback: {
489                                afterClose: function () {
490                                    if (data.url) {
491                                        location.href = data.url;
492                                    }
493                                }
494                            }
495                        });
496                    }
497                });
498
499            });
500
501        });
502    }
503
504    //所有的请求刷新操作
505    var ajax_refresh = $('a.js-ajax-refresh'),
506        refresh_lock = false;
507    if (ajax_refresh.length) {
508        ajax_refresh.on('click', function (e) {
509            e.preventDefault();
510            if (refresh_lock) {
511                return false;
512            }
513            refresh_lock = true;
514
515            $.post(this.href, function (data) {
516                refresh_lock = false;
517
518                if (data.code == 1) {
519                    if (data.url) {
520                        location.href = data.url;
521                    } else {
522                        reloadPage(window);
523                    }
524                } else if (data.code == 0) {
525                    Wind.art.dialog.alert(data.msg);
526                }
527            }, 'json');
528        });
529    }
530
531    //短信验证码
532    var $js_get_mobile_code = $('.js-get-mobile-code');
533    if ($js_get_mobile_code.length > 0) {
534        Wind.use('noty', function () {
535            $js_get_mobile_code.on('click', function () {
536                console.log(111);
537                var $this = $(this);
538                if ($this.data('loading')) return;
539                if ($this.data('sending')) return;
540                var $mobile_input = $($this.data('mobile-input'));
541                var mobile        = $mobile_input.val();
542                if (mobile == '') {
543                    $mobile_input.focus();
544                    return;
545                }
546
547                var $form           = $this.parents('form');
548                var $captchaInput   = $("input[name='captcha']", $form);
549                var $captchaIdInput = $("input[name='_captcha_id']", $form);
550                var captcha         = $captchaInput.val();
551                var captchaId       = $captchaIdInput.val();
552
553
554                $this.data('loading', true);
555                $this.data('sending', true);
556
557                var url = $this.data('url');
558
559                var init_secode_left = parseInt($this.data('init-second-left'));
560                init_secode_left     = init_secode_left > 0 ? init_secode_left : 60;
561                var init_text        = $this.text();
562                $this.data('second-left', init_secode_left);
563                var wait_msg = $this.data('wait-msg');
564                var codeType = $this.data('type');
565
566                $.ajax({
567                    url: url,
568                    type: 'POST',
569                    dataType: 'json',
570                    data: {username: mobile, type: codeType},
571                    success: function (data) {
572                        if (data.code == 1) {
573                            noty({
574                                text: data.msg,
575                                type: 'success',
576                                layout: 'center'
577                            });
578
579                            $this.text(wait_msg.replace('[second]', init_secode_left));
580
581                            var mtimer = setInterval(function () {
582                                if (init_secode_left > 0) {
583                                    init_secode_left--;
584                                    $this.text(wait_msg.replace('[second]', init_secode_left));
585                                } else {
586                                    clearInterval(mtimer);
587                                    $this.text(init_text);
588                                    $this.data('sending', false);
589                                }
590
591                            }, 1000);
592                        } else {
593                            $captchaInput.val('');
594                            var $verify_img = $form.find(".verify_img");
595                            if ($verify_img.length) {
596                                $verify_img.attr("src", $verify_img.attr("src") + "&refresh=" + Math.random());
597                            }
598                            noty({
599                                text: data.msg,
600                                type: 'error',
601                                layout: 'center'
602                            });
603                            $this.data('sending', false);
604                        }
605                    },
606                    error: function () {
607                        $this.data('sending', false);
608                    },
609                    complete: function () {
610                        $this.data('loading', false);
611                    }
612                });
613            });
614
615        });
616    }
617
618    //邮件验证码
619    var $js_get_email_code = $('.js-get-email-code');
620    if ($js_get_email_code.length > 0) {
621        Wind.use('noty', function () {
622
623            $js_get_email_code.on('click', function () {
624                var $this = $(this);
625                if ($this.data('loading')) return;
626                if ($this.data('sending')) return;
627                var $email_input = $($this.data('email-input'));
628                var email        = $email_input.val();
629                if (email == '') {
630                    $email_input.focus();
631                    return;
632                }
633
634                var $form           = $this.parents('form');
635                var $captchaInput   = $("input[name='captcha']", $form);
636                var $captchaIdInput = $("input[name='_captcha_id']", $form);
637                var captcha         = $captchaInput.val();
638                var captchaId       = $captchaIdInput.val();
639
640                // if (!captcha) {
641                //     $captchaInput.focus();
642                //     return;
643                // }
644
645                $this.data('loading', true);
646                $this.data('sending', true);
647
648                var url = $this.data('url');
649
650                var init_secode_left = parseInt($this.data('init-second-left'));
651                init_secode_left     = init_secode_left > 0 ? init_secode_left : 60;
652                var init_text        = $this.text();
653                $this.data('second-left', init_secode_left);
654                var wait_msg = $this.data('wait-msg');
655                var codeType = $this.data('type');
656                $.ajax({
657                    url: url,
658                    type: 'POST',
659                    dataType: 'json',
660                    data: {username: email, captcha: captcha, captcha_id: captchaId, type: codeType},
661                    success: function (data) {
662                        if (data.code == 1) {
663                            noty({
664                                text: data.msg,
665                                type: 'success',
666                                layout: 'center'
667                            });
668
669                            $this.text(wait_msg.replace('[second]', init_secode_left));
670
671                            var mtimer = setInterval(function () {
672                                if (init_secode_left > 0) {
673                                    init_secode_left--;
674                                    $this.text(wait_msg.replace('[second]', init_secode_left));
675                                } else {
676                                    clearInterval(mtimer);
677                                    $this.text(init_text);
678                                    $this.data('sending', false);
679                                }
680
681                            }, 1000);
682                        } else {
683                            $captchaInput.val('');
684                            var $verify_img = $form.find(".verify_img");
685                            if ($verify_img.length) {
686                                $verify_img.attr("src", $verify_img.attr("src") + "&refresh=" + Math.random());
687                            }
688
689                            noty({
690                                text: data.msg,
691                                type: 'error',
692                                layout: 'center'
693                            });
694                            $this.data('sending', false);
695                        }
696                    },
697                    error: function () {
698                        $this.data('sending', false);
699                    },
700                    complete: function () {
701                        $this.data('loading', false);
702                    }
703                });
704            });
705
706        });
707    }
708
709    /*复选框全选(支持多个,纵横双控全选)。
710     *实例:版块编辑-权限相关(双控),验证机制-验证策略(单控)
711     *说明:
712     *	"js-check"的"data-xid"对应其左侧"js-check-all"的"data-checklist";
713     *	"js-check"的"data-yid"对应其上方"js-check-all"的"data-checklist";
714     *	全选框的"data-direction"代表其控制的全选方向(x或y);
715     *	"js-check-wrap"同一块全选操作区域的父标签class,多个调用考虑
716     */
717
718    if ($('.js-check-wrap').length) {
719        var total_check_all = $('input.js-check-all');
720
721        //遍历所有全选框
722        $.each(total_check_all, function () {
723            var check_all = $(this),
724                check_items;
725
726            //分组各纵横项
727            var check_all_direction = check_all.data('direction');
728            check_items             = $('input.js-check[data-' + check_all_direction + 'id="' + check_all.data('checklist') + '"]').not(":disabled");
729
730            //点击全选框
731            check_all.change(function (e) {
732                var check_wrap = check_all.parents('.js-check-wrap'); //当前操作区域所有复选框的父标签(重用考虑)
733
734                if ($(this).prop('checked')) {
735                    //全选状态
736                    check_items.prop('checked', true);
737
738                    //所有项都被选中
739                    if (check_wrap.find('input.js-check').length === check_wrap.find('input.js-check:checked').length) {
740                        check_wrap.find(total_check_all).prop('checked', true);
741                    }
742
743                } else {
744                    //非全选状态
745                    check_items.removeProp('checked');
746
747                    check_wrap.find(total_check_all).removeProp('checked');
748
749                    //另一方向的全选框取消全选状态
750                    var direction_invert = check_all_direction === 'x' ? 'y' : 'x';
751                    check_wrap.find($('input.js-check-all[data-direction="' + direction_invert + '"]')).removeProp('checked');
752                }
753
754            });
755
756            //点击非全选时判断是否全部勾选
757            check_items.change(function () {
758
759                if ($(this).prop('checked')) {
760
761                    if (check_items.filter(':checked').length === check_items.length) {
762                        //已选择和未选择的复选框数相等
763                        check_all.prop('checked', true);
764                    }
765
766                } else {
767                    check_all.removeProp('checked');
768                }
769
770            });
771
772
773        });
774
775    }
776
777    //日期选择器
778    var dateInput = $("input.js-date");
779    if (dateInput.length) {
780        Wind.use('datePicker', function () {
781            dateInput.datePicker();
782        });
783    }
784
785    //日期+时间选择器
786    var dateTimeInput = $("input.js-datetime");
787    if (dateTimeInput.length) {
788        Wind.use('datePicker', function () {
789            dateTimeInput.datePicker({
790                time: true
791            });
792        });
793    }
794
795    // bootstrap年选择器
796    var bootstrapYearInput = $("input.js-bootstrap-year")
797    if (bootstrapYearInput.length) {
798        Wind.css('bootstrapDatetimePicker');
799        Wind.use('bootstrapDatetimePicker', function () {
800            bootstrapYearInput.datetimepicker({
801                language: 'zh-CN',
802                format: 'yyyy',
803                minView: 'decade',
804                startView: 'decade',
805                todayBtn: 1,
806                autoclose: true
807            });
808        });
809    }
810
811    // bootstrap年月份选择器
812    var bootstrapYearMonthInput = $("input.js-bootstrap-year-month");
813    if (bootstrapYearMonthInput.length) {
814        Wind.css('bootstrapDatetimePicker');
815        Wind.use('bootstrapDatetimePicker', function () {
816            bootstrapYearMonthInput.datetimepicker({
817                language: 'zh-CN',
818                format: 'yyyy-mm',
819                minView: 'year',
820                startView: 'decade',
821                todayBtn: 1,
822                autoclose: true
823            });
824        });
825    }
826
827    // bootstrap日期选择器
828    var bootstrapDateInput = $("input.js-bootstrap-date")
829    if (bootstrapDateInput.length) {
830        Wind.css('bootstrapDatetimePicker');
831        Wind.use('bootstrapDatetimePicker', function () {
832            bootstrapDateInput.datetimepicker({
833                language: 'zh-CN',
834                format: 'yyyy-mm-dd',
835                minView: 'month',
836                todayBtn: 1,
837                autoclose: true
838            });
839        });
840    }
841
842    // bootstrap日期选择器日期+时间选择器
843    var bootstrapDateTimeInput = $("input.js-bootstrap-datetime");
844    if (bootstrapDateTimeInput.length) {
845        Wind.css('bootstrapDatetimePicker');
846        Wind.use('bootstrapDatetimePicker', function () {
847            bootstrapDateTimeInput.datetimepicker({
848                language: 'zh-CN',
849                format: 'yyyy-mm-dd hh:ii',
850                todayBtn: 1,
851                autoclose: true
852            });
853        });
854    }
855
856    //赞,拍等,有数量操作的按钮
857    var $js_count_btn = $('a.js-count-btn');
858    if ($js_count_btn.length) {
859        Wind.use('noty', function () {
860            $js_count_btn.on('click', function (e) {
861                e.preventDefault();
862                var $this = $(this),
863                    href  = $this.prop('href');
864
865                $.post(href, {}, function (data) {
866
867                    if (data.code == 1) {
868
869                        var $count = $this.find(".count");
870                        var count  = parseInt($count.text());
871                        $count.text(count + 1);
872                        if (data.msg) {
873                            noty({
874                                text: data.msg,
875                                type: 'success',
876                                layout: 'center',
877                                callback: {
878                                    afterClose: function () {
879                                        if (data.url) {
880                                            location.href = data.url;
881                                        }
882                                    }
883                                }
884                            });
885                        }
886
887
888                    } else if (data.code == 0) {
889                        noty({
890                            text: data.msg,
891                            type: 'error',
892                            layout: 'center',
893                            callback: {
894                                afterClose: function () {
895                                    if (data.url) {
896                                        location.href = data.url;
897                                    }
898                                }
899                            }
900                        });
901                    }
902
903
904                }, "json");
905
906            });
907
908        });
909    }
910
911    //地址联动
912    var $js_address_select = $('.js-address-select');
913    if ($js_address_select.length > 0) {
914        $('.js-address-province-select,.js-address-city-select').change(function () {
915            var $this                   = $(this);
916            var id                      = $this.val();
917            var $child_area_select;
918            var $this_js_address_select = $this.parents('.js-address-select');
919            if ($this.is('.js-address-province-select')) {
920                $child_area_select = $this_js_address_select.find('.js-address-city-select');
921                $this_js_address_select.find('.js-address-district-select').hide();
922            } else {
923                $child_area_select = $this_js_address_select.find('.js-address-district-select');
924            }
925
926            var empty_option = '<option class="js-address-empty-option" value="">' + $child_area_select.find('.js-address-empty-option').text() + '</option>';
927            $child_area_select.html(empty_option);
928
929            var child_area_html = $this.data('childarea' + id);
930            if (child_area_html) {
931                $child_area_select.show();
932                $child_area_select.html(child_area_html);
933                return;
934            }
935
936            $.ajax({
937                url: $this_js_address_select.data('url'),
938                type: 'POST',
939                dataType: 'JSON',
940                data: {id: id},
941                success: function (data) {
942                    if (data.code == 1) {
943                        if (data.data.areas.length > 0) {
944                            var html = [empty_option];
945
946                            $.each(data.data.areas, function (i, area) {
947                                var area_html = '<option value="[id]">[name]</option>';
948                                area_html     = area_html.replace('[name]', area.name);
949                                area_html     = area_html.replace('[id]', area.id);
950                                html.push(area_html);
951                            });
952                            html = html.join('', html);
953                            $this.data('childarea' + id, html);
954                            $child_area_select.html(html);
955                            $child_area_select.show();
956                        } else {
957                            $child_area_select.hide();
958
959                        }
960                    }
961                },
962                error: function () {
963
964                },
965                complete: function () {
966
967                }
968            });
969        });
970
971    }
972    //地址联动end
973
974    //
975    var $js_action_btn = $('a.js-action-btn');
976    if ($js_action_btn.length) {
977        Wind.use('noty', function () {
978            $js_action_btn.on('click', function (e) {
979                e.preventDefault();
980                var $this = $(this),
981                    href  = $this.prop('href');
982
983                $.post(href, {}, function (data) {
984
985                    if (data.code == '1') {
986
987                        if (data.msg) {
988                            noty({
989                                text: data.msg,
990                                type: 'success',
991                                layout: 'center',
992                                callback: {
993                                    afterClose: function () {
994                                        if (data.url) {
995                                            location.href = data.url;
996                                        }
997                                    }
998                                }
999                            });
1000                        }
1001
1002
1003                    } else if (data.code == 0) {
1004                        noty({
1005                            text: data.msg,
1006                            type: 'error',
1007                            layout: 'center',
1008                            callback: {
1009                                afterClose: function () {
1010                                    if (data.url) {
1011                                        location.href = data.url;
1012                                    }
1013                                }
1014                            }
1015                        });
1016                    }
1017                }, "json");
1018
1019            });
1020
1021        });
1022    }
1023    var search_button = $(".navbar-form .search-button");
1024    if (search_button.length > 0) {
1025        search_button.on('click', function (e) {
1026            $(this).parents('form').submit();
1027        });
1028    }
1029    var $js_favorite_btn = $('a.js-favorite-btn');
1030    if ($js_favorite_btn.length) {
1031        Wind.use('noty', function () {
1032            $js_favorite_btn.on('click', function (e) {
1033                e.preventDefault();
1034                var $this       = $(this),
1035                    href        = $this.prop('href'),
1036                    url         = $this.data("url"),
1037                    id          = $this.data("id"),
1038                    table       = $this.data('table'),
1039                    title       = $this.data("title"),
1040                    description = $this.data("description");
1041                $.post(href, {
1042                    id: id,
1043                    table: table,
1044                    url: url,
1045                    title: title,
1046                    description: description
1047                }, function (data) {
1048                    if (data.code == 1) {
1049                        if (data.msg) {
1050                            noty({
1051                                text: data.msg,
1052                                type: 'success',
1053                                layout: 'center',
1054                                callback: {
1055                                    afterClose: function () {
1056                                        if (data.url) {
1057                                            location.href = data.url;
1058                                        }
1059                                    }
1060                                }
1061                            });
1062                        }
1063                    } else if (data.code == 0) {
1064                        noty({
1065                            text: data.msg,
1066                            type: 'error',
1067                            layout: 'center',
1068                            callback: {
1069                                afterClose: function () {
1070                                    if (data.url) {
1071                                        location.href = data.url;
1072                                    }
1073                                }
1074                            }
1075                        });
1076                    }
1077
1078
1079                }, "json");
1080
1081            });
1082
1083        });
1084    }
1085
1086    $("[data-toggle='Tobotton']").on('click', function(){
1087        var height = $(window).height();
1088        $(window).scrollTop(height);
1089    });
1090    $("#seaselect").on('change', function () {
1091        var val = $(this).val();
1092        if (val == 0) {
1093            window.location.href = window.location.protocol + "//" + window.location.hostname + "/portal/question/index.html"
1094        } else {
1095            window.location.href = window.location.protocol + "//" + window.location.hostname + "/portal/question/index.html?cat_id="+val;
1096        }
1097    });
1098
1099    $(".search-icon").on('click', function(){
1100        var host = window.location.protocol + "//" + window.location.hostname + window.location.pathname,
1101            keyword = $(".question-search").val();
1102        console.log(keyword.length);
1103        if (keyword.length > 0) {
1104            window.location.href = host + "?title=" + keyword;
1105        }
1106        if (keyword.length == 0) {
1107            $(".search-control-question").toggleClass('active');
1108        }
1109    })
1110
1111    var searchActive = document.body.clientWidth < 768 ? 'active' : '';
1112    console.log(searchActive);
1113    if (!$(".search-control-question").hasClass('active')) {
1114        $(".search-control-question").addClass(searchActive);
1115    }
1116
1117})();
1118
1119//重新刷新页面,使用location.reload()有可能导致重新提交
1120function reloadPage(win) {
1121    if (win) {
1122
1123    } else {
1124        win = window;
1125    }
1126    var location  = win.location;
1127    location.href = location.pathname + location.search;
1128}
1129
1130//页面跳转
1131function redirect(url) {
1132    location.href = url;
1133}
1134
1135/**
1136 * 读取cookie
1137 * @param name
1138 * @returns
1139 */
1140function getCookie(name) {
1141    var cookieValue = null;
1142    if (document.cookie && document.cookie != '') {
1143        var cookies = document.cookie.split(';');
1144        for (var i = 0; i < cookies.length; i++) {
1145            var cookie = jQuery.trim(cookies[i]);
1146            // Does this cookie string begin with the name we want?
1147            if (cookie.substring(0, name.length + 1) == (name + '=')) {
1148                cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
1149                break;
1150            }
1151        }
1152    }
1153    return cookieValue;
1154}
1155
1156/**
1157 * 设置cookie
1158 */
1159function setCookie(name, value, options) {
1160    options = options || {};
1161    if (value === null) {
1162        value           = '';
1163        options.expires = -1;
1164    }
1165    var expires = '';
1166    if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
1167        var date;
1168        if (typeof options.expires == 'number') {
1169            date = new Date();
1170            date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
1171        } else {
1172            date = options.expires;
1173        }
1174        expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
1175    }
1176    var path        = options.path ? '; path=' + options.path : '';
1177    var domain      = options.domain ? '; domain=' + options.domain : '';
1178    var secure      = options.secure ? '; secure' : '';
1179    document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
1180}
1181
1182function openIframeDialog(url, title, options) {
1183    var params = {
1184        title: title,
1185        lock: true,
1186        opacity: 0,
1187        width: "95%"
1188    };
1189    params     = options ? $.extend(params, options) : params;
1190    Wind.use('artDialog', 'iframeTools', function () {
1191        art.dialog.open(url, params);
1192    });
1193}
1194
1195/**
1196 * 打开地图对话框
1197 *
1198 * @param url
1199 * @param title
1200 * @param options
1201 * @param callback
1202 */
1203function openMapDialog(url, title, options, callback) {
1204    Wind.css('artDialog');
1205    var params = {
1206        title: title,
1207        lock: true,
1208        opacity: 0,
1209        width: "95%",
1210        height: 400,
1211        ok: function () {
1212            if (callback) {
1213                var d            = this.iframe.contentWindow;
1214                var lng          = $("#lng_input", d.document).val();
1215                var lat          = $("#lat_input", d.document).val();
1216                var address      = {};
1217                address.address  = $("#address_input", d.document).val();
1218                address.province = $("#province_input", d.document).val();
1219                address.city     = $("#city_input", d.document).val();
1220                address.district = $("#district_input", d.document).val();
1221                callback.apply(this, [lng, lat, address]);
1222            }
1223        }
1224    };
1225    params     = options ? $.extend(params, options) : params;
1226    Wind.use('artDialog', 'iframeTools', function () {
1227        art.dialog.open(url, params);
1228    });
1229}
1230
1231/**
1232 * 打开文件上传对话框
1233 * @param dialog_title 对话框标题
1234 * @param callback 回调方法,参数有(当前dialog对象,选择的文件数组,你设置的extra_params)
1235 * @param extra_params 额外参数,object
1236 * @param multi 是否可以多选
1237 * @param filetype 文件类型,image,video,audio,file
1238 * @param app  应用名,CMF的应用名
1239 */
1240function openUploadDialog(dialog_title, callback, extra_params, multi, filetype, app) {
1241    Wind.css('artDialog');
1242    multi      = multi ? 1 : 0;
1243    filetype   = filetype ? filetype : 'image';
1244    app        = app ? app : GV.APP;
1245    var params = '&multi=' + multi + '&filetype=' + filetype + '&app=' + app;
1246    Wind.use("artDialog", "iframeTools", function () {
1247        art.dialog.open(GV.ROOT + 'user/Asset/webuploader?' + params, {
1248            title: dialog_title,
1249            id: new Date().getTime(),
1250            width: '600px',
1251            height: '350px',
1252            lock: true,
1253            fixed: true,
1254            background: "#CCCCCC",
1255            opacity: 0,
1256            ok: function () {
1257                if (typeof callback == 'function') {
1258                    var iframewindow = this.iframe.contentWindow;
1259                    var files        = iframewindow.get_selected_files();
1260                    console.log(files);
1261                    if (files && files.length > 0) {
1262                        callback.apply(this, [this, files, extra_params]);
1263                    } else {
1264                        return false;
1265                    }
1266
1267                }
1268            },
1269            cancel: true
1270        });
1271    });
1272}
1273
1274/**
1275 * 单个文件上传
1276 * @param dialog_title 上传对话框标题
1277 * @param input_selector 图片容器
1278 * @param filetype 文件类型,image,video,audio,file
1279 * @param extra_params 额外参数,object
1280 * @param app  应用名,CMF的应用名
1281 */
1282function uploadOne(dialog_title, input_selector, filetype, extra_params, app) {
1283    filetype = filetype ? filetype : 'file';
1284    openUploadDialog(dialog_title, function (dialog, files) {
1285        $(input_selector).val(files[0].filepath);
1286        $(input_selector + '-preview').attr('href', files[0].preview_url);
1287
1288        $(input_selector + '-name').val(files[0].name);
1289        $(input_selector + '-name-text').text(files[0].name);
1290
1291
1292    }, extra_params, 0, filetype, app);
1293}
1294
1295/**
1296 * 单个图片上传
1297 * @param dialog_title 上传对话框标题
1298 * @param input_selector 图片容器
1299 * @param extra_params 额外参数,object
1300 * @param app  应用名,CMF的应用名
1301 */
1302function uploadOneImage(dialog_title, input_selector, extra_params, app) {
1303    openUploadDialog(dialog_title, function (dialog, files) {
1304        $(input_selector).val(files[0].filepath);
1305        $(input_selector + '-preview').attr('src', files[0].preview_url);
1306
1307        $(input_selector + '-name').val(files[0].name);
1308        $(input_selector + '-name-text').text(files[0].name);
1309
1310    }, extra_params, 0, 'image', app);
1311}
1312
1313/**
1314 * 多图上传
1315 * @param dialog_title 上传对话框标题
1316 * @param container_selector 图片容器
1317 * @param item_tpl_wrapper_id 单个图片html模板容器id
1318 * @param extra_params 额外参数,object
1319 * @param app  应用名,CMF 的应用名
1320 */
1321function uploadMultiImage(dialog_title, container_selector, item_tpl_wrapper_id, extra_params, app) {
1322    openUploadDialog(dialog_title, function (dialog, files) {
1323        var tpl  = $('#' + item_tpl_wrapper_id).html();
1324        var html = '';
1325        $.each(files, function (i, item) {
1326            var itemtpl = tpl;
1327            itemtpl     = itemtpl.replace(/\{id\}/g, item.id);
1328            itemtpl     = itemtpl.replace(/\{url\}/g, item.url);
1329            itemtpl     = itemtpl.replace(/\{preview_url\}/g, item.preview_url);
1330            itemtpl     = itemtpl.replace(/\{filepath\}/g, item.filepath);
1331            itemtpl     = itemtpl.replace(/\{name\}/g, item.name);
1332            html += itemtpl;
1333        });
1334        $(container_selector).append(html);
1335
1336    }, extra_params, 1, 'image', app);
1337}
1338
1339/**
1340 * 多文件上传
1341 * @param dialog_title 上传对话框标题
1342 * @param container_selector 图片容器
1343 * @param item_tpl_wrapper_id 单个图片html模板容器id
1344 * @param filetype 文件类型,image,video,audio,file
1345 * @param extra_params 额外参数,object
1346 * @param app  应用名,CMF 的应用名
1347 */
1348function uploadMultiFile(dialog_title, container_selector, item_tpl_wrapper_id, filetype, extra_params, app) {
1349    filetype = filetype ? filetype : 'file';
1350    openUploadDialog(dialog_title, function (dialog, files) {
1351        var tpl  = $('#' + item_tpl_wrapper_id).html();
1352        var html = '';
1353        $.each(files, function (i, item) {
1354            var itemtpl = tpl;
1355            itemtpl     = itemtpl.replace(/\{id\}/g, item.id);
1356            itemtpl     = itemtpl.replace(/\{url\}/g, item.url);
1357            itemtpl     = itemtpl.replace(/\{preview_url\}/g, item.preview_url);
1358            itemtpl     = itemtpl.replace(/\{filepath\}/g, item.filepath);
1359            itemtpl     = itemtpl.replace(/\{name\}/g, item.name);
1360            html += itemtpl;
1361        });
1362        $(container_selector).append(html);
1363
1364    }, extra_params, 1, filetype, app);
1365}
1366
1367function openIframeLayer(url, title, options) {
1368
1369    var params = {
1370        type: 2,
1371        title: title,
1372        shadeClose: true,
1373        // skin: 'layui-layer-nobg',
1374        shade: [0.001, '#000000'],
1375        shadeClose: true,
1376        area: ['95%', '90%'],
1377        move: false,
1378        content: url,
1379        yes: function (index, layero) {
1380            //do something
1381            layer.close(index); //如果设定了yes回调,需进行手工关闭
1382        }
1383    };
1384    params     = options ? $.extend(params, options) : params;
1385
1386    Wind.css('layer');
1387
1388    Wind.use("layer", function () {
1389        layer.open(params);
1390    });
1391
1392}
1393
1394function uploadSingleFile(dialog_title, input_selector, fileType, extra_params, app) {
1395    fileType = fileType? fileType : 'file';
1396    openUploadDialog(dialog_title, function (dialog, files) {
1397        $(input_selector).val(files[0].filepath);
1398        $('.file-name').text(files[0].name);
1399        $('.file-area').show();
1400        $(input_selector + '-add-btn').hide();
1401
1402    }, extra_params, 0, fileType, app);
1403}
1404
1405function removeFile(input_selector) {
1406    $(input_selector).val();
1407    $('.file-area').hide();
1408    $(input_selector + '-add-btn').show();
1409}

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.