首页增加缓存
This commit is contained in:
@@ -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 : '';
|
||||||
|
|
||||||
@@ -364,13 +364,13 @@
|
|||||||
//本周热门
|
//本周热门
|
||||||
this.getrecomVideo('2')
|
this.getrecomVideo('2')
|
||||||
//本周排行榜
|
//本周排行榜
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
this.getrecomVideo('1')
|
this.getrecomVideo('1')
|
||||||
},100)
|
}, 100)
|
||||||
//最新
|
//最新
|
||||||
setTimeout(()=>{
|
setTimeout(() => {
|
||||||
this.getrecomVideo('')
|
this.getrecomVideo('')
|
||||||
},200)
|
}, 200)
|
||||||
this.getBannerList()
|
this.getBannerList()
|
||||||
this.getMsg()
|
this.getMsg()
|
||||||
this.getGardList()
|
this.getGardList()
|
||||||
@@ -378,63 +378,29 @@
|
|||||||
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;
|
||||||
this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108
|
if($cache_config.isGongZhongHaoAutoLogin!==null&&$cache_config.isGongZhongHaoAutoLogin!==undefined){
|
||||||
if (res.code == 0 && res.data) {
|
if($cache_config.isGongZhongHaoAutoLogin=='是'){
|
||||||
if (res.data.value == '是') {
|
that.wxWebInit()
|
||||||
let ua = navigator.userAgent.toLowerCase();
|
}
|
||||||
if (ua.indexOf('micromessenger') !== -1) {
|
|
||||||
let openid = uni.getStorageSync('openId');
|
}else{
|
||||||
let userId = uni.getStorageSync('userId');
|
this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108
|
||||||
if (userId) {
|
if (res.code == 0 && res.data) {
|
||||||
if (!openid) {
|
$cache_config.set('isGongZhongHaoAutoLogin',res.data)
|
||||||
if (window.location.href.indexOf('?code=') !== -1 || window.location.href
|
if (res.data.value == '是') {
|
||||||
.indexOf(
|
that.wxWebInit()
|
||||||
'&code=') !==
|
|
||||||
-1) {
|
|
||||||
let code;
|
|
||||||
if (window.location.href.indexOf('?code=') !== -1) {
|
|
||||||
code = window.location.href.split('?code=')[1].split('&')[0];
|
|
||||||
} else {
|
|
||||||
code = window.location.href.split('&code=')[1].split('&')[0];
|
|
||||||
}
|
|
||||||
if (userId) {
|
|
||||||
that.$u.get('/app/user/openId/' + code + '/' + userId).then(
|
|
||||||
res => {
|
|
||||||
uni.setStorageSync('openId', res.data)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
window.location.href =
|
|
||||||
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
|
|
||||||
that.$queue.getWxAppid() +
|
|
||||||
'&redirect_uri=' +
|
|
||||||
window.location.href.split('#')[0] +
|
|
||||||
'&response_type=code&scope=snsapi_userinfo#wechat_redirect';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
//#endif
|
//#endif
|
||||||
if (uni.getStorageSync('token')) {
|
if (uni.getStorageSync('token')) {
|
||||||
this.getMyLoveVideo()
|
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
|
//新用户红包 837
|
||||||
this.$u.get('/app/common/type/837').then(res => {
|
this.newUserRedInit()
|
||||||
if (res.code == 0 && res.data.value) {
|
|
||||||
this.xxJDNum = res.data.value;
|
|
||||||
this.checkNewUser()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else { //没有登录隐藏悬浮与弹窗
|
} else { //没有登录隐藏悬浮与弹窗
|
||||||
this.showzl = false
|
this.showzl = false
|
||||||
this.shodrag = false
|
this.shodrag = false
|
||||||
@@ -450,7 +416,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
},
|
},
|
||||||
onReachBottom() {
|
onReachBottom() {
|
||||||
if (this.page < this.pages) {
|
if (this.page < this.pages) {
|
||||||
@@ -467,6 +433,78 @@
|
|||||||
this.getCourseList()
|
this.getCourseList()
|
||||||
},
|
},
|
||||||
methods: {
|
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();
|
||||||
|
if (ua.indexOf('micromessenger') !== -1) {
|
||||||
|
let openid = uni.getStorageSync('openId');
|
||||||
|
let userId = uni.getStorageSync('userId');
|
||||||
|
if (userId) {
|
||||||
|
if (!openid) {
|
||||||
|
if (window.location.href.indexOf('?code=') !== -1 || window.location.href
|
||||||
|
.indexOf(
|
||||||
|
'&code=') !==
|
||||||
|
-1) {
|
||||||
|
let code;
|
||||||
|
if (window.location.href.indexOf('?code=') !== -1) {
|
||||||
|
code = window.location.href.split('?code=')[1].split('&')[0];
|
||||||
|
} else {
|
||||||
|
code = window.location.href.split('&code=')[1].split('&')[0];
|
||||||
|
}
|
||||||
|
if (userId) {
|
||||||
|
that.$u.get('/app/user/openId/' + code + '/' + userId).then(
|
||||||
|
res => {
|
||||||
|
uni.setStorageSync('openId', res.data)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.location.href =
|
||||||
|
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
|
||||||
|
that.$queue.getWxAppid() +
|
||||||
|
'&redirect_uri=' +
|
||||||
|
window.location.href.split('#')[0] +
|
||||||
|
'&response_type=code&scope=snsapi_userinfo#wechat_redirect';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
// 获取活动等级
|
// 获取活动等级
|
||||||
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
|
||||||
}
|
}
|
||||||
@@ -620,38 +664,38 @@
|
|||||||
// #ifdef MP-TOUTIAO
|
// #ifdef MP-TOUTIAO
|
||||||
data.dyShow = 1
|
data.dyShow = 1
|
||||||
// #endif
|
// #endif
|
||||||
if(sort==2&&$cache_index.rmVideList){
|
if (sort == 2 && $cache_index.rmVideList) {
|
||||||
this.rmVideList = $cache_index.rmVideList
|
this.rmVideList = $cache_index.rmVideList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(sort==1&&$cache_index.phbVideoList){
|
if (sort == 1 && $cache_index.phbVideoList) {
|
||||||
this.phbVideoList = $cache_index.phbVideoList
|
this.phbVideoList = $cache_index.phbVideoList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(!sort&&$cache_index.newVideList){
|
if (!sort && $cache_index.newVideList) {
|
||||||
this.newVideList = $cache_index.newVideList
|
this.newVideList = $cache_index.newVideList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('请求服务器 获取推荐视频')
|
console.log('请求服务器 获取推荐视频')
|
||||||
this.$Request.getT('/app/course/selectCourse', data).then(res => {
|
this.$Request.getT('/app/course/selectCourse', data).then(res => {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
if (Number(sort) == 2) { //本周热门
|
if (Number(sort) == 2) { //本周热门
|
||||||
this.rmVideList = res.data.list
|
this.rmVideList = res.data.list
|
||||||
$cache_index.set('rmVideList',this.rmVideList)
|
$cache_index.set('rmVideList', this.rmVideList)
|
||||||
} else if (Number(sort) == 1) { //本周排行榜
|
} else if (Number(sort) == 1) { //本周排行榜
|
||||||
this.phbVideoList = res.data.list
|
this.phbVideoList = res.data.list
|
||||||
$cache_index.set('phbVideoList',this.phbVideoList)
|
$cache_index.set('phbVideoList', this.phbVideoList)
|
||||||
} else { //最新热播
|
} else { //最新热播
|
||||||
this.newVideList = res.data.list
|
this.newVideList = res.data.list
|
||||||
$cache_index.set('newVideList',this.newVideList)
|
$cache_index.set('newVideList', this.newVideList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getTypeList() {
|
getTypeList() {
|
||||||
if($cache_index.typeList){
|
if ($cache_index.typeList) {
|
||||||
this.typeList=$cache_index.typeList
|
this.typeList = $cache_index.typeList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
console.log('请求服务器 getTypeList')
|
console.log('请求服务器 getTypeList')
|
||||||
this.$Request.getT('/app/courseClassification/queryClassification').then(res => {
|
this.$Request.getT('/app/courseClassification/queryClassification').then(res => {
|
||||||
@@ -665,9 +709,9 @@
|
|||||||
// res.data.forEach(d => {
|
// res.data.forEach(d => {
|
||||||
// this.typeList.push(d);
|
// this.typeList.push(d);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
this.typeList=[fenlei,...res.data]
|
this.typeList = [fenlei, ...res.data]
|
||||||
$cache_index.set('typeList',this.typeList)
|
$cache_index.set('typeList', this.typeList)
|
||||||
// console.log(JSON.stringify(this.typeList))
|
// console.log(JSON.stringify(this.typeList))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -734,19 +778,19 @@
|
|||||||
},
|
},
|
||||||
//获取背景图
|
//获取背景图
|
||||||
getBgImg() {
|
getBgImg() {
|
||||||
const bgImg=$cache_index.bgImg
|
const bgImg = $cache_index.bgImg
|
||||||
const tuiguang=$cache_index.tuiguang
|
const tuiguang = $cache_index.tuiguang
|
||||||
if(bgImg&&tuiguang){
|
if (bgImg && tuiguang) {
|
||||||
this.bgImg = bgImg
|
this.bgImg = bgImg
|
||||||
this.tuiguang = tuiguang
|
this.tuiguang = tuiguang
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$u.get('app/banner/selectBannerList?classify=5').then(res => {
|
this.$u.get('app/banner/selectBannerList?classify=5').then(res => {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
this.bgImg = res.data[0].imageUrl
|
this.bgImg = res.data[0].imageUrl
|
||||||
this.tuiguang = res.data[0].describes
|
this.tuiguang = res.data[0].describes
|
||||||
$cache_index.set('bgImg',res.data[0].imageUrl)
|
$cache_index.set('bgImg', res.data[0].imageUrl)
|
||||||
$cache_index.set('tuiguang',res.data[0].describes)
|
$cache_index.set('tuiguang', res.data[0].describes)
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
@@ -775,13 +819,13 @@
|
|||||||
// #ifdef MP-TOUTIAO
|
// #ifdef MP-TOUTIAO
|
||||||
data.dyShow = 1
|
data.dyShow = 1
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
if($cache_index.courseList&&this.page==1){
|
if ($cache_index.courseList && this.page == 1) {
|
||||||
this.courseList=$cache_index.courseList
|
this.courseList = $cache_index.courseList
|
||||||
uni.stopPullDownRefresh()
|
uni.stopPullDownRefresh()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$Request.getT('/app/course/selectCourse', data).then(res => {
|
this.$Request.getT('/app/course/selectCourse', data).then(res => {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
this.pages = res.data.totalPage
|
this.pages = res.data.totalPage
|
||||||
@@ -792,7 +836,7 @@
|
|||||||
}
|
}
|
||||||
if (this.page == 1) {
|
if (this.page == 1) {
|
||||||
this.courseList = res.data.list
|
this.courseList = res.data.list
|
||||||
$cache_index.set('courseList',res.data.list)
|
$cache_index.set('courseList', res.data.list)
|
||||||
} else {
|
} else {
|
||||||
this.courseList = [...this.courseList, ...res.data.list]
|
this.courseList = [...this.courseList, ...res.data.list]
|
||||||
}
|
}
|
||||||
@@ -845,9 +889,9 @@
|
|||||||
},
|
},
|
||||||
// 获取金刚区列表
|
// 获取金刚区列表
|
||||||
getGardList() {
|
getGardList() {
|
||||||
if($cache_index.gridList){
|
if ($cache_index.gridList) {
|
||||||
this.gridList=$cache_index.gridList
|
this.gridList = $cache_index.gridList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$u.api.bannerList({
|
this.$u.api.bannerList({
|
||||||
classify: '2',
|
classify: '2',
|
||||||
@@ -860,7 +904,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.gridList = this.processArray(arr)
|
this.gridList = this.processArray(arr)
|
||||||
$cache_index.set('gridList',this.gridList)
|
$cache_index.set('gridList', this.gridList)
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
@@ -956,9 +1000,9 @@
|
|||||||
},
|
},
|
||||||
// 获取轮播图列表
|
// 获取轮播图列表
|
||||||
getBannerList() {
|
getBannerList() {
|
||||||
if($cache_index.swiperList){
|
if ($cache_index.swiperList) {
|
||||||
this.swiperList=$cache_index.swiperList
|
this.swiperList = $cache_index.swiperList
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.$u.api.bannerList({
|
this.$u.api.bannerList({
|
||||||
classify: '1'
|
classify: '1'
|
||||||
@@ -969,7 +1013,7 @@
|
|||||||
this.swiperList.push(d)
|
this.swiperList.push(d)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
$cache_index.set('swiperList',this.swiperList)
|
$cache_index.set('swiperList', this.swiperList)
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.msg,
|
title: res.msg,
|
||||||
|
|||||||
Reference in New Issue
Block a user