You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhishifufei_uniapp/pages/learning/index.vue

536 lines
14 KiB

9 months ago
<template>
<BaseContainer class="learning" :fixedNav="false">
<NavBar v-if="scrollTop > 20" title="学习中心" :showBack="false" />
9 months ago
<view v-if="Object.keys(learningData).length > 0" class="learning-box">
9 months ago
<view class="swiper-box">
<swiper class="custom-banner" indicator-dots autoplay @click="handleBannerClick" >
<swiper-item v-for="(item, index) in learningData.banner" :key="index" :data-url="item.url" class="swiper-item">
9 months ago
<image :data-url="item.url" mode="aspectFill" :src="item.pic" :alt="item.title" />
</swiper-item>
</swiper>
</view>
<view class="my-exam flex">
<image :src="getImgPath('/static/frontend/exam-bg.png')" mode="aspectFill"></image>
<view class="exam-left flex">
<view class="exam-name flex">我的考试:
9 months ago
<text @click="changeCate">{{ learningData.exam.name || learningData.exam_list[0].name }}</text>
<image src="@/static/images/learning/change.png" mode="aspectFill" @click="changeCate"></image>
9 months ago
</view>
<view class="exam-time">开考时间:
9 months ago
<text>{{ learningData.exam.date}}</text>
9 months ago
</view>
</view>
<view class="exam-right">
<view class="exam-days-title">距离考试</view>
9 months ago
<view class="exam-days-value"><text>{{ learningData.exam.distance_exam_day }}</text></view>
9 months ago
</view>
</view>
<view class="learning-info flex">
<view class="info-item flex">
<view class="item-title">坚持天数</view>
9 months ago
<view class="item-value"><text style="color: #FF9500;">{{ learningData.user_study.days }}</text></view>
<view class="item-rank">排名:{{ learningData.user_study.rank }}</view>
9 months ago
</view>
<view class="info-item flex">
<view class="item-title">背诵考点</view>
9 months ago
<view class="item-value"><text style="color: #0F74BB;">{{ learningData.user_recite.points }}</text></view>
<view class="item-rank">排名:{{ learningData.user_recite.rank }}</view>
9 months ago
</view>
<view class="info-item flex">
<view class="item-title">刷题正确率</view>
9 months ago
<view class="item-value"><text style="color: #52C794;">{{ learningData.user_brush_questions.accuracy }}</text></view>
<view class="item-rank">排名:{{ learningData.user_brush_questions.rank }}</view>
9 months ago
</view>
</view>
<view class="sign-record">
<view class="record-title content-title">
打卡记录
9 months ago
<text class="more-content" @click="checkRecord">查看 ></text>
9 months ago
</view>
<view class="record-content flex">
<view class="content-left">
9 months ago
<view v-for="(item, index) in learningData.user_clock_in.list">
{{ item.name }} <image src="@/static/images/learning/success.png" mode="aspectFill"></image>
9 months ago
</view>
9 months ago
<view>进度 <view class="progress-bg"><text class="progress" :style="{width: `${learningData.user_clock_in.progress}%` }"></text></view> <text class="progress-percent">{{ learningData.user_clock_in.progress }}%</text> </view>
9 months ago
</view>
9 months ago
<view class="content-right" :style="{ background: learningData.user_clock_in.list.length === 0 ? '#0F74BB' : '' }">{{ learningData.user_clock_in.list.length > 0 ? '已打卡' : '待打卡'}}</view>
9 months ago
</view>
</view>
9 months ago
<view v-for="(item, index) in learningData.exam_list" class="practice flex">
{{ item.name }} <text @click="toPractice(item.id)">开始练习</text>
9 months ago
</view>
<view v-if="learningData.recite && learningData.recite.length > 0" class="tab-container">
9 months ago
<view class="content-title">
背诵过关
9 months ago
<!-- <text class="more-content">更多 ></text> -->
9 months ago
</view>
<view class="flex tab-content">
9 months ago
<view :data-idx="index" class="tab-item" v-for="(item, index) in learningData.recite" :key="item.id" @click="handleReciteClick(item)">
<image :src="item.image" mode="aspectFill"></image>
9 months ago
<view>{{ item.name }}</view>
</view>
</view>
<advert :img="'/static/frontend/learning-advert.png'" :height="140"/>
9 months ago
</view>
<view v-if="learningData.brush_questions && learningData.brush_questions.length > 0" class="tab-container">
9 months ago
<view class="content-title">
刷题过关
9 months ago
<!-- <text class="more-content">更多 ></text> -->
9 months ago
</view>
<view class="flex tab-content">
9 months ago
<view :data-idx="index" class="tab-item" v-for="(item, index) in learningData.brush_questions" :key="item.id" @click="handleQestionClick(item)">
<image :src="item.image" mode="aspectFill"></image>
9 months ago
<view>{{ item.name }}</view>
</view>
</view>
<advert :img="'/static/frontend/learning-advert.png'" :height="140"/>
9 months ago
</view>
<template v-for="(item, index) in indexMenu">
<view v-if="learningData[item.key] && learningData[item.key].length > 0" :key="index" class="special-content">
9 months ago
<view class="content-title">
{{ item.menuName }}
9 months ago
<text class="more-content" @click="toMoreCourse(item.key)">更多 ></text>
9 months ago
</view>
<square-style-course v-if="item.menuName === '视频课'" :specialList="learningData[item.key]" @detail="handleSpecialClick"></square-style-course>
<square-style-course v-if="item.menuName === '直播课'" :specialList="learningData[item.key]" @detail="handleSpecialClick"></square-style-course>
<offline-style-course v-if="item.menuName === '线下课堂'" :specialList="learningData[item.key]"></offline-style-course>
9 months ago
</view>
</template>
</view>
9 months ago
<!-- <message-box title="确认收货?" @submit="console.log('提交')"></message-box> -->
9 months ago
</BaseContainer>
</template>
<script>
import { getLearningData } from '@/api/learning';
9 months ago
import Advert from '@/components/Advert/index.vue';
import SquareStyleCourse from '@/components/Course/squareStyleCourse.vue';
import OfflineStyleCourse from '@/components/Course/offlineStyleCourse.vue';
9 months ago
import MessageBox from '@/components/Message/index.vue';
import store from "@/store";
9 months ago
export default {
components: {
Advert,
SquareStyleCourse,
OfflineStyleCourse,
9 months ago
MessageBox,
9 months ago
},
data() {
return {
loading: false,
indexMenu: [
{ menuName: '视频课', key: 'video' },
{ menuName: '直播课', key: 'live' },
9 months ago
{ menuName: '线下课堂', key: 'offline_courses' },
],
learningData: {},
scrollTop: 0,
9 months ago
};
},
computed: {
position() {
return store.getters.position;
},
},
9 months ago
onShow() {
this.getLearningData();
9 months ago
},
onPageScroll(e) {
this.scrollTop = e.scrollTop;
},
9 months ago
onShareAppMessage() {
return {};
},
onShareTimeline() {
return {};
},
mounted() {
},
methods: {
async getLearningData() {
try {
const { data } = await getLearningData({
city: this.position,
});
console.log(data);
this.learningData = { ...data };
} catch (err) {
console.log(err);
9 months ago
}
},
// 点击轮播图
handleBannerClick(e) {
if (e.target.dataset.url === undefined) return;
uni.navigateTo({
url: e.target.dataset.url,
});
},
9 months ago
checkRecord() {
uni.navigateTo({
9 months ago
url: `/pages/learningCenter/clockRecord?clockDays=${this.learningData.user_study.days}&todayClock=${this.learningData.user_clock_in.list.length > 0}`,
9 months ago
})
},
changeCate() {
// this.$util.checkLogin(() => {
uni.navigateTo({
url: '/pages/store/goodsCate?type=learning'
});
// }, true)
},
toMoreCourse(key) {
if (key === 'offline_courses') {
uni.navigateTo({
9 months ago
url: `/pages/activity/activity_list?gradeId=${this.learningData.exam.gradeId}&subjectId=${this.learningData.exam.subjectId}`
});
} else {
uni.navigateTo({
9 months ago
url: `/pages/special/search?gradeId=${this.learningData.exam.grade_id}&subjectId=${this.learningData.exam.subject_id}&specialType=${ key === 'live' ? 4 : 3}`
})
}
},
9 months ago
handleReciteClick(item) {
uni.navigateTo({
url: `/pages/learningCenter/recite?id=${item.id}`
})
},
handleQestionClick(item) {
uni.navigateTo({
url: `/pages/learningCenter/brushQuestion?id=${item.id}`
})
},
9 months ago
toPractice(id) {
uni.navigateTo({
9 months ago
url: `/pages/special/question_index?id=${id}&is_analysis=${1}`,
9 months ago
});
}
9 months ago
},
};
</script>
<style>
page{
background: #F7F8F9;
}
</style>
<style lang="scss" scoped>
.learning {
background: #F4F4F4;
padding-bottom: 40rpx;
.learning-box {
padding: calc(20rpx + var(--safe-top)) 30rpx 0;
/* #ifdef MP-WEIXIN */
padding: calc(60rpx + var(--safe-top)) 30rpx 0;
/* #endif */
}
.my-exam {
width: 690rpx;
height: 175rpx;
background-color: #F6FBFE;
box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(68,68,68,0.04);
border-radius: 10rpx;
margin: 26rpx auto 0;
background-repeat: no-repeat;
background-position: center right;
background-size: auto 100%;
align-items: center;
padding: 0 36rpx 0 46rpx;
position: relative;
>image {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 0;
width: 301rpx;
height: 175rpx;
}
.exam-left {
height: 100%;
flex-direction: column;
justify-content: center;
font-size: 28rpx;
height: #333;
position: relative;
z-index: 10;
.exam-name {
margin-bottom: 24rpx;
align-items: center;
text {
color: #0F74BB;
}
image {
width: 29rpx;
height: 27rpx;
}
}
text {
margin-right: 8rpx;
margin-left: 20rpx;
}
}
.exam-right {
width: 108rpx;
height: 94rpx;
background: #fff;
box-shadow: 0rpx 5rpx 4rpx 0rpx rgba(68,68,68,0.03);
border-radius: 10rpx;
text-align: center;
margin-left: auto;
position: relative;
z-index: 10;
.exam-days-title {
background: #FF9500;
border-radius: 10rpx 10rpx 20rpx 0rpx;
height: 39rpx;
width: 100%;
line-height: 39rpx;
font-size: 22rpx;
color: #fff;
}
.exam-days-value {
height: 55rpx;
line-height: 55rpx;
color: #FF9A0C;
font-size: 20rpx;
text {
font-size: 30rpx;
}
}
}
}
.learning-info {
width: 690rpx;
height: 234rpx;
background: #fff;
border-radius: 10rpx;
margin: 20rpx auto 0;
padding: 40rpx 30rpx 37rpx 40rpx;
justify-content: space-between;
.info-item {
justify-content: space-between;
flex-direction: column;
.item-title {
color: #333;
font-size: 28rpx;
}
.item-value {
font-size: 20rpx;
color: #999;
text {
font-size: 40rpx;
}
}
.item-rank {
font-size: 24rpx;
color: #666;
}
}
}
.sign-record {
width: 690rpx;
margin: 50rpx auto 0;
.record-content {
margin-top: 30rpx;
width: 100%;
background: #fff;
border-radius: 10rpx;
padding: 0 23rpx 0 30rpx;
justify-content: space-between;
align-items: center;
.content-left {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
padding: 38rpx 0 42rpx;
>view {
display: flex;
align-items: center;
font-size: 28rpx;
&:not(:last-child) {
width: 320rpx;
color: #333;
image {
width: 30rpx;
height: 30rpx;
margin-left: auto;
}
}
&:last-child {
color: #999;
.progress-bg {
position: relative;
background: #f5f5f5;
width: 180rpx;
height: 28rpx;
border-radius: 14rpx;
margin: 0 50rpx 0 10rpx;
.progress {
position: absolute;
top: 0;
left: 0;
height: 28rpx;
border-radius: 14rpx;
background: #FF9500;
}
}
.progress-percent {
color: #FF9500;
}
}
}
}
.content-right {
margin-left: auto;
width: 150rpx;
height: 50rpx;
background: linear-gradient(183deg, #48D9A2, #0CC57F);
border-radius: 25rpx;
color: #fff;
font-size: 28rpx;
text-align: center;
line-height: 50rpx;
}
}
}
.practice {
width: 690rpx;
height: 110rpx;
background-color: #fff;
box-shadow: 0rpx 4rpx 10rpx 0rpx rgba(68,68,68,0.04);
border-radius: 10rpx;
margin: 18rpx auto 0;
align-items: center;
justify-content: space-between;
padding: 0 23rpx 0 29rpx;
font-size: 28rpx;
color: #333;
text {
width: 150rpx;
height: 50rpx;
border-radius: 25rpx;
border: 1px solid #2DD092;
font-size: 28rpx;
color: #28CE8F;
line-height: 50rpx;
text-align: center;
}
}
.tab-container {
margin: 50rpx auto 0;
width: 690rpx;
.tab-content {
margin-top: 30rpx;
background: #fff;
flex-wrap: wrap;
padding-top: 30rpx;
border-radius: 10rpx;
.tab-item {
width: 25%;
font-size: 24rpx;
line-height: 24rpx;
font-weight: 400;
color: #666;
margin-bottom: 50rpx;
display: flex;
flex-direction: column;
align-items: center;
>image {
width: 94rpx;
height: 94rpx;
margin-bottom: 11rpx;
}
>view {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
}
.special-content {
margin-top: 50rpx;
}
.content-title {
padding-left: 23rpx;
position: relative;
color: #333;
font-size: 34rpx;
line-height: 34rpx;
margin-bottom: 33rpx;
&:before {
content: '';
background: linear-gradient(0deg, #24a9e1, #0f74bb);
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
width: 8rpx;
height: 26rpx;
border-radius: 4rpx;
}
.more-content {
position: absolute;
top: 50%;
right: 0;
transform: translateY(-50%);
color: #999;
font-size: 24rpx;
}
}
}
swiper {
/deep/ {
.wx-swiper-dots-horizontal,
.uni-swiper-dots-horizontal {
left: 70%;
bottom: 60rpx;
}
.wx-swiper-dot,
.uni-swiper-dot {
width: 12rpx;
height: 8rpx;
background: #8ab1ff;
border-radius: 4rpx;
float: left;
}
.wx-swiper-dot-active,
.uni-swiper-dot-active {
width: 24rpx;
height: 8rpx;
background: #FFFFFF !important;
border-radius: 4rpx;
}
}
}
.swiper-box {
/* #ifndef MP-TOUTIAO */
height: 306rpx;
/* #endif */
}
.custom-banner {
width: 690rpx;
height: 290rpx;
margin: 0 auto;
overflow: hidden;
}
.swiper-item {
padding: 30rpx 0;
}
.swiper-item image {
width: 100%;
height: 100%;
}
</style>