mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-11-01 23:40:38 +00:00
improve: 分类切换更新缓存
This commit is contained in:
parent
e02a03a220
commit
82b88e7d6c
@ -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();
|
||||
})
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
Loading…
x
Reference in New Issue
Block a user