The uniapp version update pop-up window only pops up once a day
hint ! ! ! It mainly shows the logic that the pop-up window only pops up once a day, and does not show the version update pop-up code
Save the current year, month, and day locally when the version update pop-up window is closed
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')
},
When comparing the version number on the home page, take the date in the local cache and compare it with the current date
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
})
}
})
}