home.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view class="home-container">
  3. <!-- 头部区域 -->
  4. <top-box v-bind:timeStamp="timeStamp"></top-box>
  5. <!-- 滚动条 -->
  6. <view class="notice">
  7. <u-notice-bar :text="noticeMsg" mode="closable" bgColor="#4169e140" color="#FFF"
  8. url="/subpkg/mydata/notificationpage"></u-notice-bar>
  9. </view>
  10. <!-- 卡片区域 -->
  11. <view class="card-box">
  12. <!-- 今日课程 -->
  13. <view class="card-item" style="width: 100%;">
  14. <view class="card-info" style="padding-bottom: 20rpx;">
  15. <view :class="icon.class"></view>
  16. <text class="info-text">今日课程</text>
  17. <view style="display: flex; align-items: center;margin: 0 5rpx 0 auto;" @click="navClass"
  18. v-if="classCurrent != -1">
  19. <view class="t-icon t-icon-fenlei"></view>
  20. <view class="msg" style="font-size: 30rpx; margin-left: 5px;color: #4169E1;">课程列表</view>
  21. </view>
  22. </view>
  23. <todayclass-box :classCurrent="classCurrent"></todayclass-box>
  24. </view>
  25. <!-- 今日打卡 -->
  26. <view class="card-item" style="overflow: hidden;height: 400rpx;" @click="navCalendar">
  27. <view class="card-info">
  28. <view class="t-icon t-icon-daka"></view>
  29. <text class="info-text">今日出勤</text>
  30. </view>
  31. <view class="flex" style="flex-direction: column;">
  32. <!-- 是否打卡 -->
  33. <view class="flex">
  34. <view class="start-tag-isattend" v-if="attendance==='已打卡'"></view>
  35. <view class="start-tag-noattend" v-else></view>
  36. <view class="text-content" style="z-index: 2;">打卡记录</view>
  37. </view>
  38. <view class="flex">
  39. <view
  40. :class="attendance==='已打卡'?'t-icon t-icon-weizhidaka-dakachenggong':'t-icon t-icon-weizhidaka-dakacuowu'"
  41. style="width:60rpx;height: 60rpx;margin-left: 20rpx;z-index: 2;"></view>
  42. <view class="text-info" style="margin: 20rpx;">{{attendance}}</view>
  43. </view>
  44. <view class="image"
  45. :style="{backgroundImage: attendance==='已打卡'?`url(${image02})`:`url(${image01})`}"></view>
  46. <!-- 打卡时间 -->
  47. <view class="flex">
  48. <view class="start-tag-isattend" v-if="attendance==='已打卡'"></view>
  49. <view class="start-tag-noattend" v-else></view>
  50. <view class="text-content">打卡时间</view>
  51. </view>
  52. <view class="flex">
  53. <view class="flex" v-if="attendance==='未打卡'" style="align-items: baseline;">
  54. <view class="text-info" style="margin-left: 30rpx;font-size: 30rpx;">时间</view>
  55. <view class="text-info">未记录</view>
  56. </view>
  57. <view class="flex" v-else style="align-items: baseline;">
  58. <view class="text-info" style="margin-left: 30rpx;font-size: 30rpx;">上午</view>
  59. <view class="text-info">{{attendanceTime.split(':')[0].replace('0','')}}</view>
  60. <view class="text-info" style="font-size: 30rpx;">点</view>
  61. <view class="text-info">{{attendanceTime.split(':')[1]}}</view>
  62. <view class="text-info" style="font-size: 30rpx;">分</view>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 评测 -->
  68. <view class="card-item" @click="navTask(0)">
  69. <view class="card-info">
  70. <view :class="icon.evaluation"></view>
  71. <text class="info-text">今日评测</text>
  72. </view>
  73. <view class="charts-box">
  74. <qiun-data-charts type="arcbar" :chartData="homeData.evaluationArcbar" :loadingType="4"
  75. :canvas2d='true' canvasId='canvans9313111' :opts="evaluationOpts" />
  76. </view>
  77. </view>
  78. <!-- 作业 -->
  79. <view class="card-item" @click="navTask(1)">
  80. <view class="card-info">
  81. <view :class="icon.homework"></view>
  82. <text class="info-text">今日作业</text>
  83. </view>
  84. <view class="charts-box">
  85. <qiun-data-charts type="arcbar" :chartData="homeData.homeworkArcbar" :loadingType="4"
  86. :canvas2d='true' canvasId='canvans9327676' :opts="homeworkOpts" />
  87. </view>
  88. </view>
  89. <!-- 问卷 -->
  90. <view class="card-item" @click="navTask(2)">
  91. <view class="card-info">
  92. <view :class="icon.activity"></view>
  93. <text class="info-text">今日活动</text>
  94. </view>
  95. <view class="charts-box">
  96. <qiun-data-charts type="arcbar" :chartData="homeData.activityArcbar" :loadingType="4"
  97. :canvas2d='true' canvasId='canvans9313176' :opts="activityOpts" />
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. import {
  105. mapState
  106. } from 'vuex'
  107. export default {
  108. computed: {
  109. ...mapState('m_chart', ['homeData']),
  110. ...mapState('m_children', ['classList', 'records']),
  111. ...mapState('m_parent', ['myData'])
  112. },
  113. data() {
  114. return {
  115. //滚动通知
  116. noticeMsg: '',
  117. //当前课程索引
  118. classCurrent: '',
  119. attendance: '',
  120. attendanceTime: '',
  121. //属性(不修改)
  122. //评测进度条属性
  123. evaluationOpts: {},
  124. //作业进度条属性
  125. homeworkOpts: {},
  126. //活动进度条属性
  127. activityOpts: {},
  128. //时间戳
  129. timeStamp: '',
  130. //图标
  131. icon: {
  132. class: 't-icon t-icon-banji',
  133. evaluation: 't-icon t-icon-ceping',
  134. homework: 't-icon t-icon-bianji1',
  135. activity: 't-icon t-icon-huodong'
  136. },
  137. image01: 'https://ouch-cdn2.icons8.com/2farWQUdLe8J4mb4oQoEvJpl5OFXtM5P7AZi8nhuOxk/rs:fit:912:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvOTYz/L2VkZGEwNzAzLTAw/MWYtNGZiZS1hY2I3/LTVlNjRhZGYzNTAx/Mi5zdmc.png',
  138. image02: 'https://ouch-cdn2.icons8.com/6CkTSZQdyBYaGiqmNJRhbqoYi8QDcLFn-04VEQyQaCo/rs:fit:962:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvNzMz/LzlhYmUzYjIyLTRl/ZGQtNDVkMi1iYWEw/LTVjYjk2NThmNDJi/OC5zdmc.png'
  139. }
  140. },
  141. onLoad() {
  142. this.init()
  143. },
  144. onPullDownRefresh() {
  145. this.init()
  146. setTimeout(function() {
  147. uni.stopPullDownRefresh()
  148. }, 1000);
  149. },
  150. methods: {
  151. //页面方法初始化
  152. init() {
  153. this.timeStamp = (new Date()).format("hh:mm")
  154. this.$initHome()
  155. this.setOpts()
  156. this.getNoticeMsg()
  157. this.getClassCurrent()
  158. this.getAttendance()
  159. },
  160. //获取滚动通知
  161. getNoticeMsg() {
  162. this.noticeMsg = `您有 ${this.myData.msgList.length} 个通知,请点击查看`
  163. },
  164. //计算出当前课程
  165. getClassCurrent() {
  166. //当前时间戳是否在课程时间段内
  167. function CompareDate(start, finish) {
  168. //获得当前时间时间戳
  169. let timeNow = (new Date()).format("yyyy-MM-dd hh:mm").replace(new RegExp("-", "gm"), "/")
  170. let timeHaoMiao = (new Date(timeNow)).getTime()
  171. //获得课程开始结束时间戳
  172. let today = (new Date()).format("yyyy-MM-dd ")
  173. let classStart = (today + start).replace(new RegExp("-", "gm"), "/")
  174. let classFinish = (today + finish).replace(new RegExp("-", "gm"), "/")
  175. let classStartHaoMiao = (new Date(classStart)).getTime()
  176. let classFinishHaoMiao = (new Date(classFinish)).getTime()
  177. //比较
  178. if (timeHaoMiao < classFinishHaoMiao) {
  179. if (classStartHaoMiao < timeHaoMiao)
  180. return true
  181. }
  182. return false
  183. }
  184. //获取当前课程索引值
  185. let i = 1
  186. for (let item of this.classList) {
  187. let timeArr = item.time.split("-")
  188. let res = CompareDate(timeArr[0], timeArr[1])
  189. if (res) {
  190. break
  191. }
  192. i++
  193. }
  194. //判断是否不在任意一个时间段内
  195. if (i > this.classList.length) {
  196. i = -1
  197. }
  198. this.classCurrent = i
  199. i = 0
  200. },
  201. //获得今日是否打卡
  202. getAttendance() {
  203. //获得当前时间时间戳
  204. let timeNow = (new Date()).format("yyyy-M-dd")
  205. let timeArr = timeNow.split("-")
  206. let info = this.records.filter(x => x.year == timeArr[0] && x.month == timeArr[1] && x.date == timeArr[2])
  207. if (info.length != 0) {
  208. this.attendance = '已打卡'
  209. this.attendanceTime = info[0].time
  210. } else {
  211. this.attendance = '未打卡'
  212. this.attendanceTime = '未记录'
  213. }
  214. },
  215. //设置圆环图描述更新
  216. setOpts() {
  217. //圆环图标题和副标题动态变化
  218. let evaluation = {
  219. title: {
  220. name: this.homeData.evaluationArcbar.series[0].data * 100 + "%",
  221. color: this.homeData.evaluationArcbar.series[0].color
  222. },
  223. subtitle: {
  224. name: this.homeData.evaluationArcbar.series[0].name
  225. },
  226. }
  227. let homework = {
  228. title: {
  229. name: this.homeData.homeworkArcbar.series[0].data * 100 + "%",
  230. color: this.homeData.homeworkArcbar.series[0].color
  231. },
  232. subtitle: {
  233. name: this.homeData.homeworkArcbar.series[0].name
  234. },
  235. }
  236. let activity = {
  237. title: {
  238. name: this.homeData.activityArcbar.series[0].data * 100 + "%",
  239. color: this.homeData.activityArcbar.series[0].color
  240. },
  241. subtitle: {
  242. name: this.homeData.activityArcbar.series[0].name
  243. },
  244. }
  245. this.evaluationOpts = evaluation;
  246. this.homeworkOpts = homework;
  247. this.activityOpts = activity;
  248. },
  249. //导航
  250. navTask(index) {
  251. if(index === 0){
  252. uni.reLaunch({
  253. url: `/pages/grade/grade`
  254. })
  255. }
  256. if(index === 1){
  257. uni.reLaunch({
  258. url: `/pages/homework/homework`
  259. })
  260. }
  261. if(index === 2){
  262. uni.reLaunch({
  263. url: `/pages/interactive/interactive`
  264. })
  265. }
  266. },
  267. navCalendar() {
  268. uni.navigateTo({
  269. url: '/subpkg/calendar/calendar'
  270. })
  271. },
  272. navClass() {
  273. uni.navigateTo({
  274. url: '/subpkg/classlist/classlist'
  275. })
  276. },
  277. },
  278. }
  279. </script>
  280. <style lang="scss">
  281. @import '@/pages/common/mainpage.scss';
  282. .flex {
  283. display: flex;
  284. align-items: center;
  285. width: 100%;
  286. }
  287. .text-content {
  288. font-size: 30rpx;
  289. font-weight: bold;
  290. color: $color-title;
  291. margin: 10rpx 0 10rpx 15rpx;
  292. z-index: 2;
  293. }
  294. .text-info {
  295. margin: 10rpx 0 0 10rpx;
  296. font-size: 45rpx;
  297. font-weight: bold;
  298. color: $color-title;
  299. z-index: 2;
  300. }
  301. .t-icon {
  302. background-repeat: no-repeat;
  303. }
  304. .start-tag-isattend {
  305. height: 30rpx;
  306. width: 10rpx;
  307. border-radius: 100rpx;
  308. margin-left: 30rpx;
  309. background-image: linear-gradient($color-mixblue 60%, #FFF);
  310. }
  311. .start-tag-noattend {
  312. height: 30rpx;
  313. width: 10rpx;
  314. border-radius: 100rpx;
  315. margin-left: 30rpx;
  316. background-image: linear-gradient($color-yellow 60%, #FFF);
  317. }
  318. .image {
  319. position: absolute;
  320. margin: 20rpx 0 0 50rpx;
  321. height: 300rpx;
  322. width: 300rpx;
  323. background-size: 100%;
  324. background-repeat: no-repeat;
  325. opacity: 0.25;
  326. z-index: 1;
  327. }
  328. </style>