From 044d7e7a1d9f184f52585aa5ee7891aaf7bd117f Mon Sep 17 00:00:00 2001 From: zhanglin Date: Thu, 27 Jun 2024 09:14:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=9F=AD=E4=B8=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/homeIndex/index.vue | 79 ++++++++++++++++++++++++++++++--------- pages/login/login.vue | 8 ++-- 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/pages/homeIndex/index.vue b/pages/homeIndex/index.vue index 68a7348..51240e2 100644 --- a/pages/homeIndex/index.vue +++ b/pages/homeIndex/index.vue @@ -386,7 +386,8 @@ export default { imgHours: '', imgHourstm: [], imgHoursList: {}, - interval: null + interval: null, + numPic: 0 } }, computed: { @@ -511,15 +512,15 @@ export default { } }) }, - async getHoursImg () { + getTmData () { let h = moment().format('HH') let m = moment().format('mm') - console.log('hhh--', h, m) + console.log('hhh--', h, m, this.numPic) let tms = null, mm = null let h1 = Number(h) - 1 if (h1 < 9) { - h1 = Number(h) - 3 + h1 = Number(h) - this.numPic } if (h1 < 10) { h1 = `0${h1}` @@ -535,31 +536,73 @@ export default { tms = `${this.imgtm}${h1}30` mm = '30' } + }, + async getHoursImg () { + let h = moment().format('HH') + let m = moment().format('mm') + console.log('hhh--', h, m, this.numPic) + let tms = null, + mm = null + let h1 = Number(h) - 1 + if (h1 < 9) { + h1 = Number(h) - Number(this.numPic) + } + if (h1 < 10) { + let t = Number(h1) - Number(this.numPic) + h1 = `0${t}` + } + if (m > 30) { + h1 = Number(h) - 1 + let t3 = Number(h) - this.numPic + if (this.numPic <= 0) { + tms = `${this.imgtm}${h}30` + } else { + tms = `${this.imgtm}${t3}30` + } - console.log('ddddd', h, h1) - console.log('ddddd', tms) + mm = '30' + } else if (m < 10) { + tms = `${this.imgtm}${h1}00` + mm = '00' + } else { + tms = `${this.imgtm}${h1}30` + mm = '30' + } + + console.log('小时', h1) + console.log('需要参数', tms) uni.request({ url: 'https://shqxjs.cloudowr.cn/service/radar/rainimg', data: { tm: tms }, success: res => { - console.log('000000', tms, res.data.data) + console.log('pic---', tms, res.data.data) this.imgHoursList = res.data.data.img - let m = moment().format('MM月DD日') console.log('am222', this.imgHoursList) let m1 = Number(h1) + 2 this.imgHourstm = [`${m}${h1}时${mm}分`, `${m}${m1}时${mm}分`] + + if (res.data.data.img == null) { + this.numPic++ + setTimeout(() => { + this.getHoursImg() + }, 10 * 1000) + } else { + this.numPic = 0 + return + } } }) }, - async getInterval () { - this.interval = setInterval(() => { - this.getHoursImg() - }, 60 * 1000) - }, + + // async getInterval () { + // this.interval = setInterval(() => { + // this.getHoursImg() + // }, 60 * 1000) + // }, async getYjRead () { try { const { data } = await uni.$http.get( @@ -814,15 +857,15 @@ export default { this.getReadStatus() if (this.limit == 1) { this.getYjRead() - this.getInterval() + // this.getInterval() this.getImgs() this.getHoursImg() } - }, - onUnload () { - clearInterval(this.interval) - this.interval = null } + // onUnload () { + // clearInterval(this.interval) + // this.interval = null + // } } diff --git a/pages/login/login.vue b/pages/login/login.vue index 7e11189..5337468 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -91,10 +91,10 @@ export default { uni.setStorageSync('loginName', postForm.loginName) uni.setStorageSync('secretKey', postForm.secretKey) } else { - // uni.removeStorageSync('loginName') - // uni.removeStorageSync('secretKey') - // this.formData.username = '' - // this.formData.password = '' + uni.removeStorageSync('loginName') + uni.removeStorageSync('secretKey') + this.formData.username = '' + this.formData.password = '' } //提交表单