123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318 |
- <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;height: 400rpx;" @click="navCalendar">
- <view class="card-info">
- <view class="t-icon t-icon-daka"></view>
- <text class="info-text">今日出勤</text>
- </view>
- <view class="flex" style="flex-direction: column;">
- <!-- 是否打卡 -->
- <view class="flex">
- <view class="index" :style="{backgroundColor: attendance==='已打卡'?'#4169E1':'#f9c752'}"></view>
- <view class="text-content" style="z-index: 2;">打卡记录</view>
- </view>
- <view class="flex">
- <view
- :class="attendance==='已打卡'?'t-icon t-icon-weizhidaka-dakachenggong':'t-icon t-icon-weizhidaka-dakacuowu'"
- style="width:60rpx;height: 60rpx;margin-left: 20rpx;z-index: 2;"></view>
- <view class="text-info" style="margin: 20rpx;">{{attendance}}</view>
- </view>
- <view class="image"
- :style="{backgroundImage: attendance==='已打卡'?`url(${image02})`:`url(${image01})`}"></view>
- <!-- 打卡时间 -->
- <view class="flex">
- <view class="index" :style="{backgroundColor: attendance==='已打卡'?'#4169E1':'#f9c752'}"></view>
- <view class="text-content">打卡时间</view>
- </view>
- <view class="flex">
- <view class="flex" v-if="attendance==='未打卡'" style="align-items: baseline;">
- <view class="text-info" style="margin-left: 30rpx;font-size: 30rpx;">时间</view>
- <view class="text-info">未记录</view>
- </view>
- <view class="flex" v-else style="align-items: baseline;">
- <view class="text-info" style="margin-left: 30rpx;font-size: 30rpx;">上午</view>
- <view class="text-info">{{attendanceTime.split(':')[0].replace('0','')}}</view>
- <view class="text-info" style="font-size: 30rpx;">点</view>
- <view class="text-info">{{attendanceTime.split(':')[1]}}</view>
- <view class="text-info" style="font-size: 30rpx;">分</view>
- </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'
- },
- image01: 'https://ouch-cdn2.icons8.com/2farWQUdLe8J4mb4oQoEvJpl5OFXtM5P7AZi8nhuOxk/rs:fit:912:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvOTYz/L2VkZGEwNzAzLTAw/MWYtNGZiZS1hY2I3/LTVlNjRhZGYzNTAx/Mi5zdmc.png',
- image02: 'https://ouch-cdn2.icons8.com/6CkTSZQdyBYaGiqmNJRhbqoYi8QDcLFn-04VEQyQaCo/rs:fit:962:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvNzMz/LzlhYmUzYjIyLTRl/ZGQtNDVkMi1iYWEw/LTVjYjk2NThmNDJi/OC5zdmc.png'
- }
- },
- 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';
- .flex {
- display: flex;
- align-items: center;
- width: 100%;
- }
- .text-content {
- font-size: 30rpx;
- font-weight: bold;
- color: $color-title;
- margin: 10rpx 0 10rpx 15rpx;
- z-index: 2;
- }
- .text-info {
- margin: 10rpx 0 0 10rpx;
- font-size: 45rpx;
- font-weight: bold;
- color: $color-title;
- z-index: 2;
- }
- .t-icon {
- background-repeat: no-repeat;
- }
- .index {
- height: 30rpx;
- width: 10rpx;
- border-radius: 100rpx;
- margin-left: 30rpx;
- }
- .image {
- position: absolute;
- margin: 20rpx 0 0 50rpx;
- height: 300rpx;
- width: 300rpx;
- background-size: 100%;
- background-repeat: no-repeat;
- opacity: 0.25;
- z-index: 1;
- }
- </style>
|