home.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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="rgba(73, 125, 220, 0.25)" color="#FFF"
  8. url="/subpkg/mymsg/mymsg"></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: 5rpx;">
  15. <view :class="icon.class"></view>
  16. <text class="info-text">今日课程</text>
  17. </view>
  18. <todayclass-box :classCurrent="classIndex"></todayclass-box>
  19. </view>
  20. <!-- 今日打卡 -->
  21. <view class="card-item" @click="navCalendar">
  22. <view class="card-info">
  23. <view :class="icon.record"></view>
  24. <text class="info-text">今日打卡</text>
  25. </view>
  26. <view class="space">
  27. <view class="home-title-text">
  28. <view class="msg">今日出勤:</view>
  29. <view class="card-content">{{homeData.attendance}}</view>
  30. </view>
  31. <view class="home-title-text">
  32. <view class="msg">打卡时间:</view>
  33. <view style="margin-left: 10rpx;">
  34. <!-- <u-tag text="8点15分" plain shape="circle"></u-tag> -->
  35. <view style="display: flex; align-items: center; margin-left: 10rpx;">
  36. <view class="number-box">{{homeData.attendanceTimeAfter[0]}}</view>
  37. <view style="color: #3C9CFF;">:</view>
  38. <view class="number-box">{{homeData.attendanceTimeAfter[1]}}</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="home-title-text">
  43. <view class="msg">本周出勤质量:</view>
  44. <view class="card-content">{{homeData.attendanceQuality}}</view>
  45. </view>
  46. </view>
  47. </view>
  48. <!-- 评测 -->
  49. <view class="card-item" @click="navHomework(0)">
  50. <view class="card-info">
  51. <view :class="icon.evaluation"></view>
  52. <text class="info-text">今日评测</text>
  53. </view>
  54. <view class="charts-box">
  55. <qiun-data-charts type="arcbar" :chartData="todayData.evaluationArcbar" :loadingType="4"
  56. :canvas2d='true' canvasId='canvans9313111' :opts="evaluationOpts" />
  57. </view>
  58. </view>
  59. <!-- 作业 -->
  60. <view class="card-item" @click="navHomework(1)">
  61. <view class="card-info">
  62. <view :class="icon.homework"></view>
  63. <text class="info-text">今日作业</text>
  64. </view>
  65. <view class="charts-box">
  66. <qiun-data-charts type="arcbar" :chartData="todayData.homeworkArcbar" :loadingType="4"
  67. :canvas2d='true' canvasId='canvans9327676' :opts="homeworkOpts" />
  68. </view>
  69. </view>
  70. <!-- 问卷 -->
  71. <view class="card-item" @click="navHomework(2)">
  72. <view class="card-info">
  73. <view :class="icon.activity"></view>
  74. <text class="info-text">今日活动</text>
  75. </view>
  76. <view class="charts-box">
  77. <qiun-data-charts type="arcbar" :chartData="todayData.activityArcbar" :loadingType="4"
  78. :canvas2d='true' canvasId='canvans9313176' :opts="activityOpts" />
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import {
  86. mapState
  87. } from 'vuex'
  88. export default {
  89. computed: {
  90. ...mapState('m_chart', ['todayData']),
  91. ...mapState('m_children', ['childreninfo', 'classList']),
  92. ...mapState('m_parent', ['myData'])
  93. },
  94. data() {
  95. return {
  96. //滚动通知
  97. noticeMsg: '',
  98. //当前课程索引
  99. classIndex: '',
  100. //首页数据
  101. homeData: {
  102. //出勤状况
  103. attendance: '已打卡',
  104. //打卡时间
  105. attendanceTime: '08:15',
  106. //处理后时间
  107. attendanceTimeAfter: [],
  108. //出勤质量
  109. attendanceQuality: '优秀'
  110. },
  111. //属性(不修改)
  112. //图标
  113. icon: {
  114. record: 't-icon t-icon-dakaqiandao',
  115. class: 't-icon t-icon-banji',
  116. evaluation: 't-icon t-icon-ceping',
  117. homework: 't-icon t-icon-bianji1',
  118. activity: 't-icon t-icon-huodong'
  119. },
  120. //评测进度条属性
  121. evaluationOpts: {},
  122. //作业进度条属性
  123. homeworkOpts: {},
  124. //活动进度条属性
  125. activityOpts: {},
  126. //时间戳
  127. timeStamp: '',
  128. }
  129. },
  130. onLoad() {
  131. this.setOpts()
  132. this.$getTimeStamp()
  133. this.getNoticeMsg()
  134. this.getClassCurrent()
  135. this.getAttendanceTimeAfter()
  136. },
  137. onPullDownRefresh() {
  138. this.$getTimeStamp()
  139. this.getClassCurrent()
  140. console.log('refresh')
  141. setTimeout(function() {
  142. uni.stopPullDownRefresh()
  143. }, 1000);
  144. },
  145. methods: {
  146. //获取滚动通知
  147. getNoticeMsg() {
  148. this.noticeMsg = `您有 ${this.myData.msgList.length} 个通知,请点击查看`
  149. },
  150. //计算当前课程
  151. getClassCurrent() {
  152. //当前时间戳是否在课程时间段内
  153. function CompareDate(start, finish) {
  154. //获得当前时间时间戳
  155. let timeNow = (new Date()).format("yyyy-MM-dd hh:mm").replace(new RegExp("-", "gm"), "/")
  156. let timeHaoMiao = (new Date(timeNow)).getTime()
  157. //获得课程开始结束时间戳
  158. let today = (new Date()).format("yyyy-MM-dd ")
  159. let classStart = (today + start).replace(new RegExp("-", "gm"), "/")
  160. let classFinish = (today + finish).replace(new RegExp("-", "gm"), "/")
  161. let classStartHaoMiao = (new Date(classStart)).getTime()
  162. let classFinishHaoMiao = (new Date(classFinish)).getTime()
  163. //比较
  164. if (timeHaoMiao < classFinishHaoMiao) {
  165. if (classStartHaoMiao < timeHaoMiao)
  166. return true
  167. }
  168. return false
  169. }
  170. //获取当前课程索引值
  171. let i = 1
  172. for (let item of this.classList) {
  173. let timeArr = item.time.split("-")
  174. let res = CompareDate(timeArr[0], timeArr[1])
  175. if (res) {
  176. break
  177. }
  178. i++
  179. }
  180. this.classIndex = i
  181. i = 0
  182. },
  183. //处理打卡时间
  184. getAttendanceTimeAfter(){
  185. this.homeData.attendanceTimeAfter = this.homeData.attendanceTime.split(':')
  186. },
  187. navHomework(index) {
  188. uni.reLaunch({
  189. url: `/pages/homework/homework?index=${index}`
  190. })
  191. },
  192. navCalendar() {
  193. uni.navigateTo({
  194. url: '/subpkg/calendarmsg/calendarmsg'
  195. })
  196. },
  197. //设置圆环图描述更新
  198. setOpts() {
  199. //圆环图标题和副标题动态变化
  200. let evaluation = {
  201. title: {
  202. name: this.todayData.evaluationArcbar.series[0].data * 100 + "%",
  203. color: this.todayData.evaluationArcbar.series[0].color
  204. },
  205. subtitle: {
  206. name: this.todayData.evaluationArcbar.series[0].name
  207. },
  208. extra: {
  209. arcbar: {
  210. type: 'circle'
  211. }
  212. }
  213. }
  214. let homework = {
  215. title: {
  216. name: this.todayData.homeworkArcbar.series[0].data * 100 + "%",
  217. color: this.todayData.homeworkArcbar.series[0].color
  218. },
  219. subtitle: {
  220. name: this.todayData.homeworkArcbar.series[0].name
  221. },
  222. extra: {
  223. arcbar: {
  224. type: 'circle'
  225. }
  226. }
  227. }
  228. let activity = {
  229. title: {
  230. name: this.todayData.activityArcbar.series[0].data * 100 + "%",
  231. color: this.todayData.activityArcbar.series[0].color
  232. },
  233. subtitle: {
  234. name: this.todayData.activityArcbar.series[0].name
  235. },
  236. extra: {
  237. arcbar: {
  238. type: 'circle'
  239. }
  240. }
  241. }
  242. this.evaluationOpts = evaluation;
  243. this.homeworkOpts = homework;
  244. this.activityOpts = activity;
  245. },
  246. },
  247. }
  248. </script>
  249. <style lang="scss">
  250. @import '@/pages/common/mainpage.scss';
  251. .number-box {
  252. width: 40rpx;
  253. height: 40rpx;
  254. border-radius: 8rpx;
  255. background-color: #3C9CFF;
  256. color: #FFF;
  257. padding: 5rpx;
  258. margin: 5rpx;
  259. display: flex;
  260. justify-content: center;
  261. align-items: center;
  262. }
  263. .space {
  264. height: 100%;
  265. width: 100%;
  266. display: flex;
  267. flex-direction: column;
  268. justify-content: space-around;
  269. }
  270. </style>