chengkun
2025-04-18 1bb985f32f2efe0f9dd69f3cf29a1c809b1cf96d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
$.ajaxSetup({
    xhrFields: {
        withCredentials: true
    },
    crossDomain:true 
});
// 获取表单提交值
function getFormValue(formid) {
    var itemForm = $("#" + formid).eq(0);
 
    var nameIndex = {}, //数组 name 索引
        field = {},
        fieldElem = itemForm.find('input,select,textarea') //获取所有表单域
    
    fieldElem.each(function(_, item) {
        var init_name; //初始 name
 
        item.name = (item.name || '').replace(/^\s*|\s*&/, '');
        if (!item.name) return;
        //用于支持数组 name
        if (/^.*\[\]$/.test(item.name)) {
            var key = item.name.match(/^(.*)\[\]$/g)[0];
            nameIndex[key] = nameIndex[key] | 0;
            init_name = item.name.replace(/^(.*)\[\]$/, '$1[' + (nameIndex[key]++) + ']');
        }
 
        if (/^checkbox|radio$/.test(item.type) && !item.checked) return; //复选框和单选框未选中,不记录字段     
        field[init_name || item.name] = item.value;
    });
    
    return field;
}
 
/**
 * @desc 邮箱格式验证
 */
function check_email(strEmail) {
    var emailReg = /^([a-zA-Z0-9\-]+[_|\_|\.]?)*[a-zA-Z0-9\-]+@([a-zA-Z0-9\-]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
    if (emailReg.test(strEmail))
        return true;
    else
        return false;
}
/**
 * @desc 手机号码验证
 */
function isjsMobile(obj){
    var reg= /^[1][3456789]\d{9}$/;   
    if (obj.length != 11) return false;
    else if (!reg.test(obj)) return false;
    else if (isNaN(obj)) return false;
    else return true;
}
/**
 * @desc 电话验证
 */
function isjsTell(str) {
    //var result = str.match(/^((0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/);
    var result = str.match(/^[0-9-]+?$/);
    if (result == null) return false;
    return true;
}
function sign(){
    showLoading();
    $.post(wapurl+"index.php?c=ajax&a=sign",{rand:Math.random()},function(res){
        hideLoading();
        if(res.type=="-2"){
            showToast('操作失败', 2);return false;
        }else{ 
            showToast('签到成功+'+res.integral,2,function(){window.location.reload(true)});return false;
        }
    }, 'json');
}
 
function signok(){
    showToast('今日已签到,请明天再来', 2);return false;
}
 
function navigateTo(url){
    window.location.href = url;
}
function checkCode(id){
    if(document.getElementById(id)){
        document.getElementById(id).src=wapurl+"/authcode.inc.php?"+Math.random();
    }
}
 
function goBack(){
    if (navigator.userAgent.indexOf('Firefox') >= 0 ||
        navigator.userAgent.indexOf('Opera') >= 0 ||
        navigator.userAgent.indexOf('Safari') >= 0 ||
        navigator.userAgent.indexOf('Chrome') >= 0 ||
        navigator.userAgent.indexOf('WebKit') >= 0){
 
        if(window.history.length > 1){
            window.history.go( -1 );
        }else{
            location.href = wapurl;
        }
    }else{ //未知的浏览器
        window.history.go( -1 );
    }
}
/**
 * @desc 
 * @param imgObj
 * @param imgSrc
 * @param maxErrorNum
 * @returns
 */
function showImgDelay(imgObj,imgSrc,maxErrorNum){  
    if(maxErrorNum>0){
        imgObj.onerror=function(){
            
            showImgDelay(imgObj,imgSrc,maxErrorNum-1);
        };
        
        setTimeout(function(){
            imgObj.src    =    imgSrc;
        },500);
        
        maxErrorNum    =    parseInt(maxErrorNum) - parseInt(1);
    }
}
// 请先登录
function pleaselogin(msg,url){
    showConfirm(msg, function(){
        window.location.href = url;
    },'取消', '登录');
}
// 统一删除函数
function vant_del(msg = '', url){
    showConfirm(msg, function(){
        showLoading();
        $.get(url, function(res){
            if(!res.url){
                // 不需要跳转,返回上一页
                showToast(res.msg, 2, function(){
                    window.history.go(-1);
                });
            }else {
                if(res.url == '1'){
                    // 页面刷新
                    showToast(res.msg, 2, function(){
                        window.location.reload();
                    });
                }else{
                    // 跳转到需要的地址
                    showToast(res.msg, 2, function(){
                        window.location.href = res.url;
                    });
                }
            }
        },'json');
    });
}
//退出
function islogout(url,msg) {    
    
    showConfirm('确认退出吗?',function(){
        window.localStorage.setItem("socketState", "2");
        window.location.href = url;
    });
}
$(document).ready(function () {
    $(".repeat_list").click(function(){
        
        if($(this).attr("eid")){
            var eid = $(this).attr("eid");
            $("#eid").val($(this).attr("eid"));
        }
        if($(this).attr("uid")){
            var uid = $(this).attr("uid");
            $("#uid").val($(this).attr("uid"));
        }
        if($(this).attr("r_name")){
            var r_name = $(this).attr("r_name");
            $("#r_name").val($(this).attr("r_name"));
        }
        $.post(wapurl+"/index.php?c=resume&a=report",{eid:eid,ruid:uid},function(data){
            if(data==3){
                showToast('查看联系方式之后才可以举报', 2);return false;  
            }else if(data==1){
                showToast('您已经举报过简历!', 2);return false;  
            }else if(data==2){
                showConfirm('你确定举报这份简历?',function(){
                    location.href = "index.php?c=reportlist&uid="+uid+"&eid="+eid+"&r_name="+r_name;
                })
                
            }
        });
    });
})
var jl_flag;
// 节流函数:在一定时间内,只能触发一次
function throttle(func, wait = 1000){
    if (!jl_flag) {
        jl_flag = true;
        // 如果是立即执行,则在wait毫秒内开始时执行
        typeof func === 'function' && func();
        timer = setTimeout(() => {
            jl_flag = false;
        }, wait);
    }
 
}
 
function footernav(type){
    var display =$("."+type).css('display');
    $("#footerjob").hide(); 
    if(display=='none'){ 
        $("."+type).show();
    }else{
        $("."+type).hide();
    }
}
 
// 问答关注功能
function attention(id,type,url){
    showLoading()
    $.post(url,{id:id,type:type},function(data){
        hideLoading();
        var data=eval('('+data+')');  
        if(type==1){var msg='关注';}else{var msg='+  关注';} 
        if(data.st==8){
            showToast(data.msg, 2);return false;    
        }else{        
            $(".num"+id).html(data.url+"人关注");
            $(".index_num"+id).html(data.url);
            
            if(data.tm==1){                
                $(".q"+id+">a").attr("class","watch_qxgz");
                $(".q"+id+">a").html("取消关注");
                showToast("关注成功!", 2,function(){location.reload(true);});return false; 
            }else{
                $(".q"+id+">a").attr("class","watch_gz");
                $(".q"+id+">a").html(msg);
                showToast("取消成功!", 2,function(){location.reload(true);});return false; 
            }                
        } 
    });
}
 
// 向左滚动
function marquee_l(time,id){
    $(function(){
        var _wrap=$(id);
        var _interval=time;
        var _moving;
        _wrap.hover(function(){
            clearInterval(_moving);
        },function(){
            _moving=setInterval(function(){
            var _field=_wrap.find('li:first');
            var _h=_field.height();
            _field.animate({marginLeft:-_h+'px'},800,function(){
            _field.css('marginLeft',10).appendTo(_wrap);
            })
        },_interval)
        }).trigger('mouseleave');
    });
}
// 向上滚动
function marquee(time,id){
    $(function(){
        var _wrap=$(id);
        var _interval=time;
        var _moving;
        _wrap.hover(function(){
            clearInterval(_moving);
        },function(){
            _moving=setInterval(function(){
            var _field=_wrap.find('li:first');
            var _h=_field.height();
            _field.animate({marginTop:-_h+'px'},800,function(){
            _field.css('marginTop',0).appendTo(_wrap);
            })
        },_interval)
        }).trigger('mouseleave');
    });
}
 
 
function savepwd(){
    var password=$("#password").val();
    var passwordnew=$.trim($("#passwordnew").val());
    var passwordconfirm=$.trim($("#passwordconfirm").val());
    if(password<6){
        showToast('原密码不正确!',2);return false;
    }
    if(passwordnew.length<6){
        showToast('新密码长度必须大于等于6!',2);return false;
    }
    if(password == passwordnew){
        showToast('请输入新密码不同于原密码!', 2);return false;
    }
    if(passwordnew != passwordconfirm || passwordconfirm.length<6){
        showToast('两次输入密码不一致!', 2);return false;
    }
    showLoading()
    $.post(wapurl+"?c=ajax&a=setpwd",{password:password,passwordnew:passwordnew,passwordconfirm:passwordconfirm},function(data){
        hideLoading(); 
        var data=eval("("+data+")");
        if(data.type==9){
            window.localStorage.setItem("socketState", "2");
            showToast(data.msg,2,function(){
                window.location.href=wapurl+"index.php?c=login";
            });
        }else{
            showToast(data.msg,2);return false;
        }
    });
}
/****
* name:localStorage的key
* data:localStorage的Value
* expire:localStorage的过期时间,默认是1天后过期
****/
//设置缓存
function localStorageSet(name, data, expire = 24){
    expire = new Date().getTime() + expire * 60 * 60 * 1000;
    var obj = {
            data,
            expire
        };
    window.localStorage.setItem(name, JSON.stringify(obj));
}
//读取缓存
function localStorageGet(name){
    var storage = window.localStorage.getItem(name);
    var result = null;
    if (storage) {
        var obj = JSON.parse(storage);
        var time = new Date().getTime();
        if (time < obj.expire) {
            result = obj.data;
        } else {
             window.localStorage.removeItem(name);
        }
    }
    return result;
}
// 判断arr是否为一个数组,返回一个bool值
function isArray (arr) {
    return Object.prototype.toString.call(arr) === '[object Array]';
}
// 深度克隆
function deepClone (obj) {
    // 对常见的“非”值,直接返回原来值
    if([null, undefined, NaN, false].includes(obj)) return obj;
    if(typeof obj !== "object" && typeof obj !== 'function') {
        //原始类型直接返回
        return obj;
    }
    var o = isArray(obj) ? [] : {};
    for(let i in obj) {
        if(obj.hasOwnProperty(i)){
            o[i] = typeof obj[i] === "object" ? deepClone(obj[i]) : obj[i];
        }
    }
    return o;
}
 
var timeout = null;
/**
 * 防抖原理:一定时间内,只有最后一次操作,再过wait毫秒后才执行函数
 *
 * @param {Function} func 要执行的回调函数
 * @param {Number} wait 延时的时间
 * @return null
 */
function debounce(func, wait = 500) {
    // 清除定时器
    if (timeout !== null) clearTimeout(timeout);
    timeout = setTimeout(function() {
        typeof func === 'function' && func();
    }, wait);
}
 
 
function atn(id,url){// 关注企业
    if(id){
        showLoading()
        $.post(url,{id:id},function(data){
            hideLoading(); 
            var data=eval('('+data+')');
            if(data.errcode==1){
                showToast(data.msg,2,function(){window.location.reload(true);});return false; 
              
            }else{
                showToast(data.msg);return false;
            }
        });
    }
}
 
function checkshowjob(type, id, operation_type) {  
    window.show_scrolltop = document.body.scrollTop;
    document.body.scrollTop = 0;
    
    if(type=='once'||type=='tiny'){
        if(type == 'once'){
            $('#once_password').val('');
            yunvue.$data.onceid = id;
        }else if (type=='tiny'){
            $('#tiny_password').val('');
            yunvue.$data.tinyid = id;
        }
        $('#checkcode').val('');
        checkCode('vcode_img');
        yunvue.$data.operation_type = operation_type;
        yunvue.$data.jobBox = true;
 
    }else{
        $("#"+type+"list").show();
        checkhide('info'); 
    }
}
 
function checkOncePassword(id,img){
    if($("#once_password").val()==''){
        showToast('请输入密码');
        return;
    }
 
    var operation_type=$("#operation_type").val();
    var checkcode = $("#checkcode").val();
    showLoading();
    $.post(wapurl + "/index.php?c=once&a=ajax", { id: id, password: $("#once_password").val(), operation_type: operation_type ,checkcode:checkcode }, function (data) {
        hideLoading(); 
        var data = eval('(' + data + ')');
        if(data.type == 1 || data.type == 2|| data.type ==5) {
            showToast(data.msg);
            checkCode(img);
            return false;
        }  else if(data.type == 3) {
            showToast(data.msg, 2, function() {
                window.location.reload();
            });
        } else if(data.type == 4) {
            showToast(data.msg, 2, function() {
                location.href = wapurl + 'index.php?c=once';
            });
        } else {
            location.href =data.url;
        }
    });
}
 
function checkCode(id){
    if(document.getElementById(id)){
        document.getElementById(id).src=wapurl+"/authcode.inc.php?"+Math.random();
    }
}
 
function checkTinyPassword(id, img){
    if($("#tiny_password").val()==''){
        showToast('请输入密码');
        return;
    }
    var operation_type = $("#operation_type").val();
    var checkcode = $("#checkcode").val();
    showLoading();
    $.post(wapurl + "/index.php?c=tiny&a=ajax", { id: id, password: $("#tiny_password").val(), operation_type: operation_type ,checkcode:checkcode}, function (data) {
        hideLoading(); 
        var data = eval('(' + data + ')');
        if(data.type == 1 || data.type == 2) {
            showToast(data.msg);
            checkCode(img);
            return false;
        }  else if(data.type == 3) {
            showToast(data.msg, 2, function() {
                window.location.reload();
            });
        } else if(data.type == 4) {
            showToast(data.msg, 2, function() {
                location.href = wapurl + 'index.php?c=tiny';
            });
        } else {
            location.href =data.url;
        }
    });
}
function form2json(target_form) {
    var json_form = '';
    $(target_form).find('input,select,textarea').each(function () {
        if($(this).attr('type')=='radio'){
            if ($(this).attr('name')&&$(this).attr('checked')=='checked') {
                json_form += ',' + $(this).attr('name') + ':"' + $(this).val().replace(/[\r\n]+/g, '\\n')+'"';
            }
        }else{
            if ($(this).attr('name')) {
                json_form += ',' + $(this).attr('name') + ':"' + $(this).val().replace(/[\r\n]+/g, '\\n')+'"';
            }
        }
    });
    return eval('({' + json_form.substring(1) + '})');
}
function formfile2json(target_form) {
    var json_form = '';
    var formData = new FormData(target_form);
    $(target_form).find('input,select').each(function () {
        if ($(this).attr('name')) {
            if ($(this)[0].type == 'file') {
                formData.append('file', $('input[type=file]', target_form).get(0).files[0]);
            } else {
                formData.append($(this).attr('name'), $(this).val());
            }
        }
    });
   
    return formData;
}
 
function form2string(target_form) {
    var json_form = '';
    $(target_form).find('input,select').each(function () {
        if ($(this).attr('name')) {
            json_form += '&' + $(this).attr('name') + '=' + $(this).val();
        }
    });
    return json_form;
}
function post2ajax(target_form) {
    showLoading();
    if ($('input[type=file]', target_form).length > 0) {
        $.ajax({
            url: $(target_form).attr('action'),
            data: formfile2json(target_form),
            processData: false,
            type: 'POST',
            async: false,  
            cache: false,
            contentType: false,
            success: function (data) {
                hideLoading();
                var json_data = eval('(' + data + ')');
                if (json_data.msg) {
                    
                    if($("#bind-captcha").length>0){
                        $("#popup-submit").trigger("click");
                    }
                    if (json_data.st==10) {
                        checkCode('vcode_img'); 
                    }
                    showToast(json_data.msg, json_data.tm, function () { if (json_data.url) { location.href = json_data.url; } });
                    return false; 
                } else if (json_data.url) {
                    location.href = json_data.url;
                    return false; 
                }
            }
        });
    } else {
        if ($(target_form).attr('action') == 'get') {
            $.get($(target_form).attr('action') + form2string(target_form), function (data) {
                hideLoading();
                var json_data = eval('(' + data + ')');
                if (json_data.msg) {
                    if($("#bind-captcha").length>0){
                        $("#popup-submit").trigger("click");
                    }
                    showToast(json_data.msg, json_data.tm, function () { if (json_data.url) { location.href = json_data.url; } });
                    return false; 
                } else if (json_data.url) {
                    location.href = json_data.url;
                    return false; 
                }
            });
        } else {
            $.post($(target_form).attr('action'), form2json(target_form), function (data) {
                hideLoading();
                var json_data = eval('(' + data + ')');
                if (json_data.msg) {
                    if($("#bind-captcha").length>0){
                        $("#popup-submit").trigger("click");
                    }
                    if(json_data.msg.indexOf('script')>0){
                        $('#uclogin').html(json_data.msg);
                        json_data.msg = '登录成功';
                    }
                    showToast(json_data.msg, json_data.tm, function () {
                        if (json_data.url) {
                            location.href = json_data.url; 
                        }  
                    });
                    if (json_data.st==8) {
                        checkCode('vcode_img'); 
                    }
                    return false; 
                } else if (json_data.url) {
                    // 处理缓存,返回登陆页面后刷新
                    window.sessionStorage.setItem("needRefresh", true);
                    location.href = json_data.url;
                    return false; 
                }
            });
        }
    }
    return false;
 
function exitsid(id) {
    if(document.getElementById(id)) {
        return true;
    } else {
        return false;
    }
}
 
function get_comment(aid,show,url){ 
    $(".pl_menu").hide();
    var style=$(".review"+aid).css("display");
    var info=$(".review"+aid+" ul").html();
    if(style=="none"||show>0){ 
        if((info==''||info==null)||show>0){
            showLoading();
            $.post(url,{aid:aid},function(data){
                hideLoading(); 
                var html='';  
                var datas = Array();
                data = data.replace(/\s+/g,"[[space]]");// eval的字符串中有空格会出错
                datas = eval("("+data+")");
                $.each(datas,function(key,val){
                    html+="<li>"+
                            "<div class=\"menu_p1_tx\"><img src=\""+val.pic.replace(/\[\[space\]\]/g,' ')+"\" onerror=\"showImgDelay(this,'"+val.errorpic.replace(/\[\[space\]\]/g,' ')+"',2);\"/></div>"+
                            "<div class=\"menu_right\">"+
                                "<div class=\"menu_rig_h2\">"+
                                    "<span class=\"menu_user\"><a href=\""+val.url.replace(/\[\[space\]\]/g,' ')+"\">"+val.nickname.replace(/\[\[space\]\]/g,' ')+"</a>:</span>"+
                                    "<span class=\"menu_mes\">"+val.content.replace(/\[\[space\]\]/g,' ')+"</span>"+
                                "</div>"+ 
                                "<div class=\"menu_date\">"+
                                    "<span>"+val.date.replace(/\[\[space\]\]/g,' ')+"</span>"+
                                "</div>"+
                            "</div>"+ 
                        "</div>"+
                        "<div class=\"clear\"></div>"+
                    "</li>"; 
                    $(".review"+aid+" ul").html(html); 
                });     
            });
        }
        $(".review"+aid).show();
    }else{
        $(".review"+aid).hide();
    } 
 
function for_comment(aid,qid,url,comurl){
    var content=$.trim($("#comment_"+aid).val()); 
    if(content=="" || content=="undefined"){
        showToast('评论内容不能为空!');return false; 
    }else{
        showLoading();
        $.post(url,{aid:aid,qid:qid,content:content},function(msg){
            hideLoading(); 
            if(msg=='1'){
                $("#comment_"+aid).val("");
                var com_num=$("#com_num_"+aid).html();  
                com_num=parseInt(com_num)+parseInt(1);
                $("#com_num_"+aid).html(com_num); 
                get_comment(aid,'1',comurl);
            }else if(msg=='0'){
                showToast('评论失败!');return false; 
            }else if(msg=='no_login'){ 
                showToast('请先登录!');return false; 
            }else{
                showToast(msg);return false; 
            }
        });
    }
 
function yunfootClose(){
    footerVue.$data.yunfoot = !footerVue.$data.yunfoot;
}
 
function isChinaName(name) {
    var pattern = /^[\u4E00-\u9FA5]{2,6}$/;
    return pattern.test(name);
}