首页增加缓存

This commit is contained in:
2024-12-30 18:29:38 +08:00
parent 78f071dfda
commit 4bedd70016

View File

@@ -210,7 +210,12 @@
import activityComp from '../../components/activityComp/activityComp.vue' import activityComp from '../../components/activityComp/activityComp.vue'
import dragButton from "@/components/drag-button/drag-button.vue"; import dragButton from "@/components/drag-button/drag-button.vue";
import httpsRequest from '../../common/httpRequest.js' import httpsRequest from '../../common/httpRequest.js'
import {$cache_index} from '@/store/cashe.js' import {
$cache_index
} from '@/store/cashe.js'
import {
$cache_config
} from '@/store/cashe.js'
console.log($cache_index) console.log($cache_index)
export default { export default {
components: { components: {
@@ -339,13 +344,8 @@
uni.setStorageSync('qdCodeion', options.qdCode) uni.setStorageSync('qdCodeion', options.qdCode)
} }
if (uni.getStorageSync('token')) { if (uni.getStorageSync('token')) {
this.$u.get('/app/common/type/813').then(res => { this.zhuliInit()
if (res.code == 0 && res.data.value) {
if (res.data.value == '是') {
this.getActivity()
}
}
})
} }
let u = navigator ? navigator.userAgent : ''; let u = navigator ? navigator.userAgent : '';
@@ -378,10 +378,97 @@
this.getCourseList() this.getCourseList()
this.homeTypeSel = uni.getStorageSync('homeTypeSel') ? uni.getStorageSync('homeTypeSel') : '否' this.homeTypeSel = uni.getStorageSync('homeTypeSel') ? uni.getStorageSync('homeTypeSel') : '否'
//#ifdef H5 //#ifdef H5
let that = this let that=this;
if($cache_config.isGongZhongHaoAutoLogin!==null&&$cache_config.isGongZhongHaoAutoLogin!==undefined){
if($cache_config.isGongZhongHaoAutoLogin=='是'){
that.wxWebInit()
}
}else{
this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108 this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108
if (res.code == 0 && res.data) { if (res.code == 0 && res.data) {
$cache_config.set('isGongZhongHaoAutoLogin',res.data)
if (res.data.value == '是') { if (res.data.value == '是') {
that.wxWebInit()
}
}
});
}
//#endif
if (uni.getStorageSync('token')) {
this.getMyLoveVideo()
//新用户红包 837
this.newUserRedInit()
} else { //没有登录隐藏悬浮与弹窗
this.showzl = false
this.shodrag = false
this.videoInfo = []
}
// #ifdef APP
httpsRequest.getT("app/common/type/919", {}).then(res => {
if (res.code == 0) {
const sysInfo = uni.getSystemInfoSync();
let isIos = sysInfo.platform == 'ios'
this.isShowMoneyPay = !(res.data.value == '1' && isIos)
}
});
// #endif
},
onReachBottom() {
if (this.page < this.pages) {
this.page += 1
this.status = 'loading'
this.getCourseList()
} else {
this.status = 'nomore'
}
},
onPullDownRefresh() {
this.page = 1
$cache_index.clear()
this.getCourseList()
},
methods: {
//新用户红包 837
newUserRedInit(){
if($cache_config.isNewUserRedPack!==null&&$cache_config.isNewUserRedPack!==undefined){
if($cache_config.isNewUserRedPack){
this.xxJDNum = $cache_config.isNewUserRedPack;
this.checkNewUser()
}
return
}
this.$u.get('/app/common/type/837').then(res => {
$cache_config.set('isNewUserRedPack',res.data.value)
if (res.code == 0 && res.data.value) {
this.xxJDNum = res.data.value;
this.checkNewUser()
}
})
},
zhuliInit(){
if($cache_config.isOpenZhuLi!==null&&$cache_config.isOpenZhuLi!==undefined){
if($cache_config.isOpenZhuLi=='是'){
this.getActivity()
}
}else{
this.$u.get('/app/common/type/813').then(res => {
if (res.code == 0 && res.data.value) {
$cache_config.set('isOpenZhuLi',res.data.value)
if (res.data.value == '是') {
this.getActivity()
}
}
})
}
},
//处于微信公众号时的处理
wxWebInit() {
let that = this;
let ua = navigator.userAgent.toLowerCase(); let ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') !== -1) { if (ua.indexOf('micromessenger') !== -1) {
let openid = uni.getStorageSync('openId'); let openid = uni.getStorageSync('openId');
@@ -415,58 +502,9 @@
} }
} }
} }
}
}
});
//#endif
if (uni.getStorageSync('token')) {
this.getMyLoveVideo()
this.$u.get('/app/common/type/813').then(res => {
if (res.code == 0 && res.data.value) {
if (res.data.value == '是') {
this.getActivitys()
}
}
})
//新用户红包 837
this.$u.get('/app/common/type/837').then(res => {
if (res.code == 0 && res.data.value) {
this.xxJDNum = res.data.value;
this.checkNewUser()
}
})
} else { //没有登录隐藏悬浮与弹窗
this.showzl = false
this.shodrag = false
this.videoInfo = []
}
// #ifdef APP
httpsRequest.getT("app/common/type/919", {}).then(res => {
if (res.code == 0) {
const sysInfo = uni.getSystemInfoSync();
let isIos = sysInfo.platform == 'ios'
this.isShowMoneyPay = !(res.data.value == '1' && isIos)
}
});
// #endif
}, },
onReachBottom() {
if (this.page < this.pages) {
this.page += 1
this.status = 'loading'
this.getCourseList()
} else {
this.status = 'nomore'
}
},
onPullDownRefresh() {
this.page = 1
$cache_index.clear()
this.getCourseList()
},
methods: {
// 获取活动等级 // 获取活动等级
getActivitys() { getActivitys() {
this.$Request.getT('/app/invite/selectInviteAwardByUserId').then(res => { this.$Request.getT('/app/invite/selectInviteAwardByUserId').then(res => {
@@ -502,9 +540,15 @@
limit: 1, limit: 1,
classify: 1 classify: 1
} }
if($cache_index.videoInfo){
this.videoInfo = $cache_index.videoInfo||[]
this.shodrag = this.videoInfo.length>0
return
}
this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => { this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.videoInfo = res.data.records this.videoInfo = res.data.records
$cache_index.set('videoInfo',this.videoInfo)
if (this.videoInfo.length > 0) { if (this.videoInfo.length > 0) {
this.shodrag = true this.shodrag = true
} }