A janela pop-up de atualização da versão do uniapp só aparece uma vez por dia
dica ! ! ! Mostra principalmente a lógica de que a janela pop-up só aparece uma vez por dia e não mostra o código pop-up de atualização de versão
Salve o ano, mês e dia atuais localmente quando a janela pop-up de atualização de versão for fechada
close(){
this.show=false
var time = {
year:new Date().getFullYear(),
month:new Date().getMonth()+1,
date:new Date().getDate()
}
uni.setStorage({
key:'version',
data:time
})
this.$emit('close')
},
Ao comparar o número da versão na página inicial, pegue a data no cache local e compare-a com a data atual
if (this.version > version) {
uni.getStorage({
key: 'version',
success: (res) => {
var time = {
year: new Date().getFullYear(),
month: new Date().getMonth() + 1,
date: new Date().getDate()
}
if (!res.data){
_self.$refs.version.show = true
return false
}
if (time.year > res.data.year) {
_self.$nextTick(function() {
// 年
_self.$refs.version.show = true
})
} else if (time.year == res.data.year) {
if (time.month > res.data.month) {
// 月
_self.$nextTick(function() {
_self.$refs.version.show = true
})
} else if (time.month == res.data.month) {
if (time.date > res.data.date) {
// 天
_self.$nextTick(function() {
_self.$refs.version.show = true
})
}
}
}
},
fail: () => {
var time = {
year:new Date().getFullYear(),
month:new Date().getMonth()+1,
date:new Date().getDate()
}
uni.setStorage({
key:'version',
data:time
})
}
})
}