improve: 分类切换更新缓存

This commit is contained in:
From-wh 2023-03-29 12:16:14 +08:00
parent e02a03a220
commit 82b88e7d6c
5 changed files with 443 additions and 449 deletions

View File

@ -49,10 +49,12 @@
getCategoryVersion().then(res => {
if (!uni.getStorageSync('CAT_VERSION') || res.data.version != uni.getStorageSync(
'CAT_VERSION')) {
this.isNew = true
this.isNew = !this.isNew
console.log('变了')
uni.setStorageSync('CAT_VERSION', res.data.version)
} else {
this.isNew = false
} else {
console.log('没变')
// this.isNew = false
}
this.classStyle();
})

View File

@ -128,9 +128,8 @@
},
watch: {
isNew(newVal) {
if (newVal) {
this.getAllCategory();
}
this.getAllCategory(1);
}
},
methods: {
@ -184,11 +183,12 @@
this.navActive = index;
this.$set(this, 'lock', true);
},
getAllCategory: function() {
getAllCategory: function(type) {
let that = this;
if (this.isNew || !uni.getStorageSync('CAT1_DATA')) {
if (type || !uni.getStorageSync('CAT1_DATA')) {
getCategoryList().then(res => {
uni.setStorageSync('CAT1_DATA', res.data)
uni.setStorageSync('CAT1_DATA', res.data)
console.log('调了')
that.productList = res.data;
that.$nextTick(res => {
that.infoScroll();

View File

@ -117,9 +117,7 @@
},
watch: {
isNew(newVal) {
if (newVal) {
this.getAllCategory();
}
this.getAllCategory(1);
}
},
computed: mapGetters(['isLogin', 'uid']),
@ -168,15 +166,7 @@
storeInfo: {}
}
},
// onShow(){
// if(this.isLogin){
// this.getCartNum();
// this.getCartList(1);
// }
// this.getAllCategory();
// },
mounted() {
// this.getAllCategory();
let that = this;
// 获取设备宽度
uni.getSystemInfo({
@ -642,9 +632,9 @@
closeTap() {
this.iSlong = true
},
getAllCategory: function() {
getAllCategory: function(type) {
let that = this;
if (this.isNew || !uni.getStorageSync('CAT2_DATA')) {
if (type|| !uni.getStorageSync('CAT2_DATA')) {
getCategoryList().then(res => {
uni.setStorageSync('CAT2_DATA', res.data)
let data = res.data;

View File

@ -121,9 +121,7 @@
},
watch: {
isNew(newVal) {
if (newVal) {
this.getAllCategory();
}
this.getAllCategory(1);
}
},
data() {
@ -678,9 +676,9 @@
closeTap() {
this.iSlong = true
},
getAllCategory: function() {
getAllCategory: function(type) {
let that = this;
if (this.isNew || !uni.getStorageSync('CAT3_DATA')) {
if (type || !uni.getStorageSync('CAT3_DATA')) {
getCategoryList().then(res => {
let data = res.data;
uni.setStorageSync('CAT3_DATA', data)

File diff suppressed because one or more lines are too long