Commit 41567ed6 authored by zhangyichen's avatar zhangyichen

失败后跳转

parent b22422a0
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
* @type { *[] } * @type { *[] }
*/ */
export const defaultRoutes = [ export const defaultRoutes = [
// // 首页 // 首页
// { {
// path: '/Home', path: '/HomeIndex',
// name: 'Home', name: 'HomeIndex',
// component: (resolve) => require(['@/views/Home'], resolve) component: (resolve) => require(['@/views/HomeIndex'], resolve)
// }, },
{ {
path: '/', path: '/',
name: 'Home', name: 'Home',
......
import router from '@/router' import router from '@/router'
import {getUrlParam} from '@/utils' import {getUrlParam} from '@/utils'
import {getToken, getUserId} from '@/api/test' import {getToken, getUserId} from '@/api/test'
import {sendInfoToJava} from '@/utils/mt-utils'
import store from '@/store' import store from '@/store'
const whiteList = ['/CourseTrainOut', '/CourseTrainOutPotal'] // 不重定向白名单 const whiteList = ['/CourseTrainOut', '/CourseTrainOutPotal','/HomeIndex'] // 不重定向白名单
function getButtons() { function getButtons() {
if (store.state.buttons == null) { if (store.state.buttons == null) {
store.dispatch('GetButtonInfo').then(res => { // 拉取用户信息 store.dispatch('GetButtonInfo').then(res => { // 拉取用户信息
console.log('butonInfo is ok') console.log('butonInfo is ok')
}).catch((err) => { }).catch((err) => {
sendInfoToJava('close') router.replace({
name: 'HomeIndex'
})
console.log(err) console.log(err)
}) })
} else { } else {
...@@ -35,7 +36,9 @@ router.beforeEach((to, from, next) => { ...@@ -35,7 +36,9 @@ router.beforeEach((to, from, next) => {
store.dispatch('GetButtonInfo').then(res => { // 拉取用户信息 store.dispatch('GetButtonInfo').then(res => { // 拉取用户信息
next() next()
}).catch((err) => { }).catch((err) => {
sendInfoToJava('close') router.replace({
name: 'HomeIndex'
})
console.log(err) console.log(err)
}) })
} else { } else {
...@@ -60,7 +63,9 @@ router.beforeEach((to, from, next) => { ...@@ -60,7 +63,9 @@ router.beforeEach((to, from, next) => {
store.dispatch('GetButtonInfo').then(res => { // 拉取用户信息 store.dispatch('GetButtonInfo').then(res => { // 拉取用户信息
next() next()
}).catch((err) => { }).catch((err) => {
sendInfoToJava('close') router.replace({
name: 'HomeIndex'
})
console.log(err) console.log(err)
}) })
} else { } else {
...@@ -68,11 +73,15 @@ router.beforeEach((to, from, next) => { ...@@ -68,11 +73,15 @@ router.beforeEach((to, from, next) => {
console.log('butonInfo is already') console.log('butonInfo is already')
} }
}).catch((err) => { }).catch((err) => {
sendInfoToJava('close') router.replace({
name: 'HomeIndex'
})
console.log(err) console.log(err)
}) })
}).catch((err) => { }).catch((err) => {
sendInfoToJava('close') router.replace({
name: 'HomeIndex'
})
console.log(err) console.log(err)
}) })
} }
...@@ -84,7 +93,9 @@ router.beforeEach((to, from, next) => { ...@@ -84,7 +93,9 @@ router.beforeEach((to, from, next) => {
store.dispatch('GetButtonInfo').then(res => { // 拉取用户信息 store.dispatch('GetButtonInfo').then(res => { // 拉取用户信息
next() next()
}).catch((err) => { }).catch((err) => {
sendInfoToJava('close') router.replace({
name: 'HomeIndex'
})
console.log(err) console.log(err)
}) })
} else { } else {
......
<template> <template>
<nav-bar-view <nav-bar-view
:title="title" :title="'智学'"
:is-hidden-close="isHiddenClose" :is-hidden-close="false"
> >
<template v-slot:right> <div @click="getUserInfo()" class="sign-class-name">
<div class="iconSpan" ref="navBar"> <img src="~@/assets/images/sign_error.png" style="margin-top:200px;width: 200px;height:120px" alt="">
<img id="searchImg" class="search" src="~@assets/images/搜索.png" @click="search"> <div :class="['status-text','fail-color']">
<img class="screen" src="~@assets/images/筛选.png" @click="screen"> {{ '网络连接失败!'}}
</div>
</template>
<div
ref="scollElement"
class="content homeContent"
v-show="!hackReset"
@scroll="scrollEvent"
>
<pull-refresh
v-if="isProhibit"
v-model="isLoading"
@refresh="onRefresh"
>
<template slot="loading">
<img
class="loading-img"
src="@assets/images/下拉loading.svg"
>
</template>
<template slot="loosing">
<img
class="loading-img"
src="@assets/images/下拉loading.svg"
>
</template>
<!--轮播图-->
<div
v-if="swipeList.length !== 0"
class="swipe-box"
style="border-radius: 5px!important;-webkit-appearance: none!important;transform: translateY(0);"
>
<swipe
class="van-swipe-box"
:autoplay="5000"
:loop="true"
:duration="1500"
>
<swipe-item
v-for="(item,index) in swipeList"
:key="index"
@click="bannerClick(item.isExternalLink, index, 'Home')"
>
<van-tag
v-if="item.isPush === '1'"
style="position: absolute;
right: 10px;
top: 10px;
border:1px solid #dfecf85e;
color: #ffffff;">
推荐
</van-tag>
<img
class="swipe-img"
:src="item.imageUrl"
>
</swipe-item>
</swipe>
</div>
<!--分类-->
<div class="classification">
<div class="menuContent">
<router-link :to="{name: 'OnlineExamination', params:{fromName: 'Home'}}">
<div class="menu-wrapper">
<img style="margin-top: 11px" src="~@assets/images/index/exam.png">
<diyTag :num="Number(notStartExamCount)" :type="1"/>
<span>在线考试</span>
</div>
</router-link>
<router-link to="/personalCenter">
<div class="menu-wrapper">
<img style="margin-top: 11px" src="~@assets/images/index/study.png">
<diyTag :num="Number(notStartTrainCount) + Number(notStartLearnCount)" :type="1"/>
<span>我的智学</span>
</div>
</router-link>
<a
v-show="item.type !== '2'"
v-for="(item,index) in zcdshList"
:key="index"
@click="goOutLink({url: item.url, title: item.menuName})"
>
<div class="menu-wrapper">
<img
v-if="item.mobileLogo !== 'mobileLogo'"
class="bossSrc"
style="margin-top: 11px"
:src="item.mobileLogo"
>
<img
v-else
class="bossSrc"
style="margin-top: 11px"
src="~@assets/images/index/Phone.png"
>
<div class="outLineStyle" v-show="item.isPush === '1' && item.type !== '2'">
<img src="~@assets/images/index/iconRecommend.png" style="width: 25px;height: 15px ">
</div>
<span class="title-menuName">{{ item.menuName }}</span>
</div>
</a>
<a
v-if="zcdshList.length == 0"
@click="goOutLink({url:'~@assets/images/index/Phone.png', title: '总裁读书会'})"
>
<div class="menu-wrapper">
<img
class="bossSrc"
style="margin-top: 11px"
src="~@assets/images/index/01_03.png"
>
<span>{{ '总裁读书会' }}</span>
</div>
</a>
</div>
</div>
<!--平台推荐-->
<div
class="column-box"
v-if="platformValue.length > 0"
>
<div class="column-box-title">
<div class="title-left">
<img
class="icon"
style="position: relative;
top: -2.0px;
transform:scale(0.75,0.75);
-webkit-transform:scale(0.75,0.75);
-moz-transform:scale(0.75,0.75)"
src="~@assets/images/index/icon_zhishi.png"
>
<span class="left-nameOne" >知识广场</span>
</div>
<div
class="title-right"
@click="moreClick('知识广场')"
>
<span class="right-name">更多
<diyDot :num="allCountKnow" :type="1"/>
</span>
<img
class="icon"
src="~@assets/images/index/08_10.png"
>
</div>
</div>
<div class="column-box-content">
<div class="colum-container">
<div
class="con-box"
v-for="(item,index) in platformValue"
:key="index"
@click="$curriculumTrainRouter(item.lessonType, item.businessId, 'Home', item.valueConsume, item.lecturerId, item.lessonName)"
>
<curriculum :item="item" />
</div>
</div>
</div>
</div>
<!--企业推荐-->
<div
class="column-box"
v-if="enterprise.length > 0"
>
<div class="column-box-title">
<div class="title-left">
<img
class="icon"
style="position: relative;
top: -2.0px;
transform:scale(1.1,1.1);
-webkit-transform:scale(1.1,1.1);
-moz-transform:scale(1.1,1.1)"
src="~@assets/images/index/04_07.png"
>
<span class="left-name">企业推荐</span>
</div>
<div
class="title-right"
@click="moreClick('企业推荐')"
>
<span class="right-name">更多
<diyDot :num="allCountEnterprise" :type="1"/>
</span>
<img
class="icon"
src="~@assets/images/index/08_10.png"
>
</div>
</div>
<div class="column-box-content">
<div class="colum-container">
<div
class="con-box"
v-for="(item,index) in enterprise"
:key="index"
@click="$curriculumTrainRouter(item.lessonType, item.businessId, 'Home', item.valueConsume, item.lecturerId, item.lessonName)"
>
<curriculum :item="item" />
</div>
</div>
</div>
</div>
<!--大家都在学-->
<div
class="column-box"
v-if="AreLearning.length > 0"
>
<div class="column-box-title">
<div class="title-left">
<img
class="icon"
style="position: relative;
top: -2.0px;
transform:scale(1.1,1.1);
-webkit-transform:scale(1.1,1.1);
-moz-transform:scale(1.1,1.1)"
src="~@assets/images/index/05_07.png"
>
<span class="left-name">大家都在学</span>
</div>
<div
class="title-right"
@click="moreClick('大家都在学')"
>
<span class="right-name">更多
<diyDot :num="allCountStudy" :type="1"/>
</span>
<img
class="icon"
src="~@assets/images/index/08_10.png"
>
</div>
</div>
<div class="column-box-content">
<div class="colum-container">
<div
class="con-box"
v-for="(item,index) in AreLearning"
:key="index"
@click="$curriculumTrainRouter(item.lessonType, item.businessId, 'Home', item.valueConsume, item.lecturerId, item.lessonName)"
>
<curriculum :item="item" />
</div>
</div>
</div>
</div>
<!--最热关注-->
<div
class="column-box"
v-if="HottestConcern.length > 0"
>
<div class="column-box-title">
<div class="title-left">
<img
class="icon"
style="position: relative;
top: -2.0px;
transform:scale(1.1,1.1);
-webkit-transform:scale(1.1,1.1);
-moz-transform:scale(1.1,1.1)"
src="~@assets/images/index/06_07.png"
>
<span class="left-name">最热关注</span>
</div>
<div
class="title-right"
@click="moreClick('最热关注')"
>
<span class="right-name">更多
<diyDot :num="allCountFocus" :type="1"/>
</span>
<img
class="icon"
src="~@assets/images/index/08_10.png"
>
</div>
</div>
<div class="column-box-content">
<div class="colum-container">
<div
class="con-box"
v-for="(item,index) in HottestConcern"
:key="index"
@click="$curriculumTrainRouter(item.lessonType, item.businessId, 'Home', item.valueConsume, item.lecturerId, item.lessonName)"
>
<curriculum :item="item" />
</div>
</div>
</div>
</div>
<!--可能感兴趣的-->
<div
class="column-box"
v-if="BeInterested.length > 0"
>
<div class="column-box-title">
<div class="title-left">
<img
class="icon"
style="position: relative;
top: -2.0px;
transform:scale(1.1,1.1);
-webkit-transform:scale(1.1,1.1);
-moz-transform:scale(1.1,1.1)"
src="~@assets/images/index/07_07.png"
>
<span class="left-name">可能感兴趣的</span>
</div>
<div
class="title-right"
@click="moreClick('可能感兴趣的')"
>
<span class="right-name">更多
<diyDot :num="allCountInterest" :type="1"/>
</span>
<img
class="icon"
src="~@assets/images/index/08_10.png"
>
</div>
</div>
<div class="column-box-content">
<div class="colum-container">
<div
class="con-box"
v-for="(item,index) in BeInterested"
:key="index"
@click="$curriculumTrainRouter(item.lessonType, item.businessId, 'Home', item.valueConsume, item.lecturerId, item.lessonName)"
>
<curriculum :item="item" />
</div>
</div>
</div>
</div>
<!--tab切换-->
<div
class="tabs-box"
v-if="tabsList.length !== 1 || tabsContentList.length !== 0">
<div :class="{'tabs-box-sizing': true,'tabs-position': tabsPosition}">
<tabs
class="v-tabs"
background="#f6f6f6"
title-active-color="#4099f0"
title-inactive-color="#333333"
color="#4099f0"
@click="tabsClick"
:line-width="lineWidth"
ref="vTabs"
>
<tab v-for="(item,index) in tabsList" :title="item.title" :key="index" :name="item.key" ref="vTab">
<template #title>
<span>
{{item.title}}
<diyDot :num="item.newCount" :type="2" style="margin-left: -4px;"/>
</span>
</template>
</tab>
<div v-if="tabsList.length === 1">
<tab v-for="(item,index) in [{},{},{}]" :title="item.title" :key="index" :name="item.key" ref="vTab" disabled>
<template #title>
<span>
{{item.title}}
</span>
</template>
</tab>
</div>
<div v-if="tabsList.length === 2">
<tab v-for="(item,index) in [{},{}]" :title="item.title" :key="index" :name="item.key" ref="vTab" disabled>
<template #title>
<span>
{{item.title}}
</span>
</template>
</tab>
</div>
<div v-if="tabsList.length === 3">
<tab v-for="(item,index) in [{}]" :title="item.title" :key="index" :name="item.key" ref="vTab" disabled>
<template #title>
<span>
{{item.title}}
</span>
</template>
</tab>
</div>
</tabs>
<!-- <tab v-for="(item,index) in tabsList" :title="item.title" :key="index" :name="item.key" ref="vTab"/></tabs>-->
</div>
<div
:class="{'tabs-content-box': true, 'v-list': tabsPosition}"
class="tabs-content-box"
ref="listBox"
>
<list
v-show="!isShow"
:class="{'v-list-loading': true}"
v-model="loading"
:finished="finished"
finished-text="没有更多了"
:immediate-check="check"
@load="onLoad"
ref="list"
>
<div
class="con-box large-con-box"
v-for="(item,index) in tabsContentList"
:key="index"
@click="$curriculumTrainRouter(item.lessonType, item.businessId, 'Home', item.valueConsume, item.lecturerId, item.lessonName)"
>
<curriculum :item="item" />
</div>
</list>
<div
v-if="isShow"
class="tip-block"
>
<img
class="default-img"
src="@assets/images/暂无数据.png"
>
<span>{{ isLoadShow }}</span>
</div>
</div>
</div>
<div
v-if="enterprise.length === 0 && AreLearning.length === 0 && HottestConcern.length === 0 && BeInterested.length === 0 && tabsList.length === 1 && tabsContentList.length === 0"
class="tip-block"
>
<img
class="default-img"
src="@assets/images/暂无数据.png"
>
<span>{{ isLoadShowRecommend }}</span>
</div>
</pull-refresh>
<div
class="tip-block"
v-if="!isProhibit"
>
<img src="~@assets/images/no-auth.png">
<span>很遗憾,您已被禁用,请联系管理员</span>
</div> </div>
</div> </div>
<search-box
ref="searchBox"
:hack-reset="hackReset"
@onCancel="onCancel"
:is-new-count-all="isNewCountAll"
/>
</nav-bar-view> </nav-bar-view>
</template> </template>
<script> <script>
import {sendInfoToJava} from '@/utils/mt-utils'
import NavBarView from '@layouts/NavBarView' import NavBarView from '@layouts/NavBarView'
import {Swipe, SwipeItem, Tab, Tabs, List, PullRefresh, Tag, Icon} from 'vant' import {Icon} from 'vant'
import {get, post, lessonTotal, trainTotal, getNewCount, moreNewCount} from '@/api/test'
import Curriculum from '@/components/Home/curriculum'
import diyTag from '@/components/diyTags/diyTag'
import diyDot from '@/components/diyDot/diyDot'
import SearchBox from '@/components/Search/index'
import {getUrlParam} from '@/utils'
import $ from 'n-zepto'
// import {sendInfoToJava} from '@/utils/mt-utils'
export default { export default {
name: 'Home', name: 'index',
components: { components: {
NavBarView, NavBarView,
Swipe,
SwipeItem,
Curriculum,
Tab,
Tabs,
List,
SearchBox,
PullRefresh,
diyTag,
diyDot,
vanTag: Tag,
vanIcon: Icon vanIcon: Icon
}, },
data() { data() {
return { return {
isLoadShow: '加载中', flag: true
isLoadShowRecommend: '加载中',
isShow: true,
title: '智学',
isLoading: false, // 下拉刷新状态
// 轮播图数组
swipeList: [],
DshUrl: '', // 总裁读书会链接
// 知识广场 数组
platformValue: [],
// 企业推荐 数组
enterprise: [],
// 大家都在学 数组
AreLearning: [],
// 最热关注 数组
HottestConcern: [],
// 可能感兴趣的 数组
BeInterested: [],
// tab标签展示 数组
tabsList: [],
// tabs 列表数组
tabsContentList: [],
check: false,
loading: true,
finished: false,
pageNum: 1000, // tabs 列表 每次展示条数
tabsName: '',
hackReset: false,
tabsPosition: false,
lineWidth: '60px',
zcdshList: [],
isProhibit: true,
isHiddenClose: false, // 是否显示关闭及返回按钮
sourceCnacle: '',
notStartLearnCount: 0, // 我学习的角標數量
notStartTrainCount: 0, // 我报名的角标数量
notStartExamCount: 0, // 在线考试的角标数量
isNewAllCount: 0, // 企业推荐
isNewAllCountLearn: 0, // 大家都在学
isNewAllCountFocus: 0, // 最受关注
isNewAllCountInterest: 0, // 最感兴趣
isNewCountAll: 0,
allCountEnterprise: 0, // 企业推荐更多
allCountFocus: 0, // 最热关注更多
allCountInterest: 0, // 感兴趣更多
allCountKnow: 0, // 知识平台更多
allCountStudy: 0 // 大家都在学更多
}
},
filters: {
// 截取字符串长度
dealWithLength(value, length) {
if (!value || value === '' || value === 'undefined' || $.trim(value) === '') {
return ''
}
if (typeof value === 'number') {
value += ''
}
if (value.length <= length) {
return value
}
if (value.length > length) {
return value.substring(0, length) + '...'
}
} }
}, },
// 组件实例创建前调用 created() {
beforeRouteEnter(to, from, next) {
// console.log(to.path)
// sessionStorage.setItem('toPath', to.path)
// 判断是否被禁用
get.getQueryMenuById({}).then(res => {
next(vm => {
if (res.data.code === 200) {
if (res.data.data.code === 400) {
vm.$refs.navBar.style.display = 'none'
vm.isProhibit = false
} else {
vm.isProhibit = true
}
}
})
})
}, },
methods: { methods: {
// 前往外链 getUserInfo() {
goOutLink(params) { sendInfoToJava('close')
this.$wnsdk.page.open({
url: params.url || params.externalUrl,
needCode: 0,
type: 2,
success(result) {
// 逻辑处理...
},
error(error) {
// 失败处理...
}
})
},
// 初始化登陆信息
simplifyLoginInfo() {
if (sessionStorage.getItem('corpId') !== undefined) {
this.$ss.set('corpId', sessionStorage.getItem('corpId'))
}
if (sessionStorage.getItem('userCode') !== undefined) {
this.$ss.set('userCode', sessionStorage.getItem('userCode'))
}
if (sessionStorage.getItem('userId') !== undefined) {
this.$ss.set('userId', sessionStorage.getItem('userId'))
}
if (localStorage.getItem('task_accessToken') !== undefined) {
this.$ls.set('task_accessToken', localStorage.getItem('task_accessToken'))
}
if (localStorage.getItem('task_refreshToken') !== undefined) {
this.$ls.set('task_refreshToken', localStorage.getItem('task_refreshToken'))
}
// sessionStorage.clear()
},
// 点击搜索 事件
search() {
const that = this
if (that.$route.params.searchFocus !== 'focus') {
document.getElementById('searchInputP').focus()
}
const navBar = document.getElementById('navBar')
navBar.style.display = 'none'
// 重建组件
this.$nextTick(() => {
// 回到页面顶部
// this.$refs.scollElement.scrollIntoView()
that.hackReset = true
setTimeout(() => {
if (that.$route.params.searchContent !== undefined) {
that.$refs.searchBox.backToSearch(that.$route.params.searchContent)
}
delete that.$route.params.searchContent
delete that.$route.params.searchFocus
}, 500)
})
},
// 搜索取消关闭事件
onCancel() {
const navBar = document.getElementById('navBar')
navBar.style.display = 'block'
// 销毁组件
this.hackReset = false
this.tabsPosition = false
this.testMock()
},
// 点击筛选跳转
screen() {
this.$router.push({
name: 'Classification',
params: {
fromName: 'Home'
}
})
},
// 轮播图请求
async testMock() {
const res = await get.getSwipe({
businessId: '',
isExternalLink: '',
lineType: '',
title: ''
})
this.swipeList = res.data.data.rows
},
// 企业推荐请求
async Recommend() {
this.isLoadShowRecommend = '加载中'
const res = await get.getRecommend({
requireId: '',
page: 1,
rows: 5
})
// 遍历 学习人数
res.data.data.rows.map((list) => {
list.personNumber !== '0' && list.personNumber !== '' ? (list.personNumber = list.personNumber + (list.lessonType === '1' ? '人报名' : '人学习')) : list.personNumber = ''
list.comment = ''
})
this.enterprise = res.data.data.rows
let isNewAll = 0
for (let i = 0; i < this.enterprise.length; i++) {
isNewAll += Number(this.enterprise[i].isNew)
}
this.isNewAllCount = isNewAll
this.isLoadShowRecommend = '暂无数据'
},
// 知识广场请求
async Platform() {
this.isLoadShowRecommend = '加载中'
const res = await get.getPlatform({
requireId: '',
page: 1,
rows: 5
})
// 遍历 学习人数
res.data.data.rows.map((list) => {
list.personNumber !== '0' && list.personNumber !== '' ? (list.personNumber = list.personNumber + (list.lessonType === '1' ? '人报名' : '人学习')) : list.personNumber = ''
list.comment = ''
})
this.platformValue = res.data.data.rows
let isNewAll = 0
for (let i = 0; i < this.platformValue.length; i++) {
isNewAll += Number(this.platformValue[i].isNew)
}
this.isNewAllCount = isNewAll
this.isLoadShowRecommend = '暂无数据'
},
// 大家都在学 请求
async everybody() {
this.isLoadShowRecommend = '加载中'
const res = await get.getEverybody({
requireId: '',
page: 1,
rows: 5
})
// 遍历 学习人数和评论人数
res.data.data.rows.map((list) => {
list.personNumber !== '0' && list.personNumber !== '' ? (list.personNumber = list.personNumber + (list.lessonType === '1' ? '人报名' : '人学习')) : list.personNumber = ''
list.discussNumber === '0' || list.discussNumber === '' ? list.comment = '' : list.comment = list.discussNumber + '人评论'
})
this.AreLearning = res.data.data.rows
let isNewAll = 0
for (let i = 0; i < this.AreLearning.length; i++) {
isNewAll += Number(this.AreLearning[i].isNew)
}
this.isNewAllCountLearn = isNewAll
this.isLoadShowRecommend = '暂无数据'
},
// 最热关注 请求
async concern() {
this.isLoadShowRecommend = '加载中'
const res = await get.getConcern({
requireId: '',
page: 1,
rows: 5
})
// 遍历 学习人数和关注人数
res.data.data.rows.map((list) => {
list.collectNumber === '0' || list.collectNumber === '' ? list.collectNumber = '' : list.collectNumber = list.collectNumber + '人关注'
list.personNumber === '0' || list.personNumber === '' ? list.comment = '' : list.comment = list.personNumber + (list.lessonType === '1' ? '人报名' : '人学习')
list.personNumber = list.collectNumber
})
this.HottestConcern = res.data.data.rows
let isNewAll = 0
for (let i = 0; i < this.HottestConcern.length; i++) {
isNewAll += Number(this.HottestConcern[i].isNew)
}
this.isNewAllCountFocus = isNewAll
this.isLoadShowRecommend = '暂无数据'
},
// 可能感兴趣的 请求
async Interested() {
this.isLoadShowRecommend = '加载中'
const res = await get.getInterested({
requireId: '',
page: 1,
rows: 5
})
// 遍历 学习人数和评论人数
res.data.data.rows.map((list) => {
list.personNumber !== '0' && list.personNumber !== '' ? (list.personNumber = list.personNumber + (list.lessonType === '1' ? '人报名' : '人学习')) : list.personNumber = ''
list.discussNumber === '0' || list.discussNumber === '' ? list.comment = '' : list.comment = list.discussNumber + '人评论'
})
this.BeInterested = res.data.data.rows
let isNewAll = 0
for (let i = 0; i < this.BeInterested.length; i++) {
isNewAll += Number(this.BeInterested[i].isNew)
}
this.isNewAllCountInterest = isNewAll
this.isLoadShowRecommend = '暂无数据'
},
// 一级课程分类 请求
async Course() {
this.isLoadShowRecommend = '加载中'
const res = await post.getCourse({
requireId: '',
num: 100
})
const res1 = await get.getHomeBLessons({
courseLevelOne: '',
requireId: '',
departs: [],
viewParam: '',
page: 1,
rows: this.pageNum
})
let sum = 0
for (const items of res1.data.data.rows) {
if (items.isNew === '1') {
sum += 1
}
}
res.data.data.splice(0, 0, {title: '全部分类', key: '', children: '', newCount: sum})
this.tabsList = res.data.data
let isKindNew = 0
for (var i = 0; i < this.tabsList.length; i++) {
isKindNew += Number(this.tabsList[i].newCount)
}
this.isNewKindAll = isKindNew
this.isLoadShowRecommend = '暂无数据'
// 主页面分类上的小圆点 :fanlin
// setTimeout(() => {
// this.tabsList.map((item, index) => {
// console.log(item.title, 'ssssssssssss')
// console.log(document.getElementsByClassName('van-tab')[index].firstChild.lastChild, '2020=================')
// console.log(document.getElementsByClassName('van-tab')[index].firstChild, '2020=====07======04=')
// if (item.title === '全部分类') {
// if (this.isNewKindAll > 0 && this.isNewKindAll <= 3) {
// document.getElementsByClassName('van-tab')[index].firstChild.lastChild.style.background = '#4CC660'
// } else if (this.isNewKindAll > 3 && this.isNewAllCount <= 10) {
// document.getElementsByClassName('van-tab')[index].firstChild.lastChild.style.background = ' #F5AD01'
// } else if (this.isNewKindAll > 10) {
// document.getElementsByClassName('van-tab')[index].firstChild.lastChild.style.background = '#EA5858'
// } else {
// document.getElementsByClassName('van-tab')[index].firstChild.lastChild.style.display = 'none'
// }
// } else {
// if (item.newCount > 0 && item.newCount <= 3) {
// document.getElementsByClassName('van-tab')[index].firstChild.lastChild.style.background = '#4CC660'
// } else if (item.newCount > 3 && item.newCount <= 10) {
// document.getElementsByClassName('van-tab')[index].firstChild.lastChild.style.background = ' #F5AD01'
// } else if (item.newCount > 10) {
// document.getElementsByClassName('van-tab')[index].firstChild.lastChild.style.background = '#EA5858'
// } else {
// document.getElementsByClassName('van-tab')[index].firstChild.lastChild.style.display = 'none'
// }
// }
// })
// }, 100)
},
/**
* tabs 列表查询课程 请求
* courseLevelOne 一级课程分类 ID
*/
async HomeBLessons(courseLevelOne) {
this.isLoadShow = '加载中'
const res = await get.getHomeBLessons({
courseLevelOne: courseLevelOne,
requireId: '',
departs: [],
viewParam: '',
page: 1,
rows: this.pageNum
})
this.isLoadShow = '未筛选到相关数据'
// 遍历 学习人数和评论人数
res.data.data.rows.map((list) => {
list.personNumber !== '0' && list.personNumber !== '' ? (list.personNumber = list.personNumber + (list.lessonType === '1' ? '人报名' : '人学习')) : list.personNumber = ''
list.discussNumber === '0' || list.discussNumber === '' ? list.comment = '' : list.comment = list.discussNumber + '人评论'
})
this.tabsContentList = res.data.data.rows
let isNewCount = 0
for (var i = 0; i < this.tabsContentList.length; i++) {
isNewCount += Number(this.tabsContentList[i].isNew)
}
// this.isNewCountAll = isNewCount
this.tabsContentList.length > 0 ? this.isShow = false : this.isShow = true
// 加载状态结束
this.loading = false
// 数据全部加载完成
if (this.pageNum > res.data.data.total) {
this.finished = true
}
},
// tab标签切换事件
tabsClick(name, title) {
if (title === '全部分类') {
name = ''
}
this.lineWidth = (title.length > 5 ? 5 : title.length) * 15 + 'px'
this.finished = false // 重置 数据加载状态
this.tabsName = name
this.pageNum = 1000
this.tabsContentList = []
this.$nextTick(() => {
this.HomeBLessons(name)
})
},
// 上拉触底 异步加载tabs内容
onLoad() {
this.pageNum = this.pageNum + 4
// // 异步更新数据
this.HomeBLessons(this.tabsName)
},
// 点击更多 事件
moreClick(title) {
this.$router.push({
name: 'More',
params: {
title: title,
fromName: 'Home'
}
})
},
// handleScroll() {
// console.log(0)
// const height = document.body.clientHeight - window.innerHeight, // 页面滚动条高度
// scrollTop =
// window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop, // 滚动条距离顶部高度
// listTop = this.$refs.listBox.getBoundingClientRect().top, // list课程组件 距离页面顶部高度
// fixedTop = this.$refs.navBar.offsetHeight + this.$refs.vTabs._vnode.elm.scrollHeight + 10 // list组件距离顶部高度定位条件
// if (listTop <= fixedTop) {
// this.tabsPosition = true
// } else {
// this.tabsPosition = false
// }
// if (!this.finished) {
// if (scrollTop >= height) {
// this.loading = true
// this.pageNum = this.pageNum + 4
// // 异步更新数据
// this.HomeBLessons(this.tabsName)
// }
// }
// },
// 监听页面元素滚动 事件
scrollEvent() {
const listTop = this.$refs.listBox.getBoundingClientRect().top, // list课程组件 距离页面顶部高度
fixedTop = this.$refs.navBar.offsetHeight + this.$refs.vTabs._vnode.elm.scrollHeight + 15, // list组件距离顶部高度定位条件
clientHeight = document.documentElement.clientHeight - listTop// 页面可视区域高度
if (listTop <= fixedTop) {
this.tabsPosition = true
} else {
this.tabsPosition = false
this.$refs.listBox.style.minHeight = clientHeight + 15 + 'px'
}
},
/**
* 轮播图点击 事件
* isExternalLink 1:外部内容 0:内部课程、培训
* index 索引值
* lineType 0:线上课程 1:线下培训
*/
bannerClick(isExternalLink, index) {
if (isExternalLink === '0') {
if (this.swipeList[index].lineType === '0') {
this.$router.push({
name: 'CourseDetail',
query: {
id: this.swipeList[index].courseId
}
})
} else {
this.$router.push({
name: 'TrainDetail',
query: {
id: this.swipeList[index].courseId,
fromName: 'Home',
role: 'people'
}
})
}
} else {
this.goOutLink(this.swipeList[index])
}
},
// 总裁读书会 请求
async queryMenuById() {
const res = await get.getQueryMenuById({
requireId: '',
modelId: 10,
type: 0
})
this.zcdshList = res.data.data
// res.data.data.map((list) => {
// if (list.type === 'DSH') {
// this.DshUrl = list.value
// }
// })
},
// 下拉刷新事件
onRefresh() {
setTimeout(() => {
this.isLoading = false
this.testMock()
this.Recommend()
this.Platform()
this.everybody()
this.concern()
this.Interested()
this.HomeBLessons(this.tabsName)
this.queryMenuById()
this.Course()
}, 500)
}
},
mounted() {
this.allCount = localStorage.getItem('key')
// 进入后强制竖屏
this.$wnsdk.device.setOrientation({type: 1,
success(res) {
},
error(err) {
console.log(err)
}})
this.simplifyLoginInfo()
this.testMock()
this.Recommend()
this.Platform()
this.everybody()
this.concern()
this.Interested()
this.Course()
this.HomeBLessons(this.tabsName)
this.queryMenuById()
window.addEventListener('scroll', this.handleScroll)
this.$setgoindex()
if (this.$route.params.searchFocus && this.$route.params.searchFocus === 'focus') {
document.getElementById('searchImg').click()
} }
if (getUrlParam('isHiddenClose') === '1') {
this.isHiddenClose = true
sessionStorage.setItem('isHiddenCloseAll', '1')
} else {
sessionStorage.setItem('isHiddenCloseAll', '0')
}
// 调用总数接口获取我的学习未开始的数量
lessonTotal({}).then(res => {
this.notStartLearnCount = res.data.data.notStartCount
console.log(this.notStartCount, '//////////////////')
})
// 调用总数接口获取我的培训未开始的数量
trainTotal({}).then(res => {
this.notStartTrainCount = res.data.data.notStartCount
console.log(this.notStartCount, '//////////////////')
})
// 调用总数接口获取在线考试未开始的数量
getNewCount({
u: sessionStorage.getItem('userId'),
t: 1,
c: sessionStorage.getItem('corpId')}).then(res => {
this.notStartExamCount = res.data
console.log(this.notStartExamCount, '//////////////////')
})
// 调用更多总数接口获取在数量
moreNewCount({}).then(res => {
this.allCountEnterprise = res.data.data.recommend
this.allCountInterest = res.data.data.interest
this.allCountFocus = res.data.data.collect
this.allCountStudy = res.data.data.learn
this.allCountKnow = res.data.data.push
})
},
watch: {
},
destroyed() {
window.removeEventListener('scroll', this.handleScroll, false)
} }
} }
</script> </script>
<style lang="less"> <style scoped>
/*.content .tabs-box-sizing .van-info--dot {*/ .sign-class-name{
/* margin-top: 2px !important;*/ font-weight:544 ;
/* right: -6px !important;*/ font: 16px MicrosoftYaHei;
/*}*/ color: #999999;
.v-tabs .van-ellipsis { margin-top: 37.5px;
overflow: unset;
// white-space: nowrap;
text-overflow: inherit;
}
.tabs-box .v-tabs .van-tab {
min-width: auto;
width: auto;
/*flex-basis: 22%;*/
// margin-right: 0px;
}
.search-box .tabs-box .van-tabs__line{
display: none;
}
.van-swipe-box .van-tag--default{
background: #1112135e;
}
</style>
<style lang="less" scoped>
/*隐藏横向滚动条*/
.content::-webkit-scrollbar {
width:0;
height:0;
display: none;
} }
.content{ .status-text{
height: calc(100vh - @nav-bar-height); font-size: 18px;
/*padding-top: 10px;*/ margin-top: 32px;
background: #ffffff;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
.swipe-box{
-webkit-appearance: none;
width: calc(100% - 35px);
height: 129px;
margin: 10px auto 0 auto;
overflow: hidden;
border-radius: 5px;
/*padding-top: 10px;*/
.van-swipe-box{
-webkit-appearance: none;
width: 100%;
height: 100%;
border-radius: 5px;
overflow: hidden;
.van-swipe-item{
-webkit-appearance: none;
width: 100%;
height: 100%;
/*border-radius: 5px;*/
overflow: hidden;
.swipe-img{
-webkit-appearance: none;
width: 100%;
height: 100%;
/*margin-left: -5px;*/
/*border-radius: 5px;*/
}
}
}
}
.classification::-webkit-scrollbar{
width:0;
height:0;
display: none;
}
.classification{
/*justify-content: space-around;*/
/*-webkit-justify-content: space-around;*/
margin: 20px 0 20px 0;
height: 86px;
overflow: hidden;
.menuContent {
display: flex;
display: -webkit-flex;
height: 100%;
padding-bottom: 16px;
overflow-y: hidden;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
& > a {
margin-right: 52px;
& > div {
width: 70px;
& > img {
vertical-align: bottom;
width: 44px;
height: 44px;
border-radius: 50%;
position: relative;
// top: 9px;
}
& > span {
display: block;
margin-top: 10px;
font-size: 14px;
color: #333333;
}
}
.menu-wrapper {
overflow-x: inherit;
position: relative;
// padding-top: 2px;
img {
margin-top: 2px;
}
}
}
& > a:first-child {
margin-left: 30px;
}
& > a:last-child {
padding-right: 30px;
margin-right: 0;
}
}
}
.column-box{
margin-bottom: 30px;
.column-box-title{
width: calc(100% - 30px);
margin: 0 auto;
display: flex;
justify-content: space-between;
.title-left{
.icon{
vertical-align: bottom;
width: 20px;
height: 20px;
}
.left-name{
margin-left: 3px;
font-size: 16px;
font-weight: bold;
color: #333333;
}
.left-nameOne{
margin-left: 4px;
font-size: 16px;
font-weight: bold;
color: #333333;
}
}
.title-right{
.icon{
vertical-align: middle;
width: 12px;
height: 12px;
}
.right-name{
margin-right: 6px;
font-size: 12px;
color: #999999;
}
}
}
.column-box-content{
width: calc(100% - 15px);
height: 143px;
margin-left: 15px;
margin-top: 16px;
display: flex;
overflow: hidden;
-webkit-overflow-scrolling: touch;
.colum-container{
width: 100%;
overflow-x: auto;
overflow-y: hidden;
-webkit-overflow-scrolling: touch;
display: flex;
height: 143px;
padding-bottom: 20px;
}
.con-box:last-child{
/deep/.curriculum{
.con-img{
margin-right: 15px;
}
}
}
}
/*隐藏横向滚动条*/
.column-box-content::-webkit-scrollbar {
-webkit-appearance: none;
-moz-appearance: none;
width:0;
height:0;
display: none;
}
}
.tabs-box{
.van-tab--active {
color: #323233;
font-weight: bold ;
}
/*padding-top: 15px;*/
.tabs-box-sizing{
width: 100%;
z-index: 999;
}
.tabs-position{
position: fixed;
top: @nav-bar-height;
}
.tabs-content-box{
width: calc(100% - calc(100% - 345px));
/*padding-top: 15px;*/
margin: 15px auto 0 auto;
.van-list{
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
}
.v-list{
margin-top: calc(@nav-bar-height + 54px);
}
}
.tip-block {
margin-top: 50%;
img {
display: block;
width: 186.5px;
height: 110px;
margin: 0 auto;
}
span {
display: inline-block;
white-space: nowrap;
margin-top: 44px;
font-size:14px;
font-family:Microsoft YaHei;
font-weight:400;
color:rgba(153,153,153,1);
line-height:48px;
}
}
} }
.bossSrc{ .fail-color{
width: 50px; color: #333333;
height: 50px; font-weight: bold;
border-radius: 50%;
} }
/**{*/
/*scrollbar-3dlight-color:#fff; !*3d亮色阴影边框(threedlightshadow)的外观颜色*!*/
/*scrollbar-highlight-color:#fff; !*滚动条3d高亮边框(threedhighlight)的外观颜色*!*/
/*scrollbar-arrow-color:#fff; !*滚动条方向箭头的颜色*!*/
/*scrollbar-shadow-color:#fff; !*滚动条方向箭头的颜色*!*/
/*scrollbar-darkshadow-color:#fff; !*滚动条3d暗色阴影边框(threeddarkshadow)的外观颜色*!*/
/*scrollbar-base-color:#fff; !*滚动条基准颜色*!*/
/*scrollbar-track-color:#fff; !*滚动条拖动区域的外观颜色*!*/
/*}*/
/*::-webkit-scrollbar {*/
/*width: 0 !important;*/
/*}*/
/*::-webkit-scrollbar {*/
/*width: 0 !important;*/
/*height: 0;*/
/*}*/
/*::-webkit-scrollbar {*/
/*display: none;!*隐藏滚轮*!*/
/*}*/
</style> </style>
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