|
- define(['jquery', "template", "Tools", 'LeftNav'], function ($, template, Tools, LeftNav) {
- //数据存储
- var module = {
- data: {
- //服务器地址
- serverApi: '',
- //焦点图数据
- focusList: [],
- communicateList: [],
- knowledgeOptions: [],
- noticeList: [],
- policyList: [],
- newList: [],
- dataList: {
- children: [],
- haschildren: true,
- isopen: false,
- level: "0",
- name: "",
- url: "#",
- },
- switchTab:'expert'
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
- //新闻管理列表
- tools.doGet(knowledgeClassification, {}, module.projectList, true);
- tools.doPost(expertDatabase, {}, module.expertDatabaseList, true);
- tools.doPost(articleLibrary, {}, module.articleLibraryList, true);
- tools.doPost(videoLibrary, {}, module.videoLibraryList, true);
- };
-
- //新闻列表
- module.projectList = function (data) {
- if (data.code == 200) {
- var content = data.data;
- content.forEach(res => {
- module.data.dataList.children.push(res);
- })
- leftNav(".left", module.data.dataList);
- }
- }
-
- //专家列表
- module.expertDatabaseList = function (data) {
- if (data.code == 200) {
- var content = data.data;
- for ( var i = 0 ; i < content.length ; i++ ){
- content[i].expertsImage = serverApi + content[i].expertsImage;
- }
- module.data.directoriesList = content;
- var directoriesData = template('directoriesData', module.data);
- $("#directoriesContent").html(directoriesData);
- }
- }
-
- //文章列表
- module.articleLibraryList = function (data) {
- if (data.code == 200) {
- var content = data.data;
- for ( var i = 0 ; i < content.length ; i++ ){
- content[i].cover = serverApi + content[i].cover;
- }
- module.data.articleList = content;
- var articleData = template('articleData', module.data);
- $("#articleContent").html(articleData);
- }
- }
-
- //视频列表
- module.videoLibraryList = function (data) {
- if (data.code == 200) {
- var content = data.data;
- for ( var i = 0 ; i < content.length ; i++ ){
- content[i].cover = serverApi + content[i].cover;
- }
- module.data.videoList = content;
- var videoData = template('videoData', module.data);
- $("#videoContent").html(videoData);
- }
- }
-
- switchTab = function (type) {
- $(".left .left_nav_name").removeClass("nav_open");
- $(".left .nav_li").removeClass("nav_li_open");
- tools.doPost(expertDatabase, {}, module.expertDatabaseList, true);
- tools.doPost(articleLibrary, {}, module.articleLibraryList, true);
- tools.doPost(videoLibrary, {}, module.videoLibraryList, true);
- $("#"+type+"Tit").addClass("active").siblings().removeClass("active");
- $("#"+type+"").css('display','block').siblings().css('display','none');
- module.data.switchTab = type;
- }
-
- goSearch = function (type) {
- if (type == 'expert'){
- tools.doPost(expertDatabase, {name: $("#searchInput").val()}, module.expertDatabaseList, true);
- }
- if (type == 'article'){
- tools.doPost(articleLibrary, {headline: $("#articleSearchInput").val()}, module.articleLibraryList, true);
- }
- if (type == 'video'){
- tools.doPost(videoLibrary, {headline: $("#videoSearchInput").val()}, module.videoLibraryList, true);
- }
- }
-
- searchType = function (id) {
- console.log(module.data.switchTab)
- $(".left .left_nav_name").removeClass("nav_open");
- if (module.data.switchTab == 'expert'){
- tools.doPost(expertDatabase, {field: id}, module.expertDatabaseList, true);
- }
- if (module.data.switchTab == 'article'){
- console.log('article------'+id)
- tools.doPost(articleLibrary, {knowledgeType: id}, module.articleLibraryList, true);
- }
- if (module.data.switchTab == 'video'){
- console.log('video------'+id)
- tools.doPost(videoLibrary, {knowledgeType: id}, module.videoLibraryList, true);
- }
- }
-
- return module;
- })
|