home.vue 8.5 KB

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