|
- /**
- * Created by Administrator on 2021/4/5.
- */
- define(['jquery', "template", "Tools", "echarts", 'swiper'], function ($, template, Tools, echarts, swiper) {
- //数据存储
- var module = {
- data: {
- //服务器地址
- serverApi:'',
- //焦点图数据
- focusList: [],
- communicateList: [],
- noticeList: [],
- policyList: [],
- newList: [],
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
- //新闻管理列表
- // tools.doGet(news + '/003//7', {}, module.focusNews , true);
- tools.doGet(news, {}, module.newList , true);
- tools.doGet(trainingList, {}, module.trainingList , true);
-
- tools.doGet(dictType + '/supply_demand_unit', {}, module.dictType , true);
- tools.doGet(dictType + '/Industrial_classification_type', {}, module.dictTypeSecond , true);
-
- tools.getWebConfig();
-
-
- };
-
- module.dictType = function (data) {
- module.data.unitOptions = data.data;
- tools.doGet(supplyInformation, {}, module.supplyInformationList , true);
- tools.doGet(management, {}, module.managementList , true);
- tools.doGet(serviceList, {}, module.serviceList , true);
- tools.doPost(entityMain, {}, module.entityMain , true);
- }
-
- module.dictTypeSecond = function (data) {
- module.data.industryClassOptions = data.data;
- tools.doPost(entityMain, {}, module.entityMain , true);
- }
-
- //新闻列表
- module.newList = function (data) {
- if (data.code == 200) {
- var content = data.data;
- // var focusList = [];
- // for (var i = 0; i < content.length; i++) {
- // var imgStrs = content[i].content.match(/<img.*?>/g)
- // var title = content[i].title;
- // var id = content[i].id;
- // if (imgStrs != null && imgStrs != '') {
- // focusList.push({img:imgStrs[0],title:title,id:id})
- // }
- // }
- // module.data.focusList = focusList;
- // var bannerFocusData = template('bannerFocusData', module.data);
- // $("#bannerFocusContent").html(bannerFocusData);
- // new Swiper('#bannerFocusWrap', {
- // pagination: '.page-pagination',
- // paginationClickable: true,
- // autoplay : 2000,
- // loop:true
- // })
- // console.log(focusList)
- for (var i = 0 ; i < content.length ; i++){
- if (content[i].policyNewsNoticeType == "3"){
- module.data.noticeList.push(content[i]);
- }
- if (content[i].policyNewsNoticeType == "2"){
- module.data.newList.push(content[i]);
- }
- if (content[i].policyNewsNoticeType == "1"){
- module.data.policyList.push(content[i]);
- }
- }
- var noticeData = template('noticeData', module.data);
- $("#noticeContent").html(noticeData);
- var newData = template('newData', module.data);
- $("#newContent").html(newData);
- var policyData = template('policyData', module.data);
- $("#policyContent").html(policyData);
- }
- }
-
- //培训列表
- module.trainingList = function (data) {
- if (data.code == 200) {
- var content = data.data;
- module.data.trainingList = content;
- var trainingData = template('trainingData', module.data);
- $("#trainingContent").html(trainingData);
- }
- }
-
- //供应信息
- module.supplyInformationList = function (data) {
- if (data.code == 200) {
- var content = data.data;
-
- console.log(serverApi)
-
- for ( var i = 0 ; i < content.length ; i++ ){
-
- content[i].unit = module.selectDictLabel(module.data.unitOptions,content[i].unit);
-
- content[i].supplyMasterMap = serverApi + content[i].supplyMasterMap ;
-
- }
-
- module.data.supplyInformationList = content;
- var supplyInformationData = template('supplyInformationData', module.data);
- $("#supplyInformationContent").html(supplyInformationData);
- }
- }
-
- //求购信息
- module.managementList = function (data) {
- if (data.code == 200) {
- var content = data.data;
-
- for ( var i = 0 ; i < content.length ; i++ ){
-
- content[i].unit = module.selectDictLabel(module.data.unitOptions,content[i].unit);
-
- content[i].supplyMasterMap = serverApi + content[i].supplyMasterMap ;
-
- }
-
- module.data.managementList = content;
- var managementData = template('managementData', module.data);
- $("#managementContent").html(managementData);
- }
- }
-
- //服务信息
- module.serviceList = function (data) {
- if (data.code == 200) {
- var content = data.data;
-
- for ( var i = 0 ; i < content.length ; i++ ){
-
- content[i].unit = module.selectDictLabel(module.data.unitOptions,content[i].unit);
-
- content[i].supplyMasterMap = serverApi + content[i].supplyMasterMap ;
-
- }
-
- module.data.serviceList = content;
- var serviceData = template('serviceData', module.data);
- $("#serviceContent").html(serviceData);
- }
- }
-
- //经营主体
- module.entityMain = function (data) {
- if (data.code == 200) {
- var content = data.data;
-
- for ( var i = 0 ; i < content.length ; i++ ){
- if (content[i].industryClassificationType != null){
- var industryClassificationType = content[i].industryClassificationType.split(",");
- var secondArray = "";
- for (var j = 0 ; j < industryClassificationType.length ; j++){
- secondArray += module.selectDictLabel(module.data.industryClassOptions,industryClassificationType[j]);
- }
- content[i].industryClassificationType = secondArray;
- }
- console.log(content[i].industryClassificationType)
- content[i].masterMap = serverApi + content[i].masterMap ;
-
- }
-
- module.data.entityMainList = content;
- var entityMainData = template('entityMainData', module.data);
- $("#entityMainContent").html(entityMainData);
- }
- }
-
- module.selectDictLabel = function (datas, value) {
- var actions = [];
- Object.keys(datas).some((key) => {
- if (datas[key].dictValue == ('' + value)) {
- actions.push(datas[key].dictLabel);
- return true;
- }
- })
- return actions.join('');
- }
-
- //方案公开
- module.schemeList = function (data) {
- if (data.code == 200) {
- var content = data.data;
- module.data.schemeList = content;
- var schemeData = template('schemeData', module.data);
- $("#schemeContent").html(schemeData);
- }
- }
-
- //焦点图数据
- module.focusNews = function (data) {
- if (data.code == 200) {
- var content = data.data;
- var focusList = [];
- for (var i = 0; i < content.length; i++) {
- var imgStrs = content[i].content.match(/<img.*?>/g)
- var title = content[i].title;
- var id = content[i].id;
- if (imgStrs != null && imgStrs != '') {
- focusList.push({img:imgStrs[0],title:title,id:id})
- }
- }
- //console.log(focusList)
- module.data.focusList = focusList;
- var bannerFocusData = template('bannerFocusData', module.data);
- $("#bannerFocusContent").html(bannerFocusData);
- new Swiper('#bannerFocusWrap', {
- pagination: '.page-pagination',
- paginationClickable: true,
- autoplay : 2000,
- loop:true
- })
-
- }
- }
-
- goDetail = function(id){
- tools.skip('/agriculturalLawEnforcement/view/workDynamics/workDetail.html?id='+id);
- }
-
- goNotice = function(id){
- tools.skip('/agriculturalLawEnforcement/view/noticeAnnouncement/noticeDetail.html?id='+id);
- }
-
- goScheme = function(id){
- tools.skip('/agriculturalLawEnforcement/view/schemeDisclosure/schemeDetail.html?id='+id);
- }
-
- goEnforcement = function(id){
- tools.skip('/agriculturalLawEnforcement/view/basis/basisDetail.html?id='+id);
- }
-
- goInteractSearch = function(){
- tools.skip('view/interact/interactList.html?keyWord='+$('#interactInput').val());
- }
- return module;
- });
|