课程和案例本地存储

This commit is contained in:
nisen
2023-08-14 12:27:10 +08:00
parent d895e76979
commit 4b2816e183
3 changed files with 81 additions and 51 deletions

View File

@@ -153,6 +153,10 @@ export default {
goSearch:{
type: Number,
default: 0,
},
keywords:{
type:String,
default:''
}
},
@@ -170,6 +174,14 @@ export default {
}
}
},
watch:{
keywords(newval){
console.log(newval,9999);
if(this.findType == '1'){
this.keyword = newval
}
}
},
data() {
return {
popupConfig:{},

View File

@@ -1073,7 +1073,7 @@ export default {
},
async getCaseData() {
// this.saveLocalFilters();//存储本地刷新有记录
this.saveLocalFilters();//存储本地刷新有记录
let majorTypeList = [];
let allFielclass = JSON.parse(JSON.stringify(this.getAllFielclass()));
// 获取树状id

View File

@@ -1,7 +1,7 @@
<template>
<div id="couser-list-content" class="couser-list-content">
<div class="course-banner">
<portal-header current="course" textColor="#fff" @emitInput="emitInput" @showClass="showClass"></portal-header>
<portal-header current="course" textColor="#fff" :keywords="keyword" @emitInput="emitInput" @showClass="showClass"></portal-header>
</div>
<div style="padding-top:30px">
<div class="xcontent2">
@@ -714,38 +714,38 @@ export default {
// this.toCourseDetail(item);
// this.orderChange(id);
//查询排行榜,页面打开只查询一次
let localKey = "user_" + this.userInfo.sysId + "_gids";
if (this.audiences.length == 0) {
//let hasIds;
let hasIds = sessionStorage.getItem(localKey);
if (hasIds && hasIds.length > 0) {
this.audiences = hasIds.split(",");
this.search();
} else {
apiUserbasic.getInAudienceIds().then(rs => {
if (rs.status == 200) {
this.audiences = rs.result;
sessionStorage.setItem(localKey, this.audiences);
} else {
console.log(rs.message);
}
this.search();
})
// Promise.all([apiOldCourse.audience(this.userInfo.sysId),apiUserGroup.userGroupIds()]).then(rs=>{
// //console.log(rs,'rs');
// let aids=[];
// if(rs[0].status==200){
// aids.push(rs[0].result);
// }
// if(rs[1].status==200){
// aids.push(rs[1].result);
// }
// this.audiences=aids;
// sessionStorage.setItem(localKey,this.audiences);
// let localKey = "user_" + this.userInfo.sysId + "_gids";
// if (this.audiences.length == 0) {
// //let hasIds;
// let hasIds = sessionStorage.getItem(localKey);
// if (hasIds && hasIds.length > 0) {
// this.audiences = hasIds.split(",");
// this.search();
// } else {
// apiUserbasic.getInAudienceIds().then(rs => {
// if (rs.status == 200) {
// this.audiences = rs.result;
// sessionStorage.setItem(localKey, this.audiences);
// } else {
// console.log(rs.message);
// }
// // this.search();
// })
}
}
// // Promise.all([apiOldCourse.audience(this.userInfo.sysId),apiUserGroup.userGroupIds()]).then(rs=>{
// // //console.log(rs,'rs');
// // let aids=[];
// // if(rs[0].status==200){
// // aids.push(rs[0].result);
// // }
// // if(rs[1].status==200){
// // aids.push(rs[1].result);
// // }
// // this.audiences=aids;
// // sessionStorage.setItem(localKey,this.audiences);
// // this.search();
// // })
// }
// }
//this.searchterm();//搜索词已经没有了
this.couresreso();//广告位
@@ -799,22 +799,39 @@ export default {
let hasData = sessionStorage.getItem(this.localSessionKey);
let $this = this;
if (hasData) {
// let typeCodeList=JSON.parse(hasData);
// typeCodeList.forEach(item=>{
// if(item.type==0){
// this.keyword=item.name;
// }else if(item.type==1){
// if(item.id==20){
// $this.ctypeList[0].checked=true;
// }else if(item.id==30){
// $this.ctypeList[1].checked=true;
// }else if(item.id==40){
// $this.ctypeList[2].checked=true;
// }
// }else{ //三级分类的处理,如果一个分类选中多个,显示哪个,显示第一个,是否可以
// }
// })
let typeCodeList=JSON.parse(hasData);
typeCodeList.forEach(item=>{
if(item.type==0){
this.keyword=item.name;
}else if(item.type==1){
if(item.id==20){
$this.ctypeList[0].checked=true;
}else if(item.id==30){
$this.ctypeList[1].checked=true;
}else if(item.id==40){
$this.ctypeList[2].checked=true;
}
}else{ //三级分类的处理,如果一个分类选中多个,显示哪个,显示第一个,是否可以
this.oneList.forEach(one => {
if(one.id == item.id && item.type == '11'){
this.navTitle = [{ ...one }]
one.checked = true
}
one.children.forEach(two => {
if(two.id == item.id && item.type == '12'){
this.navTitle = [{ ...one }, { ...two }]
two.checked = true
}
two.children.forEach(three => {
if(three.id == item.id && item.type == '13'){
this.navTitle = [{ ...one }, { ...two }, { ...three }]
three.checked = true
}
})
})
})
}
})
}
},
//搜索条件
@@ -880,6 +897,7 @@ export default {
this.threeList = [];
this.navTitle = [];
this.newData = false;
sessionStorage.removeItem(this.localSessionKey)
this.searchData();
},
// 导航切换(录播课,线下课,学习项目)
@@ -1057,11 +1075,11 @@ export default {
})
}
$this.oneList.push(newItem);
console.log(newItem);
});
this.loadLocalFilters();
this.search()
}
} catch (error) {
console.log(error);