增加数据缓存,去除部分请求的重复/

This commit is contained in:
2024-12-30 16:31:01 +08:00
parent cbcd1c857c
commit 6fb98974d6
15 changed files with 697 additions and 320 deletions

View File

@@ -98,6 +98,7 @@
</template>
<script>
import {$cache_renwu} from '@/store/cashe.js'
export default {
data() {
@@ -114,7 +115,6 @@
recordList: [
],
signInBtn: '点击签到',
isShowMoneyPay: true,
isIos: false,
isAndroid: false,
adRewardedVideo: true,
@@ -128,18 +128,6 @@
this.signInList = []
this.getTaskdata()
this.getsignIn()
this.$Request.getT("app/common/type/919", {}).then(res => {
if (res.code == 0) {
const sysInfo = uni.getSystemInfoSync();
let isIos = sysInfo.platform == 'ios'
this.isIos = /iOS/.test(sysInfo.platform);
// 判断是否是安卓设备
this.isShowMoneyPay = !(res.data.value == '1' && isIos)
}
});
this.$nextTick(()=>{
this.adRewardedVideoloadNum = 0
this.$refs.adRewardedVideo.load();
@@ -214,6 +202,12 @@
* 获取签到数据
*/
getsignIn() {
if($cache_renwu.signInList&&$cache_renwu.signDays&&$cache_renwu.enable){
this.signInList =$cache_renwu.signInList
this.signDays =$cache_renwu.signDays
this.enable =$cache_renwu.enable
return
}
this.$Request.getT('app/userSignRecord/getUserSignData', {}).then(res => {
if (res.code == 0) {
this.signInList = res.data.recordList
@@ -228,6 +222,9 @@
this.signInBtn = '已签到'
}
})
$cache_renwu.set('signInList',this.signInList)
$cache_renwu.set('signDays',this.signDays)
$cache_renwu.set('enable',this.enable)
} else {
// uni.showToast({
// title: res.msg,
@@ -318,6 +315,7 @@
icon: 'none'
})
setTimeout(() => {
$cache_renwu.clear()
this.getTaskdata()
this.getsignIn()
}, 1000)
@@ -333,6 +331,12 @@
* 获取任务列表
*/
getTaskdata() {
if($cache_renwu.list){
this.list= $cache_renwu.list
uni.stopPullDownRefresh();
return
}
console.log('获取服务器 任务列表')
this.list= [];
this.$Request.getT('app/taskCenter/selectTaskCenter', {}).then(res => {
if (res.code == 0) {
@@ -350,8 +354,7 @@
}
// #endif
})
$cache_renwu.set('list',this.list)
}
uni.stopPullDownRefresh();
})
@@ -362,6 +365,7 @@
*/
onPullDownRefresh: function() {
console.log(2)
$cache_renwu.clear()
this.getTaskdata();
},