123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- <template>
- <view class="home-container">
- <!-- 头部区域 -->
- <top-box v-bind:timeStamp="timeStamp"></top-box>
- <!-- 滚动条 -->
- <view class="notice">
- <u-notice-bar :text="noticeMsg" mode="closable" bgColor="#4169e140" color="#FFF"
- url="/subpkg/mydata/notificationpage"></u-notice-bar>
- </view>
- <!-- 卡片区域 -->
- <view class="card-box">
- <!-- 今日课程 -->
- <view class="card-item" style="width: 100%;">
- <view class="card-info" style="padding-bottom: 20rpx;">
- <view :class="icon.class"></view>
- <text class="info-text">今日课程</text>
- <view style="display: flex; align-items: center;margin: 0 5rpx 0 auto;" @click="navClass" v-if="classCurrent != -1">
- <view class="t-icon t-icon-fenlei"></view>
- <view class="msg" style="font-size: 30rpx; margin-left: 5px;color: #4169E1;">课程列表</view>
- </view>
- </view>
- <todayclass-box :classCurrent="classCurrent"></todayclass-box>
- </view>
- <!-- 今日打卡 -->
- <view class="card-item" style="overflow: hidden;" @click="navCalendar">
- <!-- <view class="card-info" style="padding-bottom: 15rpx;">
- <view class="t-icon t-icon-dakaqiandao"></view>
- <text class="info-text">今日打卡</text>
- </view> -->
- <view class="head-card" :style="{backgroundColor: attendance==='已打卡'?'#4169E1':'#f9c752'}">
- <view class="flex-colum">
- <view style="display: flex;align-items: center; width: 100%;margin-top: 10rpx;">
- <view class="index" :style="{backgroundColor: '#FFF'}"></view>
- <view class="text-content" style="color: #FFF;z-index: 2;">打卡记录</view>
- </view>
- <view class="flex">
- <view class="state-text" style="z-index: 2;">{{attendance}}</view>
- </view>
- </view>
- <view :class="attendance==='已打卡'?'t-icon t-icon-gou1':'t-icon t-icon-cha'"
- style="position: relative;top: -230rpx;left: 180rpx;width: 200rpx;height: 200rpx;z-index: 1;"></view>
- </view>
- <view style="display: flex;align-items: center; width: 100%;">
- <view class="index" :style="{backgroundColor: attendance==='已打卡'?'#4169E1':'#f9c752'}" />
- <view class="text-content">打卡时间</view>
- </view>
- <view class="flex" style="margin-left: 17rpx;">
- <view :class="attendance==='已打卡'?'t-icon t-icon-weizhidaka-dakachenggong':'t-icon t-icon-weizhidaka-dakacuowu'"
- style="width:70rpx;height: 70rpx;"></view>
- <view class="state"
- :style="{backgroundColor: attendance==='已打卡'?'#4169E1':(attendance === '未打卡'?'#f9c752':'#FFF')}">
- <view class="state-text" style="font-size: 40rpx;">{{attendanceTime}}</view>
- </view>
- </view>
- </view>
- <!-- 评测 -->
- <view class="card-item" @click="navHomework(0)">
- <view class="card-info">
- <view :class="icon.evaluation"></view>
- <text class="info-text">今日评测</text>
- </view>
- <view class="charts-box">
- <qiun-data-charts type="arcbar" :chartData="homeData.evaluationArcbar" :loadingType="4"
- :canvas2d='true' canvasId='canvans9313111' :opts="evaluationOpts" />
- </view>
- </view>
- <!-- 作业 -->
- <view class="card-item" @click="navHomework(1)">
- <view class="card-info">
- <view :class="icon.homework"></view>
- <text class="info-text">今日作业</text>
- </view>
- <view class="charts-box">
- <qiun-data-charts type="arcbar" :chartData="homeData.homeworkArcbar" :loadingType="4"
- :canvas2d='true' canvasId='canvans9327676' :opts="homeworkOpts" />
- </view>
- </view>
- <!-- 问卷 -->
- <view class="card-item" @click="navHomework(2)">
- <view class="card-info">
- <view :class="icon.activity"></view>
- <text class="info-text">今日活动</text>
- </view>
- <view class="charts-box">
- <qiun-data-charts type="arcbar" :chartData="homeData.activityArcbar" :loadingType="4"
- :canvas2d='true' canvasId='canvans9313176' :opts="activityOpts" />
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex'
- export default {
- computed: {
- ...mapState('m_chart', ['homeData']),
- ...mapState('m_children', ['classList', 'records']),
- ...mapState('m_parent', ['myData'])
- },
- data() {
- return {
- //滚动通知
- noticeMsg: '',
- //当前课程索引
- classCurrent: '',
- attendance: '',
- attendanceTime: '',
- //属性(不修改)
- //评测进度条属性
- evaluationOpts: {},
- //作业进度条属性
- homeworkOpts: {},
- //活动进度条属性
- activityOpts: {},
- //时间戳
- timeStamp: '',
- //图标
- icon: {
- class: 't-icon t-icon-banji',
- evaluation: 't-icon t-icon-ceping',
- homework: 't-icon t-icon-bianji1',
- activity: 't-icon t-icon-huodong'
- },
- }
- },
- onLoad() {
- this.init()
- },
- onPullDownRefresh() {
- this.init()
- setTimeout(function() {
- uni.stopPullDownRefresh()
- }, 1000);
- },
- methods: {
- //页面方法初始化
- init() {
- this.timeStamp = (new Date()).format("hh:mm")
- this.$initHome()
- this.setOpts()
- this.getNoticeMsg()
- this.getClassCurrent()
- this.getAttendance()
- },
- //获取滚动通知
- getNoticeMsg() {
- this.noticeMsg = `您有 ${this.myData.msgList.length} 个通知,请点击查看`
- },
- //计算出当前课程
- getClassCurrent() {
- //当前时间戳是否在课程时间段内
- function CompareDate(start, finish) {
- //获得当前时间时间戳
- let timeNow = (new Date()).format("yyyy-MM-dd hh:mm").replace(new RegExp("-", "gm"), "/")
- let timeHaoMiao = (new Date(timeNow)).getTime()
- //获得课程开始结束时间戳
- let today = (new Date()).format("yyyy-MM-dd ")
- let classStart = (today + start).replace(new RegExp("-", "gm"), "/")
- let classFinish = (today + finish).replace(new RegExp("-", "gm"), "/")
- let classStartHaoMiao = (new Date(classStart)).getTime()
- let classFinishHaoMiao = (new Date(classFinish)).getTime()
- //比较
- if (timeHaoMiao < classFinishHaoMiao) {
- if (classStartHaoMiao < timeHaoMiao)
- return true
- }
- return false
- }
- //获取当前课程索引值
- let i = 1
- for (let item of this.classList) {
- let timeArr = item.time.split("-")
- let res = CompareDate(timeArr[0], timeArr[1])
- if (res) {
- break
- }
- i++
- }
- //判断是否不在任意一个时间段内
- if (i > this.classList.length) {
- i = -1
- }
- this.classCurrent = i
- i = 0
- },
- //获得今日是否打卡
- getAttendance() {
- //获得当前时间时间戳
- let timeNow = (new Date()).format("yyyy-M-dd")
- let timeArr = timeNow.split("-")
- let info = this.records.filter(x => x.year == timeArr[0] && x.month == timeArr[1] && x.date == timeArr[2])
- if (info.length != 0) {
- this.attendance = '已打卡'
- this.attendanceTime = info[0].time
- } else {
- this.attendance = '未打卡'
- this.attendanceTime = '未记录'
- }
- },
- //设置圆环图描述更新
- setOpts() {
- //圆环图标题和副标题动态变化
- let evaluation = {
- title: {
- name: this.homeData.evaluationArcbar.series[0].data * 100 + "%",
- color: this.homeData.evaluationArcbar.series[0].color
- },
- subtitle: {
- name: this.homeData.evaluationArcbar.series[0].name
- },
- }
- let homework = {
- title: {
- name: this.homeData.homeworkArcbar.series[0].data * 100 + "%",
- color: this.homeData.homeworkArcbar.series[0].color
- },
- subtitle: {
- name: this.homeData.homeworkArcbar.series[0].name
- },
- }
- let activity = {
- title: {
- name: this.homeData.activityArcbar.series[0].data * 100 + "%",
- color: this.homeData.activityArcbar.series[0].color
- },
- subtitle: {
- name: this.homeData.activityArcbar.series[0].name
- },
- }
- this.evaluationOpts = evaluation;
- this.homeworkOpts = homework;
- this.activityOpts = activity;
- },
- //导航
- navHomework(index) {
- uni.reLaunch({
- url: `/pages/homework/homework?index=${index}`
- })
- },
- navCalendar() {
- uni.navigateTo({
- url: '/subpkg/calendar/calendar'
- })
- },
- navClass() {
- uni.navigateTo({
- url: '/subpkg/classlist/classlist'
- })
- },
- },
- }
- </script>
- <style lang="scss">
- @import '@/pages/common/mainpage.scss';
- .head-card {
- height: 200rpx;
- width: 100%;
- border-radius: $card-border-radius;
- background-color: $color-mixblue;
- }
- .flex-colum {
- display: flex;
- flex-direction: column;
- align-items: center;
- height: 100%;
- width: 100%;
- }
- .state {
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 50rpx;
- height: 70rpx;
- width: 210rpx;
- }
- .state-text {
- font-size: 48rpx;
- font-weight: bold;
- color: #FFF;
- }
- .text-content {
- font-size: 30rpx;
- font-weight: bold;
- color: $color-title;
- margin: 20rpx auto 20rpx 15rpx;
- }
- .flex {
- width: 300rpx;
- margin: 10rpx auto 10rpx 15px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .t-icon {
- background-repeat: no-repeat;
- }
- .index {
- height: 30rpx;
- width: 10rpx;
- border-radius: 100rpx;
- margin-left: 30rpx;
- }
- </style>
|