PageSourceSearch

https://www.chinaventure.com.cn/js/common.js

js chinaventure.com.cn collected 2026-10-02 04:19:20 UTC 46,832 bytes, 1,154 lines download raw bytes

1//判断设备尺寸并重定向
2var screenReset = function(vm){
3    console.log('activeUrl:',vm.activeUrl)
4    if ((vm.activeUrl == 'index' || vm.activeUrl == 'institute' || vm.activeUrl == 'articledetail' || vm.activeUrl == 'reportdetail' || vm.activeUrl == 'special' || vm.activeUrl == 'search' || vm.activeUrl == 'meetingspecial' || vm.activeUrl == 'meetinglive' || vm.activeUrl == 'subjectlist' || vm.activeUrl == 'meetinglist' || vm.activeUrl == 'guestinfo' || vm.activeUrl == 'community_introduce' || vm.activeUrl == 'everest_program' || vm.activeUrl =='community_guest') && (window.location.href.indexOf('new.chinaventure') == -1) && (window.location.href.indexOf('8082') == -1)) {
5        //域名不同
6        if (CVWEBDOMAIN == 'chinaventure') {
7            if (OSENV == 'mobile') {
8                if (HREFENV !== 'mobile') {
9                    if (ROOTPATH.indexOf('www.chinaventure') !== -1) {
10                        window.location.href = window.location.href.replace('www.chinaventure','m.chinaventure')
11                    } else {
12                        window.location.href = window.location.href.replace('chinaventure','m.chinaventure')
13                    }
14                }
15            } else {
16                if (HREFENV !== 'pc') {
17                    window.location.href = window.location.href.replace('m.chinaventure','www.chinaventure')
18                }
19            }
20        } else if (CVWEBDOMAIN == 'cvmedia') {
21            if (OSENV == 'mobile') {
22                if (HREFENV !== 'mobile') {
23                    if (ROOTPATH.indexOf('www.cvmedia') !== -1) {
24                        window.location.href = window.location.href.replace('www.cvmedia','m.cvmedia')
25                    } else {
26                        window.location.href = window.location.href.replace('cvmedia','m.cvmedia')
27                    }
28                }
29            } else {
30                if (HREFENV !== 'pc') {
31                    window.location.href = window.location.href.replace('m.cvmedia','www.cvmedia')
32                }
33            }
34        }
35        
36    }
37
38}
39
40
41/* 动态匹配页尾ICP备案信息 */
42$(document).ready(function(){
43    //通用右侧工具栏下载二维码
44    if ($('#downloadCodepic')) {
45        if (CVWEBDOMAIN == 'cvmedia') {
46            $('#downloadCodepic').attr('src','/images/cvmedia_downloadcode.png')
47        } else {
48            $('#downloadCodepic').attr('src','/images/chinaventure_downloadcode.png')
49        }
50    }
51})
52
53
54
55/* 请求基本数据 */
56var reqUserBaseData = {
57    serviceId: '002',
58    serviceType: '0',
59    serviceVersion: '1.0.0',
60    user: {
61        userId: getCookie('userId') || ''
62    },
63    device:{
64        useragent: navigator.userAgent.toString(),
65        os: GetOSInfo().toString()
66    }
67}
68
69/* 
70    通用请求
71    type:类型 'POST','GET'
72    baseUrl: 基础请求地址
73    url: 业务地址
74    dataType:数据类型
75    contentType :请求头类型
76    data : 请求参数主体,
77    fn:回调
78*/
79var commonRequest = function (type,baseUrl,url,dataType,contentType,data,fn) {
80    if (type == 'GET') {
81        var reqdata = data
82    } else if (type == 'POST') {
83        var reqdata = JSON.stringify(Object.assign({data}, reqUserBaseData))  
84    } 
85    console.log('common:','type:',type,'baseURL',baseUrl,'url',url,'datatype',dataType,'contentType',contentType,'reqdata',reqdata,'callback:',fn)
86
87    $.ajax({
88        type: type,
89        url: baseUrl + url,
90        data: reqdata,
91        dataType: dataType,
92        timeout : 30000,
93        beforeSend: function(request) {
94            request.setRequestHeader("cv_sso_token", getCookie('token'));
95            request.setRequestHeader("cv_sso_user_id", getCookie('userId'));
96            request.setRequestHeader("Content-Type", contentType);
97        },
98        success:function(res){
99            console.log('common接口返回:',res)
100            if (res.code == 200) {
101                fn(res)
102            } else {
103                mapStatus(res)
104            }
105        },
106        complete:function(XMLHttpRequest,status){
107            if(status == 'timeout') {
108                XMLHttpRequest.abort();
109                var messageAlert_timeout = new messageAlert({
110                    isPc: true,
111                    bgMask: {
112                        bgColor:'rgba(0,0,0,0.2)',
113                        isClose: true
114                    },
115                    title:'温馨提示',
116                    showCloseBtn:true,
117                    innerText:'网络请求超时,请刷新后重试',
118                    buttonGroup:[{
119                        buttonText:'我知道了',
120                        clickFn: function() {
121                            location.reload();
122                        }
123                    }]
124                }) 
125            }
126        },
127        error:function(res){
128            //mapStatus(res)
129        }
130        
131    })
132
133
134}
135
136//报错检查流转流转
137var mapStatus = function(res) {
138    //全局单例请求控制器
139    vm.ajaxCommonController = true
140    //接触投稿锁定请求
141    if (vm.activeUrl == 'contribute') {
142        vm.submitLock = true
143        vm.articleForm = {
144            draftTitle:'',//稿子标题
145            draftContent:'',//稿子内容
146            draftImg:'',//稿子内容图片
147            draftSourceName:'',//稿子来源
148            draftOriginal:1,//是否原创 0否 1是
149            draftPhone:'',//联系方式
150            draftAuthor:'',//稿子作者
151            draftUserId: getCookie('userId'),//稿子创建人编号
152        },
153        vm.headPicFile = ''
154        vm.headpictureShow = ''
155        vm.contentPicFileList = []
156        vm.contentPicShow = []
157        vm.limit = 5
158    }
159    switch(res.code){
160        case 500:
161            console.log(res.msg)
162            break;
163        case 7001:
164            openLoginZone(0)
165            logoutBack(res)
166            break;
167        case 87127: //用户已经投过票
168            if (vm.activeUrl == 'meetingdetail') {
169                vm.getUserVoteResult()
170            }
171        case 889988: // 登峰计划已报名
172            vm.isLogin = true;
173            vm.isSubmit = true;
174            break;
175        default:
176            var messageAlert_false = new messageAlert({
177                isPc: true,
178                bgMask: {
179                    bgColor:'rgba(0,0,0,0.2)',
180                    isClose: true
181                },
182                title:'温馨提示',
183                showCloseBtn:true,
184                innerText: res.msg,
185                buttonGroup:[{
186                    buttonText:'我知道了',
187                    clickFn: function() {
188                    }
189                }]
190            })    
191    }
192}
193
194
195
196/* 
197    全局搜索相关
198*/
199var overallSearchInfo = {
200    searchStr:'',
201    search_tips:[],
202    needToSearch: false,
203    timeDelay:'',
204}
205
206var openSearchZone = function () {
207    $('.search_content_pc').fadeIn();
208    setTimeout(function(){ document.getElementById('overallSearchInput').focus() }, 100);
209}
210//@input
211// var searchSuggestList = function(vm) {
212//     console.log('正在查询的字符串:',vm.searchStr)
213//     if (vm.searchStr) {
214//         commonRequest('POST', BASEURL.ES.ESREQBASEURL1, '/completion/all','json','application/json',{
215//             keyword: vm.searchStr,
216//             pageNum:1,
217//             pageSize:10,
218//             isHighlight: true,
219//             preTags:'<span style="color:#1A65C9">',
220//             postTags:'</span>'
221//         },renderCompletionList)
222//     }
223// }
224// var renderCompletionList = function (res) {
225//     if (res.data.list.length !== 0) {
226//         vm.search_tips = res.data.list
227//     }
228// } 
229var ensureStr = function(vm,str) {
230    vm.needToSearch = false
231    vm.search_tips = []
232    vm.searchStr = str
233    $('#overallSearchInput').focus();
234}
235//@blur
236// var searchBlur = function(vm) {
237//     vm.needToSearch = false
238//     setTimeout(function(){
239//         vm.search_tips = []
240//     },200)
241// }
242var cancelSearch = function () {
243    $('.search_content_pc').hide();
244    $('#overallSearchInput').val('');
245    overallSearchInfo.searchStr = ''
246}
247// var openSearch = function (vm) {
248//     vm.needToSearch = true
249// }
250var toSearchResultPage = function () {
251    overallSearchInfo.searchStr = $('#overallSearchInput').val();
252    if (overallSearchInfo.searchStr.trim() !== '') {
253        window.location.href = '/search.html' + '?searchword='+ encodeURI(overallSearchInfo.searchStr)
254    } else {
255        $('#overallSearchInput').blur();
256        var messageAlert_logout = new messageAlert({
257            isPc: true,
258            bgMask: {
259                bgColor:'rgba(0,0,0,0.2)',
260                isClose: true
261            },
262            title:'温馨提示',
263            showCloseBtn:true,
264            innerText:'搜索内容不能为空',
265            buttonGroup:[{
266                buttonText:'我知道了',
267                clickFn: function() {}
268            }]
269        }) 
270    }
271    
272}
273
274
275
276/* 
277    SSO登录注册相关流转 
278*/
279var userLoginInfo = {
280    showLoginZone: 'none',
281    isLogin:false,
282    loginZoneType: 0, //0:快捷登录 1账号密码  2新用户注册
283    phoneNumber: '',
284    messageCode: '',
285    userAccount:'',
286    userPassword:'',
287    sendTimer:'',
288    btnText:'发送验证码',
289    ableToSend:true,
290    timeCutdown: 60,
291}
292
293//切换登录状态--复原状态
294var tabLoginType = function(type){
295    resetLoginData()
296    userLoginInfo.loginZoneType = type
297    console.log(userLoginInfo.loginZoneType)
298    $('.login_tablist li').removeClass('active').eq(type).addClass('active');
299    if (userLoginInfo.loginZoneType == 0) {
300        $('.login_box_pc .login_text span').removeClass('active').eq(0).addClass('active');
301        $('#fastlogin_phone').css('display','flex');
302        $('#fastlogin_phonetips').show();
303        $('#fastlogin_code').css('display','flex');
304        $('#fastlogin_codetips').show();
305        $('#commonlogin_account').css('display','none');
306        $('#commonlogin_accounttips').hide();
307        $('#commonlogin_password').css('display','none');
308        $('#commonlogin_passwordtips').hide();
309        $('#loginButton').show();
310        $('#registerButton').hide();
311    } else if (userLoginInfo.loginZoneType == 1) {
312        $('.login_box_pc .login_text span').removeClass('active');
313        $('#fastlogin_phone').css('display','none');
314        $('#fastlogin_phonetips').hide();
315        $('#fastlogin_code').css('display','none');
316        $('#fastlogin_codetips').hide();
317        $('#commonlogin_account').css('display','flex');
318        $('#commonlogin_accounttips').show();
319        $('#commonlogin_password').css('display','flex');
320        $('#commonlogin_passwordtips').show();
321        $('#loginButton').show();
322        $('#registerButton').hide();
323    } else if (userLoginInfo.loginZoneType == 2) {
324        $('.login_box_pc .login_text span').removeClass('active').eq(1).addClass('active');
325        $('.login_box_pc .login_text span').removeClass('active').eq(0).addClass('active');
326        $('#fastlogin_phone').css('display','flex');
327        $('#fastlogin_phonetips').show();
328        $('#fastlogin_code').css('display','flex');
329        $('#fastlogin_codetips').show();
330        $('#commonlogin_account').css('display','none');
331        $('#commonlogin_accounttips').hide();
332        $('#commonlogin_password').css('display','none');
333        $('#commonlogin_passwordtips').hide();
334        $('#loginButton').hide();
335        $('#registerButton').show();
336        
337    }
338    
339}
340//打开关闭登陆框type=====>loginZoneType: 0, //0:快捷登录 1账号密码  2新用户注册
341var openLoginZone = function (type) {
342    tabLoginType(type)
343    if(userLoginInfo.showLoginZone == 'block') {
344        userLoginInfo.showLoginZone = 'none'
345        $('.login_warpper_pc').hide();
346        resetLoginData()
347    } else if (userLoginInfo.showLoginZone == 'none') {
348        userLoginInfo.showLoginZone = 'block'
349        $('.login_warpper_pc').show();
350    }
351
352}
353
354//重置登录状态--倒计时不清空
355var resetLoginData = function () {
356    userLoginInfo.showLoginZone = 'none'
357    userLoginInfo.phoneNumber = ''
358    userLoginInfo.messageCode = ''
359    userLoginInfo.userAccount = ''
360    userLoginInfo.userPassword = ''
361    $('#fastlogin_phone input').val('')
362    $('#fastlogin_code input').val('')
363    $('#commonlogin_account input').val('')
364    $('#commonlogin_password input').val('')
365    $('#fastlogin_phonetips').text('');
366    $('#fastlogin_codetips').text('');
367    $('#commonlogin_accounttips').text('');
368    $('#commonlogin_passwordtips').text('');
369}
370
371//关闭登录框
372var closeLoginWrapper = function () {
373    resetLoginData()
374    $('.login_warpper_pc').hide();
375}
376
377
378//行为验证后发送短信
379var sendMessageCode = function () {
380    if (userLoginInfo.ableToSend === true && userLoginInfo.timeCutdown === 60) {
381        //获取值
382        userLoginInfo.phoneNumber = $('#fastlogin_phone input').val()
383        if (userLoginInfo.phoneNumber == '') {
384            $('#fastlogin_phonetips').text('手机号不能为空');
385            return false; 
386        }
386 else if (!(REGPhone.test(userLoginInfo.phoneNumber))) {
387            $('#fastlogin_phonetips').text('手机号格式有误,请确认');
388            return false; 
389        } else {
390            $('#fastlogin_phonetips').text('');
391            var captchaCommon = new TencentCaptcha('2027481577', function(res) {
392                console.log('防水墙返回',res)
393                if (res.ret == 0) {
394                    userLoginInfo.ableToSend = false
395                    $('.commonlogin_sendcode_hook').addClass('disable');
396                    //请求SSO接口   reqFromCode 0-官网,1-ios,2-android,3-邀请
397                    commonRequest('GET',BASEURL.SSO.SSOBASEURL1,'/user/phone/send','json','application/x-www-form-urlencoded','phone=' + userLoginInfo.phoneNumber +'&reqFromCode=0'+'&ticket=' + res.ticket +'&rand=' + res.randstr, sendCodeOk)
398                    userLoginInfo.sendTimer = setInterval(function () {
399                        if (userLoginInfo.timeCutdown <= 60 && userLoginInfo.timeCutdown > 0) {
400                            userLoginInfo.timeCutdown--
401                            $('.commonlogin_sendcode_hook').text(userLoginInfo.timeCutdown + '秒后重新发送')
402                        } else {
403                            clearInterval(userLoginInfo.sendTimer)
404                            userLoginInfo.timeCutdown = 60
405                            userLoginInfo.sendTimer = ''
406                            $('.commonlogin_sendcode_hook').removeClass('disable').text('发送验证码');
407                            userLoginInfo.ableToSend = true
408                            console.log(userLoginInfo.timeCutdown)
409                        }
410                    }, 1000)
411                }
412            });
413            captchaCommon.show();
414        }
415    }  
416}
417
418
419//腾讯验证回调
420// var tencentTestCallback = function (res) {
421//     console.log(res)
422//     if (vm.ableToSend === true && vm.timeCutdown === 60) {
423//         if (vm.phoneNumber == '') {
424//             vm.phoneNumber_tips = '手机号不能为空'
425//             return false; 
426//         } else if (!(/^1[34578]\d{9}$/.test(vm.phoneNumber))) {
427//             vm.phoneNumber_tips = '手机号格式有误,请确认'
428//             return false; 
429//         } else {
430//             vm.phoneNumber_tips = ''
431//             vm.ableToSend = false
432//             //请求SSO接口   reqFromCode 0-官网,1-ios,2-android,3-邀请
433//             commonRequest('GET',BASEURL.SSO.SSOBASEURL1,'/user/phone/send','json','application/x-www-form-urlencoded','phone=' + vm.phoneNumber +'&reqFromCode=0', sendCodeOk)
434//             vm.sendTimer = setInterval(function () {
435//                 if (vm.timeCutdown <= 60 && vm.timeCutdown > 0) {
436//                     vm.timeCutdown--
437//                     vm.btnText = vm.timeCutdown + '秒后重新发送'
438//                 }
439//             }, 1000)
440//         }
441//     }  
442//     if (res.ret === 0) {
443//         commonRequest('GET',BASEURL.SSO.SSOBASEURL1,'/user/phone/send','json','application/x-www-form-urlencoded','phone=' + vm.phoneNumber +'&reqFromCode=0'+'&ticket=' + res.ticket +'&rand=' + res.randstr, sendCodeOk)
444//     }
445// }
446
447
448//发送登录验证码成功
449var sendCodeOk = function (res) {
450    if (res.code !== 200 ) {
451        //调用弹出框
452        var messageAlert_codefail = new messageAlert({
453            isPc: true,
454            bgMask: {
455                bgColor:'rgba(0,0,0,0.2)',
456                isClose: true
457            },
458            title:'温馨提示',
459            showCloseBtn:true,
460            innerText:'验证码发送失败,请稍后再试',
461            buttonGroup:[{
462                buttonText:'我知道了',
463                clickFn: function() {}
464            }]
465        }) 
466    }
467}
468
469//校验登录注册提交文本
470var doWriteInTest = function () {
471    //获取值
472    userLoginInfo.phoneNumber = $('#fastlogin_phone input').val()
473    userLoginInfo.messageCode = $('#fastlogin_code input').val()
474    userLoginInfo.userAccount = $('#commonlogin_account input').val()
475    userLoginInfo.userPassword = $('#commonlogin_password input').val()
476    //loginZoneType 0:快捷登录 1账号密码  2新用户注册
477    if (userLoginInfo.loginZoneType == 0 || userLoginInfo.loginZoneType == 2) {
478        if (userLoginInfo.phoneNumber == '') {
479            $('#fastlogin_phonetips').text('手机号不能为空');
480            return false; 
481        }
481 else if (!(REGPhone.test(userLoginInfo.phoneNumber))) {
482            $('#fastlogin_phonetips').text('手机号格式有误,请确认');
483            return false; 
484        } else {
485            $('#fastlogin_phonetips').text('');
486        }
487        if (userLoginInfo.messageCode == '') {
488            $('#fastlogin_codetips').text('验证码不能为空');
489            return false; 
490        } else if (!(REGTestCode.test(userLoginInfo.messageCode))) {
491            $('#fastlogin_codetips').text('验证码为6位数字');
492            return false;
493        } else {
494            $('#fastlogin_codetips').text('');
495        }
496    
497        //手机号+短信登录
498        commonRequest ('GET',BASEURL.SSO.SSOBASEURL1,'/user/phone/code','json','application/x-www-form-urlencoded','phone=' + userLoginInfo.phoneNumber +'&code=' + userLoginInfo.messageCode, loginBack)
499
500    } else if (userLoginInfo.loginZoneType == 1) {
501        var accountType = ''
502        $('#commonlogin_accounttips').text('');
503        $('#commonlogin_passwordtips').text('');
504        if (userLoginInfo.userAccount == '') {
505            $('#commonlogin_accounttips').text('账号不能为空');
506            return false; 
507        } else if ((REGPhone.test(userLoginInfo.userAccount))) {
508            accountType = 'phone'
509            $('#commonlogin_accounttips').text('');
510        } else if ((REGEmail.test(userLoginInfo.userAccount))) {
511            accountType = 'email'
512            $('#commonlogin_accounttips').text('');
513        } else {
514            $('#commonlogin_accounttips').text('账号格式不正确');
515            return false;
516        }
517        if (userLoginInfo.userPassword == '') {
518            $('#commonlogin_passwordtips').text('密码不能为空');
519            return false;
520        } else if (userLoginInfo.userPassword.length < 6) {
521            $('#commonlogin_passwordtips').text('密码不能小于6位');
522            return false;
523        } else if (!(REGPassword.test(userLoginInfo.userPassword))) {
524            $('#commonlogin_passwordtips').text('密码格式有误,只能是英文字母或数字');
525            return false;
526        }
527        if (accountType == 'phone') {
528            //手机号或邮箱+密码登录
529            commonRequest ('POST',BASEURL.SSO.SSOBASEURL1,'/user/login','json','application/json',{
530                mobile: userLoginInfo.userAccount,
531                password: userLoginInfo.userPassword
532            }, loginBack)
533        } else if (accountType == 'email') {
534            //手机号或邮箱+密码登录
535            commonRequest ('POST',BASEURL.SSO.SSOBASEURL1,'/user/login','json','application/json',{
536                email: userLoginInfo.userAccount,
537                password: userLoginInfo.userPassword
538            }, loginBack)
539        }
540
541    } 
542    
543}
544
545//登录成功保存用户信息
546var loginBack = function (res) {
547    if (res.code == 200) {
548        setCookie ('userId', res.data.userId, 365)
549        setCookie ('mobile', res.data.mobile, 0.5)
550        setCookie ('email', res.data.email, 0.5)
551        setCookie ('nickname', res.data.nickname, 0.5)
552        setCookie ('token', res.data.token, 0.5)
553        setCookie ('mediaId', res.data.mediaId, 0.5)
554        setCookie ('isFlag', res.data.isFlag, 0.5)
555        setCookie ('avatar', res.data.avatar, 0.5)
556        //更新请求基础参数
557        reqUserBaseData.user = {
558            userId: getCookie('userId') || ''
559        }
560        //获取用户登录状态-切换页头显示效果
561        $('.nav_userheadpic img').attr('src',getCookie('avatar'));
562        userLoginInfo.isLogin = true
563        getUserLoginStatus()
564        closeLoginWrapper()
565    }
566}
567
568//退出登录
569var toLogout = function () {
570    //调用弹出框
571    var messageAlert_logout = new messageAlert({
572        isPc: true,
573        bgMask: {
574            bgColor:'rgba(0,0,0,0.2)',
575            isClose: true
576        },
577        title:'温馨提示',
578        showCloseBtn:true,
579        innerText:'亲,确认要退出登录吗?',
580        buttonGroup:[{
581            buttonText:'再想想',
582            clickFn: function() {}
583        },{
584            buttonText:'是的',
585            clickFn: function() {
586                //退出登录
587                commonRequest ('POST',BASEURL.SSO.SSOBASEURL1,'/user/signOut','json','application/json',{
588                    userId: getCookie('userId')
589                }, logoutBack)
590            }
591        }]
592    }) 
593}
594
595//获取用户登录状态
596var getUserLoginStatus = function(){
597    if (getCookie('token') == '' || getCookie('token') == null){
598        console.log('登出状态')
599        userLoginInfo.isLogin = false
600        $('.userlogin_btn_box .userlogin_btn').show();
601        $('.userlogin_btn_box .usercenter_drop').hide();
602        $('.nav_userheadpic img').attr('src','/images/default_userheadpic.png');
603    } else {
604        console.log('登入状态')
605        userLoginInfo.isLogin = true
606        $('.userlogin_btn_box .userlogin_btn').hide();
607        $('.userlogin_btn_box .usercenter_drop').show();
608        $('.nav_userheadpic img').attr('src',getCookie('avatar'));
609    }
610}
611
612//退出登录返回
613var logoutBack = function (res) {
614    console.log('登出res',res) 
615    deletCookie('userId')
616    deletCookie('mobile')
617    deletCookie('email')
618    deletCookie('nickname') 
619    deletCookie('token')
620    deletCookie('mediaId')
621    deletCookie('isFlag')
622    deletCookie ('avatar')
623    $('.nav_userheadpic img').attr('src','/images/default_userheadpic.png');
624    //更新请求基础参数
625    reqUserBaseData.user = {
626        userId: ''
627    }
628    //获取用户登录状态-切换页头显示效果
629    getUserLoginStatus()
630    //如果用户停留在用户中心应当剔除
631    if (vm.activeUrl == 'usercenter') {
632        window.location.href = '/index.html'
633    }
634}
635
636//去找回密码页面
637var toForgetPasswordPage = function () {
638    window.location.href = '/usercenter/forgotpassword.html'
639}
640
641
642
643
644/*  
645    分布式请求新闻列表
646    vm: vue实例  obj
647    newsObjName:新闻列表对象名称 string
648*/
649
650var RedisRequest = function (type,url,dataType,contentType,data,fn,newsObjName) {
651    if (type == 'POST') {
652        var param = data
653    } else {
654        var param = JSON.stringify(data)
655    }
656
657    console.log('Redis:','type:',type,'URL',url,'datatype',dataType,'contentType',contentType,'param',param,'callback:',fn,'newsObjName',newsObjName)
658    $.ajax({
659        type:type,
660        url: BASEURL.REDIS.REDISBASEURL1 + url,
661        data: param,
662        dataType: dataType,
663        timeout : 30000,
664        beforeSend: function(request) {
665            request.setRequestHeader("cv_sso_token", getCookie('token'));
666            request.setRequestHeader("cv_sso_user_id", getCookie('userId'));
667            request.setRequestHeader("Content-Type", contentType);
668        },
669        success:function(res){
670            console.log('Redis返回:',res)
671            if (res.code == 200) {
672                fn(res,newsObjName)
673            } else if (res.code == 7101) {//缓存数据未找到
674                fn(res,newsObjName)
675            } else {
676                mapStatus(res)
677            }
678        },
679        complete:function(XMLHttpRequest,status){
680            if(status == 'timeout') {
681                XMLHttpRequest.abort();
682                var messageAlert_timeout = new messageAlert({
683                    isPc: true,
684                    bgMask: {
685                        bgColor:'rgba(0,0,0,0.2)',
686                        isClose: true
687                    },
688                    title:'温馨提示',
689                    showCloseBtn:true,
690                    innerText:'网络请求超时,请刷新后重试',
691                    buttonGroup:[{
692                        buttonText:'我知道了',
693                        clickFn: function() {
694                            location.reload();
695                        }
696                    }]
697                }) 
698            }
699        },
700        error:function(res){}
701        
702    })
703
704
705}
706
707//加载首页新闻列表---针对所有频道首页公共方法
708var stepAddNewsList = function (vm,newsObjName) {
709    console.log('当前的新闻实例',newsObjName,vm[newsObjName])
710    if (vm[newsObjName].total < vm.stepRequestSettings.limit) { //如果没有超过限定
711        if (vm[newsObjName].storeList.length !== 0) { //当缓冲区列表不为空
712            //截取的数组长度如果小于stepLook,直接隐藏按钮显示没有更多
713            let spliceArr = vm[newsObjName].storeList.splice(0,vm.stepRequestSettings.stepLook)
714            console.log('+=',spliceArr)
715            if (spliceArr.length == vm.stepRequestSettings.stepLook) {
716                vm[newsObjName].showUserList = vm[newsObjName].showUserList.concat(spliceArr)
717                vm[newsObjName].total += vm.stepRequestSettings.stepLook
718            } else {
719                vm[newsObjName].showUserList = vm[newsObjName].showUserList.concat(spliceArr)
720                vm[newsObjName].total += spliceArr.length
721                vm[newsObjName].showLoading = false
722                vm[newsObjName].showNomore = true
723            }
724        } else { //当缓冲区没有新闻时
725            //模拟一下ajax请求
726            vm[newsObjName].showLoading = true
727            //推荐单独走接口
728            if (vm.channel_id == 0) {
729                RedisRequest('POST','/api/getRecommendNewsList','json','application/x-www-form-urlencoded',
730                '&begin_num=' + (parseInt(vm[newsObjName].total) + 1) +
731                '&size=' + vm.stepRequestSettings.stepReq + 
732                '&page=' + 1
733            , RenderPushArticleList, newsObjName)
734            } else {
735                RedisRequest('POST','/api/getNewsListByChannel','json','application/x-www-form-urlencoded',
736                'channel_id=' + vm.channel_id +
737                '&begin_num=' + (parseInt(vm[newsObjName].total) + 1) +
738                '&size=' + vm.stepRequestSettings.stepReq + 
739                '&page=' + 1
740            , RenderArticleList, newsObjName)
741            }
742            
743        }
744    } else {
745        vm[newsObjName].showLoading = false
746        vm[newsObjName].showNomore = true
747    }
748}
749
750//渲染新闻列表--公共方法
751var RenderArticleList = function(res,newsObjName) {
752    console.log('新闻返回结果',newsObjName,res)
753    if (res.code == 200 && res.data.channel_news_list.length !== 0) {
754        vm[newsObjName].storeList = vm[newsObjName].storeList.concat(res.data.channel_news_list.splice(0,vm.stepRequestSettings.stepReq))
755        vm[newsObjName].currentPage += 1
756        //截取的数组长度如果小于stepLook,直接隐藏按钮显示没有更多
757        let spliceArr = vm[newsObjName].storeList.splice(0,vm.stepRequestSettings.stepLook)
758        console.log('+==',spliceArr)
759        if (spliceArr.length == vm.stepRequestSettings.stepLook) {
760            vm[newsObjName].showUserList = vm[newsObjName].showUserList.concat(spliceArr)
761            vm[newsObjName].total += vm.stepRequestSettings.stepLook
762        } else {
763            vm[newsObjName].showUserList = vm[newsObjName].showUserList.concat(spliceArr)
764            vm[newsObjName].total += spliceArr.length
765            vm[newsObjName].showLoading = false
766            vm[newsObjName].showNomore = true
767        }
768        //当实际总数小于设置最大限定时,且不能为-1时
769        if (res.data.list_size !== -1 && res.data.list_size < vm.stepRequestSettings.limit) {
770            vm.stepRequestSettings.limit = res.data.list_size
771        }
772        console.log('total',vm[newsObjName].total,'limit',vm.stepRequestSettings.limit)
773        if (vm[newsObjName].total !== 0 && vm[newsObjName].total < vm.stepRequestSettings.limit) {
774            //加载继续
775            vm[newsObjName].showLoading = false
776        } else if (vm[newsObjName].total == 0) {
777            vm[newsObjName].showLoading = false
778            vm[newsObjName].showNomore = true
779        } else {
780            vm[newsObjName].showLoading = false
781            vm[newsObjName].showNomore = true
782        }
783    } else {//当返回列表为空时,没有更多数据
784        vm[newsObjName].showLoading = false
785        vm[newsObjName].showNomore = true
786    }
787}
788
789//渲染首页推荐新闻列表--公共方法
790var RenderPushArticleList = function (res,newsObjName) {
791    console.log('新闻返回结果',newsObjName,res)
792    if (res.code == 200 && res.data.recommend_news_list.length !== 0) {
793        vm[newsObjName].storeList = vm[newsObjName].storeList.concat(res.data.recommend_news_list.splice(0,vm.stepRequestSettings.stepReq))
794        vm[newsObjName].currentPage += 1
795        //截取的数组长度如果小于stepLook,直接隐藏按钮显示没有更多
796        let spliceArr = vm[newsObjName].storeList.splice(0,vm.stepRequestSettings.stepLook)
797        console.log('+==',spliceArr)
798        if (spliceArr.length == vm.stepRequestSettings.stepLook) {
799            vm[newsObjName].showUserList = vm[newsObjName].showUserList.concat(spliceArr)
800            vm[newsObjName].total += vm.stepRequestSettings.stepLook
801        } else {
802            vm[newsObjName].showUserList = vm[newsObjName].showUserList.concat(spliceArr)
803            vm[newsObjName].total += spliceArr.length
804            vm[newsObjName].showLoading = false
805            vm[newsObjName].showNomore = true
806        }
807        //当实际总数小于设置最大限定时,且不能为-1时
808        if (res.data.list_size !== -1 && res.data.list_size < vm.stepRequestSettings.limit) {
809            vm.stepRequestSettings.limit = res.data.list_size
810        }
811        console.log('total',vm[newsObjName].total,'limit',vm.stepRequestSettings.limit)
812        if (vm[newsObjName].total !== 0 && vm[newsObjName].total < vm.stepRequestSettings.limit) {
813            //加载继续
814            vm[newsObjName].showLoading = false
815        } else if (vm[newsObjName].total == 0) {
816            vm[newsObjName].showLoading = false
817            vm[newsObjName].showNomore = true
818        } else {
819            vm[newsObjName].showLoading = false
820            vm[newsObjName].showNomore = true
821        }
822    } else {//当返回列表为空时,没有更多数据
823        vm[newsObjName].showLoading = false
824        vm[newsObjName].showNomore = true
825    }
826}
827
828
829
830//加载专题内部新闻列表
831var stepAddSpecialNewsList = function (vm,newsObjName,limitIndex) {
832    console.log('当前的新闻实例',newsObjName,vm[newsObjName],limitIndex)
833    if (vm[newsObjName].total < vm.stepRequestSettings.limit[limitIndex]) { //如果没有超过限定
834        console.log('1111',vm[newsObjName].total,vm.stepRequestSettings.limit[limitIndex])
835        if (vm[newsObjName].storeList.length !== 0) { //当缓冲区列表不为空
836            vm[newsObjName].showUserList = vm[newsObjName].showUserList.concat(vm[newsObjName].storeList.splice(0,vm.stepRequestSettings.stepLook))
837            vm[newsObjName].total += vm.stepRequestSettings.stepLook
838        } else { //当缓冲区没有新闻时
839            //模拟一下ajax请求
840            vm[newsObjName].showLoading = true
841            //入参
842            RedisRequest('POST','/api/getNewsListBySubject','json','application/x-www-form-urlencoded',
843                'subject_id=' + vm.subject_id +
844                '&begin_num=' + 21 +
845                '&size=' + vm.stepRequestSettings.stepReq + 
846                '&page=' + (vm[newsObjName].currentPage + 1)
847            , RenderSpecialArticleList, newsObjName)
848        }
849    } else {
850        vm[newsObjName].showLoading = false
851        vm[newsObjName].showNomore = true
852    }
853}
854
855
856//渲染新闻列表--公共方法
857var RenderSpecialArticleList = function(res,newsObjName) {
858    let limitIndex = 0
859    console.log('新闻返回结果',newsObjName,res,limitIndex)
860    if (res.data.subject_news_list.length !== 0) {
861        vm[newsObjName].storeList = vm[newsObjName].storeList.concat(res.data.subject_news_list.splice(0,vm.stepRequestSettings.stepReq))
862        vm[newsObjName].showUserList = vm[newsObjName].showUserList.concat(vm[newsObjName].storeList.splice(0,vm.stepRequestSettings.stepLook))
863        vm[newsObjName].currentPage += 1
864        vm[newsObjName].total = vm[newsObjName].showUserList.length
865        //当实际总数小于设置最大限定时,且不能为-1时
866        if (res.data.list_size !== -1 && res.data.list_size < vm.stepRequestSettings.limit[limitIndex]) {
867            vm.stepRequestSettings.limit[limitIndex] = res.data.list_size
868        }
869        console.log('total',vm[newsObjName].total,'limit',vm.stepRequestSettings.limit[limitIndex])
870        if (vm[newsObjName].total !== 0 && vm[newsObjName].total < vm.stepRequestSettings.limit[limitIndex] ) {
871            //加载继续
872            vm[newsObjName].showLoading = false
873        } else if (vm[newsObjName].total == 0) {
874            vm[newsObjName].showLoading = false
875            vm[newsObjName].showNomore = true
876        } else {
877            vm[newsObjName].showLoading = false
878            vm[newsObjName].showNomore = true
879        }
880    } else {//当返回列表为空时,没有更多数据
881        vm[newsObjName].showLoading = false
882        vm[newsObjName].showNomore = true
883    }
884
885}
886
887
888
889/*  
890    分布式请求报告列表
891    vm: vue实例  obj
892    reportObjName:新闻列表对象名称 string
893    filterController:分类筛选控制器 obj
894*/
895
896var stepAddReportList = function (vm,reportObjName,filterController) {
897    console.log('当前的报告实例',reportObjName, vm[reportObjName], filterController)
898    if (vm[reportObjName].total < vm.stepRequestSettings.limit) { //如果没有超过限定
899        if (vm[reportObjName].storeList.length !== 0) { //当缓冲区列表不为空
900            vm[reportObjName].showUserList = vm[reportObjName].showUserList.concat(vm[reportObjName].storeList.splice(0,vm.stepRequestSettings.stepLook))
901            vm[reportObjName].total += vm.stepRequestSettings.stepLook
902        } else { //当缓冲区没有新闻时
903            //模拟一下ajax请求
904            vm[reportObjName].showLoading = true
905            //入参
906            commonRequest('POST',BASEURL.ES.ESREQBASEURL1,'/search/api/es/search/conditional/report','json','application/json',{
907                keyword: filterController,
908                pageNum: vm[reportObjName].currentPage + 1,
909                pageSize: vm.stepRequestSettings.stepReq
910            }, RenderReportList)  
911        }
912    } else {
913        vm[reportObjName].showLoading = false
914        vm[reportObjName].showNomore = true
915    }
916
917
918}
919//渲染报告列表
920var RenderReportList = function(res) {
921    console.log('ES报告返回结果',res)
922    if (res.data.list.length !== 0) {
923        vm.reportNowObj.storeList = vm.reportNowObj.storeList.concat(res.data.list.splice(0,vm.stepRequestSettings.stepReq))
924        vm.reportNowObj.showUserList = vm.reportNowObj.showUserList.concat(vm.reportNowObj.storeList.splice(0,vm.stepRequestSettings.stepLook))
925        vm.reportNowObj.currentPage += 1
926        vm.reportNowObj.total = vm.reportNowObj.showUserList.length
927        //当实际总数小于设置最大限定时,且不能为-1时
928        if (res.data.total !== -1 && res.data.total < vm.stepRequestSettings.limit) {
929            vm.stepRequestSettings.limit = res.data.total
930        }
931        console.log(vm.reportNowObj, 'total',vm.reportNowObj.total,'limit',vm.stepRequestSettings.limit)
932        if (vm.reportNowObj.total !== 0 && vm.reportNowObj.total < vm.stepRequestSettings.limit) {
933            //加载继续
934            vm.reportNowObj.showLoading = false
935        } else if (vm.reportNowObj.total == 0) {
936            vm.reportNowObj.showLoading = false
937            vm.reportNowObj.showNomore = true
938        } else {
939            vm.reportNowObj.showLoading = false
940            vm.reportNowObj.showNomore = true
941        }
942    } else {//当返回列表为空时,没有更多数据
943        vm.reportNowObj.showLoading = false
944        vm.reportNowObj.showNomore = true
945    }
946
947}
948
949//侧边栏动画执行以及相关方法
950$(window).scroll(function(){
951    //投中24H模块固定
952    if ($('#index_aside_hourfastinfo').length !== 0) {
953        let _allChildren = $('.content_right_pc').eq(0)
954        let _totalHeight = 0;
955        for (let i = 0; i <_allChildren.children().length; i++) {
956            _totalHeight += (_allChildren.children()[i].offsetHeight + 40)
957        }
958        if ($(window).scrollTop() >= (_allChildren[0].offsetTop + _totalHeight)) {
959            $('#index_aside_hourfastinfo').addClass('asideFixedRight');
960            //600是展开后的进深高度
961            if ($(window).scrollTop() + $(window).height() >= ($(document).height() - 600)) {
962                $('#index_aside_hourfastinfo').removeClass('asideFixedRight');
963            }
964        } else if ($(window).scrollTop() < (_allChildren[0].offsetTop + _totalHeight)){
965            $('#index_aside_hourfastinfo').removeClass('asideFixedRight');
966        }
967    }
968
969
970});
971$(function(){
972    $('.common_asidefixed_tools .guestsignup_btn').hover(function(){
973        $('.common_asidefixed_tools .guestsignup_btn').addClass('guestsignupStrength');
974    })
975    $('.common_asidefixed_tools .guestsignup_btn').mouseleave(function(){
976        $('.common_asidefixed_tools .guestsignup_btn').removeClass('guestsignupStrength');
977    });
978    $('.common_asidefixed_tools .contribute_btn').hover(function(){
979        $('.common_asidefixed_tools .contribute_btn').addClass('contributeStrength');
980    })
981    $('.common_asidefixed_tools .contribute_btn').mouseleave(function(){
982        $('.common_asidefixed_tools .contribute_btn').removeClass('contributeStrength');
983    });
984    $('.common_asidefixed_tools .backtotop_btn').hover(function(){
985        $('.common_asidefixed_tools .backtotop_btn').addClass('backtotopStrength');
986    });
987    $('.common_asidefixed_tools .backtotop_btn').mouseleave(function(){
988        $('.common_asidefixed_tools .backtotop_btn').removeClass('backtotopStrength');
989    });
990    $('.common_asidefixed_tools .backtotop_btn').on('click',function () {
991        var timer = setInterval(function () {
992            var toTop = document.documentElement.scrollTop || document.body.scrollTop;
993            if(toTop == 0){
994              clearInterval(timer);
995            }else {
996              var speed = Math.ceil(toTop/2.5);
997              document.documentElement.scrollTop = document.body.scrollTop = toTop - speed;
998            }
999        },30);
1000    });
1001    $('.common_asidefixed_tools .appdownload_btn').hover(function(){
1002        $('.common_asidefixed_tools .appdownload_btn').addClass('active');
1003        $('.common_asidefixed_tools .ercode_box_bg').fadeIn(200);
1004    });
1005    $('.common_asidefixed_tools .appdownload_btn').mouseleave(function(){
1006        $('.common_asidefixed_tools .appdownload_btn').removeClass('active');
1007        setTimeout(function(){
1008            $('.common_asidefixed_tools .ercode_box_bg').fadeOut(10);
1009        },10);
1010    });
1011    $('.common_asidefixed_tools .appcode_tab li').click(function(){
1012        $('.common_asidefixed_tools .appcode_tab li').removeClass('active');
1013        $('.common_asidefixed_tools .appcode_box li').removeClass('active');
1014        if (this.innerHTML == '投中网') {
1015            $('.common_asidefixed_tools .appcode_tab li').eq(0).addClass('active');
1016            $('.common_asidefixed_tools .appcode_box li').eq(0).addClass('active');
1017        } else {
1018            $('.common_asidefixed_tools .appcode_tab li').eq(1).addClass('active');
1019            $('.common_asidefixed_tools .appcode_box li').eq(1).addClass('active');
1020        }
1021    });
1022
1023    
1024})
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035//messageAlert提示框封装 Reliable: reset.v1.css, common.css
1036var messageAlert = function (opt) {
1037	this._id = 'messageAlert'+ new Date().getTime();
1038	this._initial(opt);
1039}
1040//弹出框原型
1041messageAlert.prototype = {
1042    //初始化
1043    _initial: function(opt){
1044        var _self = this;
1045        var _content = document.getElementById('page_content')
1046        var _messageDiv = document.createElement('div');
1047        _messageDiv.className = 'message_alert'
1048        _messageDiv.id = this._id;
1049        //背景
1050        if (opt.bgMask) {
1051            var _maskDiv = document.createElement('div');
1052            _maskDiv.className = 'message_alert_bg'
1053            opt.bgMask.bgColor ? _maskDiv.style.backgroundColor = opt.bgMask.bgColor : _maskDiv.style.backgroundColor = 'rgba(0,0,0,0.2)'
1054            _messageDiv.appendChild(_maskDiv)
1055        }
1056        //弹框主体
1057        var _alertDiv = document.createElement('div');
1058        opt.isPc ? _alertDiv.className = 'message_alert_content_pc' : _alertDiv.className = 'message_alert_content_mob'
1059        if(opt.title){
1060            var _titleDiv = document.createElement('div');
1061            _titleDiv.className = 'message_alert_title'
1062            _titleDiv.innerHTML = opt.title
1063            _alertDiv.appendChild(_titleDiv)
1064        }
1065        if (opt.showCloseBtn) {
1066            var _closeDiv = document.createElement('div');
1067            _closeDiv.className = 'message_alert_closebtn';
1068            _closeDiv.innerHTML = '<span class="t1"></span><span class="t2"></span>'
1069            _alertDiv.appendChild(_closeDiv)
1070        }
1071        if (opt.innerText) {
1072            var _textDiv = document.createElement('div');
1073            _textDiv.className = 'message_alert_text';
1074            _textDiv.innerHTML = opt.innerText
1075            _alertDiv.appendChild(_textDiv)
1076        }
1077        if (opt.buttonGroup.length) {
1078            var _btnzoneDiv = document.createElement('div');
1079            _btnzoneDiv.className = 'message_alert_btnzone';
1080            for (var i = 0; i < opt.buttonGroup.length; i++) {
1081                var _button = document.createElement('button');
1082                _button.innerHTML = opt.buttonGroup[i].buttonText
1083                _btnzoneDiv.appendChild(_button)
1084            }
1085            _alertDiv.appendChild(_btnzoneDiv)
1086        }
1087        _messageDiv.appendChild(_alertDiv)
1088
1089        //必须DOM挂载完成后,增加事件监听,否则所有方法挂载失效
1090        _content.appendChild(_messageDiv)
1091        if(opt.bgMask.isClose){
1092            document.getElementById(this._id).getElementsByClassName('message_alert_bg')[0].addEventListener("click", function(){
1093                _self._removeAlert()
1094            });
1095        }
1096        if(opt.showCloseBtn){
1097            document.getElementById(this._id).getElementsByClassName('message_alert_closebtn')[0].addEventListener("click", function(){
1098                _self._removeAlert()
1099            });
1100        }
1101        if (opt.buttonGroup.length) {
1102            for(let i = 0; i < opt.buttonGroup.length; i++){
1103                document.getElementById(this._id).getElementsByTagName('button')[i].addEventListener("click", function(){
1104                    opt.buttonGroup[i].clickFn && _self._btnClickFn(opt.buttonGroup[i].clickFn)
1105                });
1106            }
1107        }
1108        //禁用滚动
1109        //document.body.addEventListener('touchmove',this._bodyScroll,false);  
1110        //$('body').css({'position':'fixed',"width":"100%"});
1111    },
1112    //移除信息弹框
1113    _removeAlert:function(){
1114        //解锁滚动
1115        //document.body.removeEventListener('touchmove',this._bodyScroll,false);   
1116        //$("body").css({"position":"initial","height":"auto"}); 
1117        var _deletChild = document.getElementById(this._id)
1118        _deletChild.parentNode.removeChild(_deletChild)
1119        return this
1120    },
1121    //按钮用户回调方法
1122    _btnClickFn:function(clickFn){
1123        clickFn && clickFn()
1124        this._removeAlert()
1125        return this
1126    },
1127    //禁用滚动方法
1128    _bodyScroll:function (event){  
1129        event.preventDefault();  
1130    }
1131}
1132
1133
1134// 广告位滚动
1135$(document).ready(function() {
1136    console.log(1);
1137    if ($('#index_topadv_zone').length > 0 && $('#index_topadv_zone .swiper-slide').length > 1) {
1138        console.log(2);
1139        new Swiper("#index_topadv_zone",{ 
1140          direction:"horizontal",/*横向滑动*/
1141            loop:true,
1142            slidesPerView: 1,
1143            spaceBetween: 50,
1144            autoplay: {
1145                delay: 5000,//1秒切换一次
1146                disableOnInteraction: false,
1147            },
1148            navigation: {
1149                nextEl: '.swiper-button-next',
1150                prevEl: '.swiper-button-prev',
1151            }
1152        })
1153    }
1154})

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.