import { stationurl,brigade } from "../../../../public/js/url.js"; import {stationInfoTableList,layuiObj } from "../index.js"; import { getCurrData } from "../../../../public/js/timestamp.js"; let currentStation="";//五一中路小学 let schoolNewslist=[]; async function selectSchoolNewsGetlist() { schoolNewslist=[]; var schoolNewsReq=await getSchoolNewsGetlist(); schoolNewslist=schoolNewsReq.data.data; schoolNewslist.reverse(); showSchoolNewslist(schoolNewslist); showBasicSchoolInfo(); //初始化时间 $("#schoolstyle_time").val(getCurrData()); layuiObj.laydate.render({ elem: '#schoolstyle_time', done:function(value, date){ updateSchoolStyleTimeInfo(value); } }); } function getSchoolNewsGetlist(){ var data={ "brigade":brigade, "station":currentStation } var loginurl=stationurl+"/firectrl/school/news/getlist"; return axios({ method: 'post', url:loginurl, data: data }) } function showSchoolNewslist(newslist){ var div=""; newslist.forEach(item=>{ if(item["imageUrls"].length>0){ var imgUrl=JSON.parse(item["imageUrls"]); var url=stationurl+imgUrl[0]; }else{ var url=""; } div+=`
暂无风采
`); }else{ $(".campusStyle-list_box").html(div); } $(".school_name_style").html(currentStation); addSchoolNewslistEvent(); } function showBasicSchoolInfo(){ stationInfoTableList.forEach(item=>{ var station=item["name"]; if(currentStation==station){ $(".schoolName").html(item["nickname"]); $(".schoolAddress").html(item["address"]); $(".schoolPersonPhone").html(item["legal_person"]+"("+item["legal_person_phone"]+")"); $(".schoolDetachment").html(item["detachment"]); $(".schoolBorough").html(item["borough"]); $(".teacherCount").html(item["teacherCount"]); $(".roomCount").html(item["roomCount"]); $(".studentCount").html(item["studentCount"]); $(".guarderCount").html(item["guarderCount"]); //显示学校大门口图片 var src=`${stationurl}/mdev/pic/download?creator=学校简介和图片/${station}&file=gate.jpg` $(".schoolInfo_right").html(``) //图片放大 new Viewer(document.getElementById(`${station}gate`),{ url: 'data-original' }); getStationmDesc(station); } }) } //获取学校的简介 function getStationmDesc(station){ const url = `${stationurl}/mdev/pic/download?creator=学校简介和图片/${station}&file=简介.txt` //const url = `${stationurl}/mdev/pic/download?creator=geo&file=430000.json` fetch(url).then(response=>{ var status=response["status"] if(status=="500"){ return new Promise((resovle)=>{ resovle("无数据"); }) }else{ //return response.json(); return response.text(); } }).then(data => { console.log(data); $(".stationDesc").html(data); }); } function updateBasicSchoolInfo(station){ currentStation=station; if(station=="000"){ currentStation=""; } selectSchoolNewsGetlist(); } function updateSchoolStyleTimeInfo(time){ var timearr=[]; time=time+" 23:59:59"; schoolNewslist.forEach(item=>{ var timestamp=new Date(item["timestamp"]).getTime(); var currTimestamp=new Date(time).getTime(); if(currTimestamp>timestamp){ timearr.push(item); } }) showSchoolNewslist(timearr) } function addSchoolNewslistEvent(){ $(".campusStyle-list>ul>li>.showMore").on('click',function(){ var newsId=$(this).parent().attr("newsId"); getSchoolStyleInfo(newsId,schoolNewslist) }) } export function getSchoolStyleInfo(newsId,schoolNewslist){ var imgs=""; var div=""; var imgUrlArr=[]; schoolNewslist.forEach(item=>{ if(item["newsId"]==newsId){ var timestamp=item["timestamp"] var title=item["title"]; var comment=item["comment"]; var creator=item["creator"]; var station=item["station"]; div+=`学校: ${station}
标题: ${title}
内容: ${comment}
发布时间: ${timestamp}
发布者: ${creator}