Commit 422ab579 authored by 张伯涛's avatar 张伯涛

课程商城记住筛选项和页面高度

parent 1f1ab8e9
<template> <template>
<div id="app"> <div id="app" @scroll="parentScroll" ref="scrollContainer">
<router-view /> <router-view />
</div> </div>
</template> </template>
...@@ -11,13 +11,36 @@ export default { ...@@ -11,13 +11,36 @@ export default {
name: 'App', name: 'App',
data() { data() {
return { return {
timeout: null timeout: null,
routerPath: ''
}
},
// 监听,当路由发生变化的时候执行
watch: {
$route: {
immediate: true, // 加这个就可以在刷新时也监听到相应页面的路由
handler(val) {
this.routerPath = val.path
if (this.routerPath === '/courseResources/courseMall/index') {
this.$refs.scrollContainer.scrollTop = 1400
}
},
// 深度观察监听
deep: true
} }
}, },
mounted() { mounted() {
this.setupAutoLogoutTimer() // 页面加载时启动监控用户操作 this.setupAutoLogoutTimer() // 页面加载时启动监控用户操作
}, },
methods: { methods: {
parentScroll(event) {
// 获取滚动高度
const scrollHeight = event.target.scrollTop
if (this.routerPath === '/courseResources/courseMall/index') {
this.$store.dispatch('app/setTopE', scrollHeight)
}
},
/** 页面加载时启动监控用户操作*/ /** 页面加载时启动监控用户操作*/
setupAutoLogoutTimer() { setupAutoLogoutTimer() {
// 监听用户操作事件 // 监听用户操作事件
......
...@@ -22,5 +22,6 @@ const getters = { ...@@ -22,5 +22,6 @@ const getters = {
groups: state => state.props.groups, groups: state => state.props.groups,
businessId: state => state.user.businessId, businessId: state => state.user.businessId,
unitUser: state => state.props.unitUser, unitUser: state => state.props.unitUser,
topE: state => state.app.topE
} }
export default getters export default getters
...@@ -6,7 +6,8 @@ const state = { ...@@ -6,7 +6,8 @@ const state = {
withoutAnimation: false withoutAnimation: false
}, },
device: 'desktop', device: 'desktop',
loadingCount: 0 loadingCount: 0,
topE: null
} }
const mutations = { const mutations = {
...@@ -29,6 +30,9 @@ const mutations = { ...@@ -29,6 +30,9 @@ const mutations = {
}, },
SET_LOADING_COUNT: (state, countNum) => { SET_LOADING_COUNT: (state, countNum) => {
state.loadingCount = countNum state.loadingCount = countNum
},
SET_TOP_E: (state, e) => {
state.topE = e
} }
} }
...@@ -44,6 +48,9 @@ const actions = { ...@@ -44,6 +48,9 @@ const actions = {
}, },
setLoadingCount({ commit }, countNum) { setLoadingCount({ commit }, countNum) {
commit('SET_LOADING_COUNT', countNum) commit('SET_LOADING_COUNT', countNum)
},
setTopE({ commit }, e) {
commit('SET_TOP_E', e)
} }
} }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<div> <div>
<nav-list :list="navList" :current-menu="'/courseResources/index'" /> <nav-list :list="navList" :current-menu="'/courseResources/index'" />
<div v-loading="loading" class="courseDetails-content"> <div v-loading="loading" class="courseDetails-content">
<el-button type="primary" @click="handleGoBack">返回</el-button>
<div class="courseCard"> <div class="courseCard">
<img v-if="courseDetails.availableTrialTime === 0" class="guoqiPathClass" :src="guoqiPath" alt=""> <img v-if="courseDetails.availableTrialTime === 0" class="guoqiPathClass" :src="guoqiPath" alt="">
<div class="coursePicture"> <div class="coursePicture">
...@@ -505,6 +506,16 @@ export default { ...@@ -505,6 +506,16 @@ export default {
this.getRecommendCourse() this.getRecommendCourse()
next() next()
}, },
beforeRouteEnter(to, from, next) {
console.log('from',from)
next(vm => {
if (from.path === '/courseResources/courseMall/index') {
localStorage.setItem('backType', '1')
} else if (from.path !== '/') {
localStorage.setItem('backType', '2')
}
})
},
mounted() { mounted() {
const periodElement = this.$refs.period const periodElement = this.$refs.period
if (periodElement) { if (periodElement) {
...@@ -792,6 +803,22 @@ export default { ...@@ -792,6 +803,22 @@ export default {
} else { } else {
this.$message.success('取消收藏成功') this.$message.success('取消收藏成功')
} }
},
/** 返回按钮 backType: 返回类型,1:返回到课程列表页面,并带参。2:直接go-1*/
handleGoBack() {
console.log('33333', this.$route.query)
console.log('44444', localStorage.getItem('backType'))
const backType = localStorage.getItem('backType')
if (backType === '1') {
this.$router.push({
path: '/courseResources/courseMall/index?mallIdentityType=' + this.$route.query.mallIdentityType,
query: {
params: this.$route.query
}
})
} else {
this.$router.go(-1)
}
} }
} }
} }
......
...@@ -107,28 +107,28 @@ ...@@ -107,28 +107,28 @@
<div class="box-top"> <div class="box-top">
<div class="title">综合</div> <div class="title">综合</div>
<div class="search-box"> <div class="search-box">
<!-- <el-checkbox--> <!-- <el-checkbox-->
<!-- v-model="onlyTryToSee"--> <!-- v-model="onlyTryToSee"-->
<!-- size="medium"--> <!-- size="medium"-->
<!-- class="checkbox"--> <!-- class="checkbox"-->
<!-- @change="onlyTryToSeeChose"--> <!-- @change="onlyTryToSeeChose"-->
<!-- >只看试用--> <!-- >只看试用-->
<!-- </el-checkbox>--> <!-- </el-checkbox>-->
<!-- <el-checkbox--> <!-- <el-checkbox-->
<!-- v-model="onlyFree"--> <!-- v-model="onlyFree"-->
<!-- size="medium"--> <!-- size="medium"-->
<!-- class="checkbox"--> <!-- class="checkbox"-->
<!-- @change="onlyFreeChose"--> <!-- @change="onlyFreeChose"-->
<!-- >只看免费--> <!-- >只看免费-->
<!-- </el-checkbox>--> <!-- </el-checkbox>-->
<!-- <el-checkbox--> <!-- <el-checkbox-->
<!-- v-if="$store.getters.token"--> <!-- v-if="$store.getters.token"-->
<!-- v-model="onlyPurchased"--> <!-- v-model="onlyPurchased"-->
<!-- size="medium"--> <!-- size="medium"-->
<!-- class="checkbox"--> <!-- class="checkbox"-->
<!-- @change="onlyPurchasedChose"--> <!-- @change="onlyPurchasedChose"-->
<!-- >只看已购--> <!-- >只看已购-->
<!-- </el-checkbox>--> <!-- </el-checkbox>-->
<el-input <el-input
v-model.trim="queryParams.lessonName" v-model.trim="queryParams.lessonName"
class="search" class="search"
...@@ -352,7 +352,7 @@ export default { ...@@ -352,7 +352,7 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['userId']), ...mapGetters(['userId', 'topE']),
// 是否展示考核相关按钮 // 是否展示考核相关按钮
// 选择岗位能力准入 且 岗位分类 及难度等级均选择特定选项 // 选择岗位能力准入 且 岗位分类 及难度等级均选择特定选项
showExamBtns() { showExamBtns() {
...@@ -389,6 +389,7 @@ export default { ...@@ -389,6 +389,7 @@ export default {
next() next()
}, },
created() { created() {
console.log('createdcreatedcreatedcreatedcreatedcreated',this.queryParams)
this.getCoursePlanOptions() // 获取企业和院校的课程方案 this.getCoursePlanOptions() // 获取企业和院校的课程方案
this.handleToTop() // 一进入页面自动滚动到最顶部 this.handleToTop() // 一进入页面自动滚动到最顶部
this.mallIdentityType = this.$route.query.mallIdentityType || '' this.mallIdentityType = this.$route.query.mallIdentityType || ''
...@@ -415,6 +416,17 @@ export default { ...@@ -415,6 +416,17 @@ export default {
}) })
} }
}, },
beforeRouteEnter(to, from, next) {
next(vm => {
console.log('from', from)
if (from.path === '/courseResources/courseDetails/index') {
setTimeout(() => {
vm.queryParams = JSON.parse(from.query.params)
vm.getCourseByPagination()
}, 1000)
}
})
},
methods: { methods: {
/** 获取企业和院校的课程方案*/ /** 获取企业和院校的课程方案*/
getCoursePlanOptions() { getCoursePlanOptions() {
...@@ -620,10 +632,14 @@ export default { ...@@ -620,10 +632,14 @@ export default {
}, },
// 跳转到课程详情 // 跳转到课程详情
toCourseDetails(param) { toCourseDetails(param) {
console.log('this.scrollTop', this.topE)
this.$router.push({ this.$router.push({
path: '/courseResources/courseDetails/index', path: '/courseResources/courseDetails/index',
query: { query: {
courseId: param.businessId courseId: param.businessId,
params: JSON.stringify(this.queryParams),
height: this.topE,
mallIdentityType: this.mallIdentityType
} }
}) })
} }
......
...@@ -370,7 +370,7 @@ export default { ...@@ -370,7 +370,7 @@ export default {
} }
}).catch(() => { }).catch(() => {
this.loading = false this.loading = false
this.verify = true this.verify = false
if (this.captchaType === 'MATH' || this.captchaType === 'CHAR') { if (this.captchaType === 'MATH' || this.captchaType === 'CHAR') {
this.getCode() this.getCode()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment