提交 bbee561d 编写于 作者: R Renic1

新增缓存

上级 54b3d950
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
name:'', name:'',
type:'', type:'',
icon:'', icon:'',
teamNameStorageCount:1,
runningRecordStorageCount:1,
walkingRecordStorageCount:1,
} }
} }
</script> </script>
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
schoolName: '', schoolName: '',
teamName: '新野生动物营', teamName: '新野生动物营',
userId: '', userId: '',
teamNameStorageCount:1,
} }
}, },
methods: { methods: {
...@@ -108,7 +109,17 @@ ...@@ -108,7 +109,17 @@
.then(res => { .then(res => {
console.log(res); console.log(res);
this.teamName = res.result.data.team; this.teamName = res.result.data.team;
let that =this;
uni.setStorage({
key: 'teamName_key',
data: this.teamName,
success: function () {
console.log(that.teamName);
}
})
getApp().globalData.teamNameStorageCount=0;
}); });
console.log(this.teamName)
}, },
}, },
onLoad() { onLoad() {
...@@ -119,7 +130,18 @@ ...@@ -119,7 +130,18 @@
this.nickname = getApp().globalData.name; this.nickname = getApp().globalData.name;
this.schoolName = getApp().globalData.school; this.schoolName = getApp().globalData.school;
this.userId = getApp().globalData.userId; this.userId = getApp().globalData.userId;
this.getData(); if(getApp().globalData.teamNameStorageCount==1) {//增删改查
this.getData();
}else {
uni.getStorage({
key: 'teamName_key',
success: function (res) {
console.log(res.data);
this.teamName=res.data;
console.log(this.teamName);
}
})
}
} }
} }
</script> </script>
......
...@@ -68,7 +68,15 @@ ...@@ -68,7 +68,15 @@
item.duration = this.formatSeconds(item.duration); item.duration = this.formatSeconds(item.duration);
item.startDatetime = this.formatDate(item.startDatetime); item.startDatetime = this.formatDate(item.startDatetime);
}); });
let that =this;
uni.setStorage({
key: 'runningRecord_key',
data: this.runningrecordList,
success: function () {
console.log(that.runningrecordList);
}
})
getApp().globalData.runningRecordStorageCount=0;
}); });
}, },
formatSeconds(value) { formatSeconds(value) {
...@@ -112,7 +120,22 @@ ...@@ -112,7 +120,22 @@
return arr[0]; return arr[0];
}, },
onLoad() { onLoad() {
this.getData(); if(getApp().globalData.runningRecordStorageCount==1) {
this.getData();
}else {
uni.getStorage({
key: 'runningRecord_key',
success: (res)=> {
console.log(res.data);
this.runningrecordList=res.data;
console.log(this.runningrecordList);
this.runningrecordList.forEach((item, index) => {
item.duration = this.formatSeconds(item.duration);
item.startDatetime = this.formatDate(item.startDatetime);
});
}
})
}
} }
} }
} }
......
...@@ -69,6 +69,15 @@ ...@@ -69,6 +69,15 @@
item.duration = this.formatSeconds(item.duration); item.duration = this.formatSeconds(item.duration);
item.startDatetime = this.formatDate(item.startDatetime); item.startDatetime = this.formatDate(item.startDatetime);
}); });
let that =this;
uni.setStorage({
key: 'walkingRecord_key',
data: this.walkingrecordList,
success: function () {
console.log(that.walkingrecordList);
}
})
getApp().globalData.walkingRecordStorageCount=0;
}); });
}, },
formatDate(value) { formatDate(value) {
...@@ -112,7 +121,23 @@ ...@@ -112,7 +121,23 @@
return result; return result;
}, },
onLoad() { onLoad() {
this.getData(); if(getApp().globalData.walkingRecordStorageCount==1) {
this.getData();
}else {
uni.getStorage({
key: 'walkingRecord_key',
success: (res)=> {
console.log(res.data);
this.walkingrecordList=res.data;
console.log(this.walkingrecordList);
this.walkingrecordList.forEach((item, index) => {
item.duration = this.formatSeconds(item.duration);
item.startDatetime = this.formatDate(item.startDatetime);
});
}
})
}
} }
} }
} }
......
...@@ -197,6 +197,7 @@ ...@@ -197,6 +197,7 @@
uni.showToast({ uni.showToast({
title: '退出成功' title: '退出成功'
}); });
getApp().globalData.teamNameStorageCount=1;
} else { } else {
uni.showToast({ uni.showToast({
title: '退出失败', title: '退出失败',
...@@ -220,6 +221,7 @@ ...@@ -220,6 +221,7 @@
.then(res => { .then(res => {
this.code = res.result.code this.code = res.result.code
console.log(this.userId) console.log(this.userId)
getApp().globalData.teamNameStorageCount=1;
}) })
this.$refs['popupDialog2'].close(); this.$refs['popupDialog2'].close();
await this.showTorM(); await this.showTorM();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册