任务缓存优化

This commit is contained in:
GaoHao 2024-12-31 09:57:41 +08:00
parent 6710481852
commit d1bca91769
1 changed files with 24 additions and 16 deletions

View File

@ -47,7 +47,7 @@
src="../../static/images/signIn_icon1.png" mode="" /> src="../../static/images/signIn_icon1.png" mode="" />
<view class="radius"></view> <view class="radius"></view>
<view class="_label">{{item.showText}}</view> <view class="_label">{{item.showText}}</view>
<view class="_label" style="font-size: 18rpx;color: #999;margin-top: 2rpx;">{{item.signDay.slice(5,10)}}</view> <view class="_label" style="font-size: 18rpx;color: #999;margin-top: 2rpx;">{{item.signDay.slice(6,10)}}</view>
</view> </view>
</view> </view>
@ -98,6 +98,10 @@
</template> </template>
<script> <script>
import {$cache_renwu} from '@/store/cashe.js'
import {isEmpty} from '@/utils/util.js'
export default { export default {
data() { data() {
@ -114,7 +118,6 @@
recordList: [ recordList: [
], ],
signInBtn: '点击签到', signInBtn: '点击签到',
isShowMoneyPay: true,
isIos: false, isIos: false,
isAndroid: false, isAndroid: false,
adRewardedVideo: true, adRewardedVideo: true,
@ -128,18 +131,6 @@
this.signInList = [] this.signInList = []
this.getTaskdata() this.getTaskdata()
this.getsignIn() 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.$nextTick(()=>{
this.adRewardedVideoloadNum = 0 this.adRewardedVideoloadNum = 0
this.$refs.adRewardedVideo.load(); this.$refs.adRewardedVideo.load();
@ -214,6 +205,12 @@
* 获取签到数据 * 获取签到数据
*/ */
getsignIn() { getsignIn() {
if($cache_renwu.signInList&&!isEmpty($cache_renwu.signDays)&&!isEmpty($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 => { this.$Request.getT('app/userSignRecord/getUserSignData', {}).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.signInList = res.data.recordList this.signInList = res.data.recordList
@ -228,6 +225,9 @@
this.signInBtn = '已签到' this.signInBtn = '已签到'
} }
}) })
$cache_renwu.set('signInList',this.signInList)
$cache_renwu.set('signDays',this.signDays)
$cache_renwu.set('enable',this.enable)
} else { } else {
// uni.showToast({ // uni.showToast({
// title: res.msg, // title: res.msg,
@ -318,6 +318,7 @@
icon: 'none' icon: 'none'
}) })
setTimeout(() => { setTimeout(() => {
$cache_renwu.clear()
this.getTaskdata() this.getTaskdata()
this.getsignIn() this.getsignIn()
}, 1000) }, 1000)
@ -333,6 +334,12 @@
* 获取任务列表 * 获取任务列表
*/ */
getTaskdata() { getTaskdata() {
if($cache_renwu.list){
this.list= $cache_renwu.list
uni.stopPullDownRefresh();
return
}
console.log('获取服务器 任务列表')
this.list= []; this.list= [];
this.$Request.getT('app/taskCenter/selectTaskCenter', {}).then(res => { this.$Request.getT('app/taskCenter/selectTaskCenter', {}).then(res => {
if (res.code == 0) { if (res.code == 0) {
@ -350,8 +357,7 @@
} }
// #endif // #endif
}) })
$cache_renwu.set('list',this.list)
} }
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
}) })
@ -362,6 +368,8 @@
*/ */
onPullDownRefresh: function() { onPullDownRefresh: function() {
console.log(2) console.log(2)
$cache_renwu.clear()
this.getsignIn()
this.getTaskdata(); this.getTaskdata();
}, },