Просмотр исходного кода

improve: 分类切换更新缓存

From-wh 2 лет назад
Родитель
Сommit
82b88e7d6c

+ 5 - 3
template/uni-app/pages/goods_cate/goods_cate.vue

@@ -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();
 				})

+ 6 - 6
template/uni-app/pages/goods_cate/goods_cate1.vue

@@ -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();

+ 3 - 13
template/uni-app/pages/goods_cate/goods_cate2.vue

@@ -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;

+ 3 - 5
template/uni-app/pages/goods_cate/goods_cate3.vue

@@ -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)

Разница между файлами не показана из-за своего большого размера
+ 426 - 422
template/uni-app/pages/users/user_integral/index.vue