123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- const ar = async (time) => {
- try {
- let {data} = await axios({
- method: 'get',
- url: '/gettime?time=' + time,
- });
- console.log(data)
- } catch (error) {
- console.log(error)
- }
- }
- const getlastmonth = () => {
- var nowdays = new Date();
- var year = nowdays.getFullYear();
- var month = nowdays.getMonth();
- if(month==0){
- month=12;
- year=year-1;
- }
- if (month < 10) {
- month = "0" + month;
- }
- var myDate = new Date(year, month, 0);
- var lastDay = year + "-" + month + "-" + myDate.getDate()
- return lastDay
- }
- var fna = 0
- var boe = 0
- const xuanr = (data) => {
- document.querySelector('#der').innerHTML = ''
- let checktime=0;
- data.map((i)=>{
- let d = new Date(i.time)
- let times = (d.getMonth() + 1) + '/' + d.getDate()
- if(document.getElementById(`${i.id}`)){
- let fa = (parseInt(i.fan) - parseInt(fna)).toString()
- let bo = (parseInt(i.post) - parseInt(boe)).toString()
- if (fa < 0){ var facon = `<div style="background: #ff7b7b">${fa}</div>` } else { var facon = `<div style="background: #a6ff88">+${fa}</div>` }
- if (bo < 0){ var faconer = `<div style="background: #ff7b7b">${bo}</div>` } else { var faconer = `<div style="background: #a6ff88">+${bo}</div>` }
- let der = document.getElementById(`${i.id}`).parentNode
- if(d.getDate()!=checktime+1){
- checktime=d.getDate();
- der.innerHTML += `
- <div class="a4" id=${i.id}>
- <div style="background: #ff7b7b">无</div>
- <div style="background: #ff7b7b">无</div>
- <div style="background: #ff7b7b">无</div>
- <div style="background: #ff7b7b">无</div>
- </div>
- <div class="a4" id=${i.id}>
- <div>${i.post}</div>
- ${faconer}
- <div>${i.fan}</div>
- ${facon}
- </div>
- `
- }else{
- checktime++;
- der.innerHTML += `
- <div class="a4" id=${i.id}>
- <div>${i.post}</div>
- ${faconer}
- <div>${i.fan}</div>
- ${facon}
- </div>
- `
- }
- fna = i.fan
- boe = i.post
- }else{
- checktime=1;
- var date = new Date(i.time);
- date_value=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
- if(getlastmonth() != date_value){
- let fa = (parseInt(i.fan) - parseInt(fna)).toString()
- let bo = (parseInt(i.post) - parseInt(boe)).toString()
- if (fa < 0){ var facon = `<div style="background: #ff7b7b">${fa}</div>` } else { var facon = `<div style="background: #a6ff88">+${fa}</div>` }
- if (bo < 0){ var faconer = `<div style="background: #ff7b7b">${bo}</div>` } else { var faconer = `<div style="background: #a6ff88">+${bo}</div>` }
- document.querySelector('#der').innerHTML += `
- <div class="a1">
- <div class="a2">${i.name}</div>
- <div class="a3">${i.id}</div>
- <div class="a4">
- <div>发博数</div>
- <div>发博递减</div>
- <div>粉丝数</div>
- <div>粉丝递减</div>
- </div>
- <div class="a4" id=${i.id}>
- <div>${i.post}</div>
- ${faconer}
- <div>${i.fan}</div>
- ${facon}
- </div>
- </div>
- `
- }
- fna = i.fan
- boe = i.post
- }
- // boe = i.post
- })
- let checkdd=0;
- for(let der = 0; der < (data.length/45); der ++){
- let dd = new Date(data[der].time)
- let times = (dd.getMonth() + 1) + '/' + dd.getDate()
- let timeser = dd.getFullYear() + '-' + (dd.getMonth() + 1) + '-' + dd.getDate()
- if (timeser != getlastmonth()) {
- if(dd.getDate()!=checkdd+1){
- times = (dd.getMonth()+1) + '/' +(dd.getDate()-1)
- document.querySelector('.tim').innerHTML += `<div class="tim1">${times}</div>`
- times = (dd.getMonth()+1) + '/' +(dd.getDate())
- document.querySelector('.tim').innerHTML += `<div class="tim1">${times}</div>`
- checkdd=dd.getDate();
- }else{
- checkdd++;
- document.querySelector('.tim').innerHTML += `<div class="tim1">${times}</div>`
- }
- }
- }
- }
- var fnaer = 0
- var boeer = 0
- const chaxun = (data, ad) => {
- let checktime=0;
- document.querySelector('#der').innerHTML = ''
- data.map((i)=>{
- let d = new Date(i.time)
- let times = (d.getMonth() + 1) + '/' + d.getDate()
- let dder = new Date(i.time)
- let timeser = dder.getFullYear() + '/' + (dder.getMonth() + 1) + '/' + dder.getDate()
- if(document.getElementById(`${i.id}`)){
- let fa = (parseInt(i.fan) - parseInt(fnaer)).toString()
- let bo = (parseInt(i.post) - parseInt(boeer)).toString()
- if (fa < 0){ var facon = `<div style="background: #ff7b7b">${fa}</div>` } else { var facon = `<div style="background: #a6ff88">+${fa}</div>` }
- if (bo < 0){ var faconer = `<div style="background: #ff7b7b">${bo}</div>` } else { var faconer = `<div style="background: #a6ff88">+${bo}</div>` }
- let der = document.getElementById(`${i.id}`).parentNode
- if(d.getDate()!=checktime+1){
- checktime=d.getDate();
- der.innerHTML += `
- <div class="a4" id=${i.id}>
- <div style="background: #ff7b7b">无</div>
- <div style="background: #ff7b7b">无</div>
- <div style="background: #ff7b7b">无</div>
- <div style="background: #ff7b7b">无</div>
- </div>
- <div class="a4" id=${i.id}>
- <div>${i.post}</div>
- ${faconer}
- <div>${i.fan}</div>
- ${facon}
- </div>
- `
- }else{
- checktime++;
- der.innerHTML += `
- <div class="a4" id=${i.id}>
- <div>${i.post}</div>
- ${faconer}
- <div>${i.fan}</div>
- ${facon}
- </div>
- `
- }
- /*der.innerHTML += `
- <div class="a4" id=${i.id}>
- <div>${i.post}</div>
- ${faconer}
- <div>${i.fan}</div>
- ${facon}
- </div>
- `*/
- fnaer = i.fan
- boeer = i.post
- }else{
- checktime=1;
- var date = new Date(i.time);
- date_value=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
- if(getlastmonth() != date_value){
- let fa = (parseInt(i.fan) - parseInt(fnaer)).toString()
- let bo = (parseInt(i.post) - parseInt(boeer)).toString()
- if (timeser == "2018/10/24") {
- fa = 0
- bo = 0
- }
- if (fa < 0){ var facon = `<div style="background: #ff7b7b">${fa}</div>` } else { var facon = `<div style="background: #a6ff88">+${fa}</div>` }
- if (bo < 0){ var faconer = `<div style="background: #ff7b7b">${bo}</div>` } else { var faconer = `<div style="background: #a6ff88">+${bo}</div>` }
- document.querySelector('#der').innerHTML += `
- <div class="a1">
- <div class="a2">${i.name}</div>
- <div class="a3">${i.id}</div>
- <div class="a4">
- <div>发博数</div>
- <div>发博递减</div>
- <div>粉丝数</div>
- <div>粉丝递减</div>
- </div>
- <div class="a4" id=${i.id}>
- <div>${i.post}</div>
- ${faconer}
- <div>${i.fan}</div>
- ${facon}
- </div>
- </div>
- `
- }
- fnaer = i.fan
- boeer = i.post
- }
- // boe = i.post
- })
- let checkdd=0;
- for(let der = 0; der < (data.length/45); der ++){
- let dd = new Date(data[der].time)
- let times = (dd.getMonth() + 1) + '/' + dd.getDate()
- let timeser = dd.getFullYear() + '-' + (dd.getMonth() + 1) + '-' + dd.getDate()
- var nowdays = new Date();
- var year = nowdays.getFullYear();
- var month = nowdays.getMonth();
- if(month==0){
- month=12;
- year=year-1;
- }
- if (month < 10) {
- month = "0" + month;
- }
- var myDate = new Date(year, month, 0);
- var lastDay = year + "-" + month + "-" + myDate.getDate()
- //timeser渲染时
- //lastDay上个月
- if (document.querySelector('#search_begindate').value == dd.getFullYear() + '-' + (dd.getMonth() + 1)) {
- if(dd.getDate()!=checkdd+1){
- times = (dd.getMonth()+1) + '/' +(dd.getDate()-1)
- document.querySelector('.tim').innerHTML += `<div class="tim1">${times}</div>`
- times = (dd.getMonth()+1) + '/' +(dd.getDate())
- document.querySelector('.tim').innerHTML += `<div class="tim1">${times}</div>`
- checkdd=dd.getDate();
- }else{
- checkdd++;
- document.querySelector('.tim').innerHTML += `<div class="tim1">${times}</div>`
- }
- //document.querySelector('.tim').innerHTML += `<div class="tim1">${times}</div>`
- }
- }
- }
- window.onload = async () => {
- try {
- let {data} = await axios({
- method: 'get',
- url: '/all',
- });
- xuanr(data)
- } catch (error) {
- }
- }
- const getyue = async () => {
- try {
- let yue = document.querySelector('#search_begindate').value
- let {data} = await axios({
- method: 'get',
- url: `/getyue?time=${yue}&lasttime=${getlastmonth()}`,
- });
- document.querySelector('.tim').innerHTML = `<div class="tim1">#</div><div class="tim1">id</div><div class="tim1">日期</div>`
- document.querySelector('#der').innerHTML = ''
- chaxun(data, '1')
- } catch (error) {
- }
- }
- const gettimeer = async () => {
- let a = document.querySelector('#datepicker').value
- let b = document.querySelector('#datepickerer').value
- try {
- let url = '/setime?starttime=' + a + '&endtime=' + b
- let {data} = await axios({
- method: 'get',
- url: url,
- });
- document.querySelector('#der').innerHTML = '数据加载中'
- xuanr(data)
- } catch (error) {
- }
- }
|