tab_home.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. <template>
  2. <view>
  3. <view v-if="!isHomeLoad">
  4. <loading></loading>
  5. </view>
  6. <view class="page-view" v-if="isHomeLoad">
  7. <!-- 成绩统计 -->
  8. <view class="bg1">
  9. <view class="circle-line1"></view>
  10. <view class="circle-line2"></view>
  11. <view class="circle-line3"></view>
  12. <top-info :timeStamp="timeStamp"></top-info>
  13. <scroll-view class="scroll-view" scroll-x="true" :scroll-with-animation="true" scroll-left="0">
  14. <view class="view-box">
  15. <view class="scroll-view-item" v-for="(item,index) in cardList" :key="index"
  16. @click="navTab(index)">
  17. <view class="card-info">
  18. <view :class="item.icon"></view>
  19. <view class="title">{{item.title}}</view>
  20. </view>
  21. <view class="chart-box">
  22. <qiun-data-charts type="arcbar" :chartData="item.data" :canvas2d='true'
  23. :canvasId='item.canvasId' :opts="item.chartOpts" />
  24. </view>
  25. </view>
  26. </view>
  27. </scroll-view>
  28. </view>
  29. <!-- 通知 -->
  30. <view class="bg2">
  31. <view class="notice">
  32. <u-notice-bar :text="noticeData" bgColor="rgba(65,105,225,0.4)" color="#FFF"
  33. url="/subpkg/mine/msgList"></u-notice-bar>
  34. </view>
  35. </view>
  36. <!-- 课程 -->
  37. <view class="card-view">
  38. <!-- 今日课程模块 -->
  39. <view class="card-item" style="width: 100%;" v-if="classCurrent != -1">
  40. <view class="card-title">
  41. <view class="front-tag"></view>
  42. <view class="title">今日课程</view>
  43. <view class="flex-row" style="margin: 0 0 0 auto;" @click="navClassList">
  44. <view class="t-icon t-icon-fenlei"></view>
  45. <view class="title" style="color: #4169E1;margin-left: 10rpx;">课程列表</view>
  46. </view>
  47. </view>
  48. <view class="data-list">
  49. <!-- 上上节 -->
  50. <view class="data-item" v-if="classCurrent === classList.length">
  51. <view class="flex-row">
  52. <view class="t-icon t-icon-classicon-copy" style="width: 60rpx; height: 60rpx;"></view>
  53. <view class="flex-column">
  54. <view class="row-margin">
  55. <view class="item-title">{{classList[classCurrent - 3].title}}</view>
  56. <view class="tag">
  57. <view class="tag-text">{{classList[classCurrent - 3].name}}</view>
  58. </view>
  59. <view class="tag">
  60. <view class="tag-text">{{classList[classCurrent - 3].teacher}}</view>
  61. </view>
  62. </view>
  63. <view class="row-margin">
  64. <view class="item-subtitle">上节</view>
  65. <view class="item-detail">
  66. {{classList[classCurrent - 3].time}}
  67. </view>
  68. </view>
  69. </view>
  70. <view class="state">
  71. <view class="state-text">{{classList[classCurrent - 3].attendance?'已出勤':'未出勤'}}
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 上节 -->
  77. <view class="data-item" v-if="classCurrent >= 2">
  78. <view class="flex-row">
  79. <view class="t-icon t-icon-classicon-copy" style="width: 60rpx; height: 60rpx;"></view>
  80. <view class="flex-column">
  81. <view class="row-margin">
  82. <view class="item-title">{{classList[classCurrent - 2].title}}</view>
  83. <view class="tag">
  84. <view class="tag-text">{{classList[classCurrent - 2].name}}</view>
  85. </view>
  86. <view class="tag">
  87. <view class="tag-text">{{classList[classCurrent - 2].teacher}}</view>
  88. </view>
  89. </view>
  90. <view class="row-margin">
  91. <view class="item-subtitle">上节</view>
  92. <view class="item-detail">
  93. {{classList[classCurrent - 2].time}}
  94. </view>
  95. </view>
  96. </view>
  97. <view class="state">
  98. <view class="state-text">{{classList[classCurrent - 2].attendance?'已出勤':'未出勤'}}
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 当前 -->
  104. <view class="data-item" style="border-image: linear-gradient(to right, #4169E1, #FFF) 1;">
  105. <view class="flex-row">
  106. <view class="t-icon t-icon-classicon-copy" style="width: 60rpx; height: 60rpx;"></view>
  107. <view class="flex-column">
  108. <view class="row-margin">
  109. <view class="item-title" style="color: #4169E1;">
  110. {{classList[classCurrent - 1].title}}
  111. </view>
  112. <view class="tag">
  113. <view class="tag-text">{{classList[classCurrent - 1].name}}</view>
  114. </view>
  115. <view class="tag">
  116. <view class="tag-text">{{classList[classCurrent - 1].teacher}}</view>
  117. </view>
  118. </view>
  119. <view class="row-margin">
  120. <view class="item-subtitle" style="color: #4169E1;">当前</view>
  121. <view class="item-detail" style="color: #4169E1;">
  122. {{classList[classCurrent - 1].time}}
  123. </view>
  124. </view>
  125. </view>
  126. <view class="state" style="background-color: #ff5959;">
  127. <view class="state-text">{{classList[classCurrent - 1].attendance?'课程中':'未出勤'}}
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. <!-- 下节 -->
  133. <view class="data-item" v-if="classCurrent != classList.length">
  134. <view class="flex-row">
  135. <view class="t-icon t-icon-classicon-noarrive" style="width: 60rpx; height: 60rpx;">
  136. </view>
  137. <view class="flex-column">
  138. <view class="row-margin">
  139. <view class="item-title">{{classList[classCurrent].title}}</view>
  140. <view class="tag">
  141. <view class="tag-text">{{classList[classCurrent].name}}</view>
  142. </view>
  143. <view class="tag">
  144. <view class="tag-text">{{classList[classCurrent].teacher}}</view>
  145. </view>
  146. </view>
  147. <view class="row-margin">
  148. <view class="item-subtitle">下节</view>
  149. <view class="item-detail">
  150. {{classList[classCurrent].time}}
  151. </view>
  152. </view>
  153. </view>
  154. <view class="state" style="background-color: #909399;">
  155. <view class="state-text">未开始</view>
  156. </view>
  157. </view>
  158. </view>
  159. <!-- 下下节 -->
  160. <view class="data-item" v-if="classCurrent === 1">
  161. <view class="flex-row">
  162. <view class="t-icon t-icon-classicon-noarrive" style="width: 60rpx; height: 60rpx;">
  163. </view>
  164. <view class="flex-column">
  165. <view class="row-margin">
  166. <view class="item-title">{{classList[classCurrent+1].title}}</view>
  167. <view class="tag">
  168. <view class="tag-text">{{classList[classCurrent+1].name}}</view>
  169. </view>
  170. <view class="tag">
  171. <view class="tag-text">{{classList[classCurrent+1].teacher}}</view>
  172. </view>
  173. </view>
  174. <view class="row-margin">
  175. <view class="item-subtitle">下节</view>
  176. <view class="item-detail">
  177. {{classList[classCurrent+1].time}}
  178. </view>
  179. </view>
  180. </view>
  181. <view class="state" style="background-color: #909399;">
  182. <view class="state-text">未开始</view>
  183. </view>
  184. </view>
  185. </view>
  186. </view>
  187. </view>
  188. <!-- 插画模块 -->
  189. <view class="card-item" style="width: 100%;" v-if="classCurrent === -1">
  190. <view class="card-title">
  191. <view class="front-tag"></view>
  192. <view class="title">今日课程</view>
  193. </view>
  194. <view class="detail-image-none" :style="{backgroundImage:`url(${image})`}"></view>
  195. <view class="data-list">
  196. <view class="data-item" style="height: 120rpx;">
  197. <view class="flex-row" style="justify-content: space-between;">
  198. <view class="item-title" v-if="!isAfterDayClass">
  199. {{classList.length === 0 ? '假期充电' : '课间休息'}}
  200. </view>
  201. <view class="item-title" v-if="isAfterDayClass">课程完成</view>
  202. <view class="tag" style="margin: 0;">
  203. <view class="tag-text" v-if="!isAfterDayClass">
  204. {{classList.length === 0 ? '无课' : '下课'}}
  205. </view>
  206. <view class="tag-text" v-if="isAfterDayClass">放学</view>
  207. </view>
  208. <view class="item-subtitle" style="font-weight: 400;font-size: 26rpx;"
  209. v-if="!isAfterDayClass">
  210. {{classList.length === 0 ? '合理规划' : '预习下节'}}
  211. </view>
  212. <view class="item-subtitle" style="font-weight: 400;font-size: 26rpx;"
  213. v-if="isAfterDayClass">巩固所学</view>
  214. <view class="flex-row" @click="navClassList">
  215. <view class="t-icon t-icon-fenlei"></view>
  216. <view class="item-title" style="color: #4169E1;margin-left: 10rpx;">课程列表
  217. </view>
  218. </view>
  219. </view>
  220. </view>
  221. </view>
  222. </view>
  223. <!-- 今日打卡模块 -->
  224. <view class="card-item" style="height: 300rpx;" @click="navClockStats">
  225. <view class="flex-row" style="margin: 20rpx 20rpx 0 20rpx;">
  226. <view class="icon-box" style="width: 120rpx;height: 120rpx; background-color: #d8deff;">
  227. <view class="t-icon t-icon-a-rilidaka" style="width: 60rpx;height: 60rpx;"></view>
  228. </view>
  229. <view class="clock-block">
  230. <view class="subtitle">打卡记录</view>
  231. <view class="flex-baseline">
  232. <view class="YS-title">{{dayTime.split('月')[0]}}</view>
  233. <view class="YS-title" style="font-size: 30rpx; margin-left: 4rpx;">月</view>
  234. <view class="YS-title" style="margin-left: 4rpx;">
  235. {{dayTime.split('月')[1]}}
  236. </view>
  237. <view class="YS-title" style="font-size: 30rpx; margin-left: 4rpx;">日</view>
  238. </view>
  239. </view>
  240. </view>
  241. <view class="flex-row" style="margin: auto 20rpx 20rpx 20rpx;justify-content: space-between;">
  242. <view class="clock-block">
  243. <view class="subtitle">打卡时间</view>
  244. <view class="YS-title" v-if="clockTime === '无记录'">
  245. {{clockTime}}
  246. </view>
  247. <view class="flex-baseline" v-if="clockTime != '无记录'">
  248. <view class="YS-title">
  249. {{clockTime.split(':')[0].replace('0','')}}
  250. </view>
  251. <view class="YS-title" style="font-size: 30rpx; margin-left: 4rpx;">点</view>
  252. <view class="YS-title" style="margin-left: 4rpx;">
  253. {{clockTime.split(':')[1]}}
  254. </view>
  255. <view class="YS-title" style="font-size: 30rpx; margin-left: 4rpx;">分</view>
  256. </view>
  257. </view>
  258. <view class="icon-box" style="width: 120rpx;height: 120rpx;"
  259. :style="{backgroundColor: clockState === '未打卡' ? '#ff5959':'#4169E1'}">
  260. <view class="YS-title" style="color: #FFF;font-size: 32rpx;">
  261. {{clockState}}
  262. </view>
  263. </view>
  264. </view>
  265. <view style="width: 0;height: 0;">
  266. <view class="clock-image"
  267. :style="{backgroundImage: clockState === '已打卡'?`url(${image2})`:`url(${image1})`}">
  268. </view>
  269. </view>
  270. </view>
  271. <!-- 今日出席模块 -->
  272. <view class="card-item" style="background-color: #f3f4f9;justify-content: space-between;">
  273. <!-- 当前课程 -->
  274. <view class="class-box">
  275. <view class="icon-box" style="background-color: #d8deff; margin-left: 20rpx;">
  276. <view class="t-icon t-icon-shangke-"></view>
  277. </view>
  278. <view class="info-column">
  279. <view class="subtitle" style="font-size: 24rpx;">当前课程</view>
  280. <view class="YS-title" v-if="classCurrent!=-1">
  281. {{classList[classCurrent - 1].name}}
  282. </view>
  283. <view class="YS-title" v-if="classCurrent===-1">无课程</view>
  284. </view>
  285. <view v-if="classCurrent != -1">
  286. <view class="icon-box" style="margin-right: 20rpx;"
  287. :style="{backgroundColor: classList[classCurrent - 1].attendance ? '#23b46c':'#ff5959'}">
  288. <view class="YS-title" style="color: #FFF;font-size: 32rpx;">
  289. {{classList[classCurrent - 1].attendance ? '出勤':'缺勤'}}
  290. </view>
  291. </view>
  292. </view>
  293. <view v-if="classCurrent === -1">
  294. <view class="icon-box" style="margin-right: 20rpx;background-color: #f9c752;">
  295. <view class="YS-title" style="color: #FFF;font-size: 32rpx;">休息</view>
  296. </view>
  297. </view>
  298. </view>
  299. <!-- 出勤课程统计 -->
  300. <view class="class-box">
  301. <view class="icon-box" style="background-color: #d8deff;margin-left: 20rpx;">
  302. <view class="t-icon t-icon-shangkejilu"></view>
  303. </view>
  304. <view class="info-column">
  305. <view class="subtitle" style="font-size: 24rpx;">出勤课程</view>
  306. <view class="YS-title" v-if="classList">{{finishClassNum}}节课</view>
  307. <view class="YS-title" v-if="!classList">0 节</view>
  308. </view>
  309. <view v-if="classList">
  310. <view class="icon-box" style="margin-right: 20rpx;"
  311. :style="{backgroundColor: classAttendanceQuality === '全勤' ? '#23b46c':'#ff5959'}">
  312. <view class="YS-title" style="color: #FFF;font-size: 32rpx;">{{classAttendanceQuality}}
  313. </view>
  314. </view>
  315. </view>
  316. <view v-if="!classList">
  317. <view class="icon-box" style="margin-right: 20rpx;background-color: #f9c752;">
  318. <view class="YS-title" style="color: #FFF;font-size: 32rpx;">休息</view>
  319. </view>
  320. </view>
  321. </view>
  322. </view>
  323. <!-- 推荐课例列表 -->
  324. <view class="flex-column" style="margin: 15rpx 0 10rpx 20rpx;">
  325. <view class="title" style="font-size: 32rpx;">课程推荐</view>
  326. <view class="bottom-tag"></view>
  327. </view>
  328. <view class="flex-row" style="width: 70%;"></view>
  329. </view>
  330. <scroll-view class="scroll-view-bottom" scroll-x="true" :scroll-with-animation="true" scroll-left="0">
  331. <view class="box-container" v-for="(item,index) in classData" :key="index"
  332. @click="navCourseRecommend(index)">
  333. <view class="clounm-container" v-for="(classItem,i) in item" :key="i">
  334. <view class="item-box">
  335. <view class="thumb" :style="{backgroundImage: `url(${classItem.coverImage})`}"></view>
  336. <view class="info-box">
  337. <view class="title" style="font-size: 32rpx;">{{classItem.title}}</view>
  338. <view class="flex-row">
  339. <view class="tag-fill">
  340. <view class="t-icon t-icon-a-wangluokechengzaixianjiaoyu"></view>
  341. <view class="tag-text">{{classItem.classHour}} 学时</view>
  342. </view>
  343. <view class="tag-fill" style="margin-left: 20rpx;">
  344. <view class="t-icon t-icon-xiaoyuanredian"></view>
  345. <view class="tag-text">{{classItem.learnNum}} 已学</view>
  346. </view>
  347. </view>
  348. <view class="desc">{{classItem.description}}</view>
  349. </view>
  350. </view>
  351. </view>
  352. </view>
  353. </scroll-view>
  354. </view>
  355. </view>
  356. </template>
  357. <script>
  358. import {
  359. mapState,
  360. mapMutations
  361. } from 'vuex'
  362. export default {
  363. computed: {
  364. ...mapState('m_children', ['classList', 'examData', 'workData', 'swapData', 'clockData']),
  365. ...mapState('m_parent', ['userData', 'classData'])
  366. },
  367. data() {
  368. return {
  369. cardList: [{
  370. icon: 't-icon t-icon-chakandingdan',
  371. title: '今日评测',
  372. canvasId: 'tab_home_chart1',
  373. data: {
  374. "series": [{
  375. "name": "评测完成率",
  376. "data": '无评测',
  377. "color": "#ff8caf"
  378. }]
  379. },
  380. chartOpts: {}
  381. }, {
  382. icon: 't-icon t-icon-renwu',
  383. title: '今日作业',
  384. canvasId: 'tab_home_chart2',
  385. data: {
  386. "series": [{
  387. "name": "作业完成率",
  388. "data": '无作业',
  389. "color": "#f9c752"
  390. }]
  391. },
  392. chartOpts: {}
  393. }, {
  394. icon: 't-icon t-icon-wenjian',
  395. title: '今日活动',
  396. canvasId: 'tab_home_chart3',
  397. data: {
  398. "series": [{
  399. "name": "活动完成率",
  400. "data": '无活动',
  401. "color": "#FF6D31"
  402. }]
  403. },
  404. chartOpts: {}
  405. }],
  406. noticeData: '',
  407. //当前课程索引
  408. classCurrent: '',
  409. //已上课程
  410. finishClassNum: '',
  411. //课程缺省image
  412. image: 'https://image.meiye.art/pic_1631411821366fqhkuMI110LbOlAIdv1SV',
  413. //时间戳
  414. timeStamp: '',
  415. //今日时间
  416. dayTime: '',
  417. //打卡状态
  418. clockState: '',
  419. //打卡时间
  420. clockTime: '',
  421. //出勤课程统计信息
  422. classAttendanceQuality: '',
  423. //打卡状态image
  424. image1: 'https://ouch-cdn2.icons8.com/2farWQUdLe8J4mb4oQoEvJpl5OFXtM5P7AZi8nhuOxk/rs:fit:912:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvOTYz/L2VkZGEwNzAzLTAw/MWYtNGZiZS1hY2I3/LTVlNjRhZGYzNTAx/Mi5zdmc.png',
  425. image2: 'https://ouch-cdn2.icons8.com/6CkTSZQdyBYaGiqmNJRhbqoYi8QDcLFn-04VEQyQaCo/rs:fit:962:912/czM6Ly9pY29uczgu/b3VjaC1wcm9kLmFz/c2V0cy9zdmcvNzMz/LzlhYmUzYjIyLTRl/ZGQtNDVkMi1iYWEw/LTVjYjk2NThmNDJi/OC5zdmc.png',
  426. //当前页面加载是否完成
  427. isHomeLoad: false,
  428. //今日课程是否上完
  429. isAfterDayClass: false
  430. };
  431. },
  432. onLoad() {
  433. this.init()
  434. },
  435. //刷新页面
  436. onPullDownRefresh() {
  437. this.init()
  438. setTimeout(function() {
  439. uni.stopPullDownRefresh();
  440. }, 1000);
  441. },
  442. methods: {
  443. //初始化页面
  444. async init() {
  445. await this.$initHome()
  446. this.dayTime = (new Date()).format('M-d').replace('-', '月')
  447. this.timeStamp = (new Date()).format("hh:mm")
  448. this.getClassCurrent()
  449. this.getChartData()
  450. this.getNoticeData()
  451. this.getClockData()
  452. this.getClassAttendance()
  453. this.isHomeLoad = true
  454. },
  455. //计算出当前课程
  456. getClassCurrent() {
  457. //当前时间戳是否在课程时间段内
  458. function CompareDate(start, finish) {
  459. //获得当前时间时间戳
  460. let timeNow = (new Date()).format("yyyy-MM-dd hh:mm").replace(new RegExp("-", "gm"), "/")
  461. let timeHaoMiao = (new Date(timeNow)).getTime()
  462. //获得课程开始结束时间戳
  463. let today = (new Date()).format("yyyy-MM-dd ")
  464. let classStart = (today + start).replace(new RegExp("-", "gm"), "/")
  465. let classFinish = (today + finish).replace(new RegExp("-", "gm"), "/")
  466. let classStartHaoMiao = (new Date(classStart)).getTime()
  467. let classFinishHaoMiao = (new Date(classFinish)).getTime()
  468. //比较
  469. if (timeHaoMiao < classFinishHaoMiao) {
  470. if (classStartHaoMiao < timeHaoMiao)
  471. return true
  472. }
  473. return false
  474. }
  475. //当前时间戳是否在课程开始时间之前
  476. function CompareDateStart(start) {
  477. //获得当前时间时间戳
  478. let timeNow = (new Date()).format("yyyy-MM-dd hh:mm").replace(new RegExp("-", "gm"), "/")
  479. let timeHaoMiao = (new Date(timeNow)).getTime()
  480. //获得课程开始结束时间戳
  481. let today = (new Date()).format("yyyy-MM-dd ")
  482. let classStart = (today + start).replace(new RegExp("-", "gm"), "/")
  483. let classStartHaoMiao = (new Date(classStart)).getTime()
  484. //比较
  485. if (timeHaoMiao < classStartHaoMiao)
  486. return true
  487. return false
  488. }
  489. //今日有课程
  490. if (this.classList.length != 0) {
  491. //当前课程索引
  492. let classIndex = -100
  493. //完成课程数目
  494. let finishNum = -100
  495. //是否在课堂中
  496. let isInClass = false
  497. //判断是否在课程中,若是则赋值为当前课程索引
  498. this.classList.some((item, index) => {
  499. let timeArr = item.time.split("-")
  500. //在课堂中
  501. let res = CompareDate(timeArr[0], timeArr[1])
  502. if (res) {
  503. classIndex = index + 1
  504. finishNum = index + 1
  505. return isInClass = true
  506. }
  507. })
  508. if (isInClass) {
  509. //当前课程赋值
  510. this.classCurrent = classIndex
  511. //已上课程赋值
  512. this.finishClassNum = finishNum
  513. } else {
  514. //是否放学
  515. this.classList.some((item, index) => {
  516. let timeArr = item.time.split("-")
  517. //没在课堂中
  518. let value = CompareDateStart(timeArr[0])
  519. //课间时间
  520. if (value) {
  521. classIndex = -1
  522. finishNum = index - 1
  523. this.isAfterDayClass = false
  524. } else {
  525. //放学时间(有课程但已上完状态)
  526. classIndex = -1
  527. finishNum = this.classList.length
  528. this.isAfterDayClass = true
  529. }
  530. })
  531. //当前课程赋值
  532. this.classCurrent = classIndex
  533. //已上课程赋值
  534. this.finishClassNum = finishNum
  535. }
  536. //无课程,放假时间
  537. } else {
  538. //当前课程赋值
  539. this.classCurrent = -1
  540. //已上课程赋值
  541. this.finishClassNum = 0
  542. }
  543. },
  544. //更新图表数据
  545. getChartData() {
  546. //完成数据
  547. if (this.examData.length != 0) {
  548. let examFinishData = this.examData.filter(x => x.examInfo.progress === 'finish')
  549. this.cardList[0].data.series[0].data = parseFloat((examFinishData.length / this.examData.length)
  550. .toFixed(2))
  551. }
  552. if (this.workData.length != 0) {
  553. let workFinishData = this.workData.filter(x => x.work.progress === 'finish')
  554. this.cardList[1].data.series[0].data = parseFloat((workFinishData.length / this.workData.length)
  555. .toFixed(2))
  556. }
  557. if (this.swapData.length != 0) {
  558. let swapFinishData = this.swapData.filter(x => x.vote && x.vote.progress === 'finish')
  559. swapFinishData.push(...this.swapData.filter(x => x.survey && x.survey.progress === 'finish'))
  560. this.cardList[2].data.series[0].data = parseFloat((swapFinishData.length / this.swapData.length)
  561. .toFixed(2))
  562. }
  563. //完成率传入图表
  564. for (let i = 0; i < 3; i++) {
  565. if (typeof(this.cardList[i].data.series[0].data) === typeof(0)) {
  566. let opt = {
  567. title: {
  568. name: (this.cardList[i].data.series[0].data * 100).toFixed(0) + '%',
  569. color: this.cardList[i].data.series[0].color
  570. },
  571. subtitle: {
  572. name: this.cardList[i].data.series[0].name
  573. },
  574. }
  575. this.cardList[i].chartOpts = JSON.parse(JSON.stringify(opt))
  576. } else {
  577. let opt = {
  578. title: {
  579. name: this.cardList[i].data.series[0].data,
  580. color: this.cardList[i].data.series[0].color
  581. },
  582. subtitle: {
  583. name: this.cardList[i].data.series[0].name
  584. },
  585. }
  586. this.cardList[i].chartOpts = JSON.parse(JSON.stringify(opt))
  587. }
  588. }
  589. },
  590. //日历数据获取
  591. getClockData() {
  592. //获得当前时间时间戳
  593. let today = (new Date()).format("yyyy-M-dd")
  594. let timeArr = today.split("-")
  595. if (this.clockData.length != 0) {
  596. let val = this.clockData.filter(x => x.year == timeArr[0] && x.month == timeArr[1] && x.date ==
  597. timeArr[2])
  598. if (val.length != 0) {
  599. this.clockState = '已打卡'
  600. this.clockTime = val[0].time
  601. } else {
  602. this.clockState = '未打卡'
  603. this.clockTime = '无记录'
  604. }
  605. } else {
  606. this.clockState = '未打卡'
  607. this.clockTime = '无记录'
  608. }
  609. },
  610. //获取滚动通知
  611. getNoticeData() {
  612. if (this.userData.msgList)
  613. this.noticeData = `您有 ${this.userData.msgList.length} 条通知,请点击查看`
  614. if (!this.userData.msgList)
  615. this.noticeData = `您已查看全部通知`
  616. },
  617. //获取出勤课程统计
  618. getClassAttendance() {
  619. let finishClassData = []
  620. for (let i = 0; i < this.finishClassNum; i++) {
  621. finishClassData.push(this.classList[i])
  622. }
  623. if (finishClassData.length != 0) {
  624. let isAttendArr = finishClassData.filter(x => x.attendance === true)
  625. this.classAttendanceQuality = isAttendArr.length === this.finishClassNum ? '全勤' : '缺勤'
  626. }
  627. },
  628. //导航
  629. navClassList() {
  630. let current = this.classCurrent
  631. uni.navigateTo({
  632. url: `/subpkg/home/classList?index=${current}`
  633. })
  634. },
  635. navTab(index) {
  636. let urlArr = ['/pages/tab_exam/tab_exam',
  637. '/pages/tab_work/tab_work',
  638. '/pages/tab_swap/tab_swap'
  639. ]
  640. uni.switchTab({
  641. url: urlArr[index]
  642. })
  643. },
  644. navClockStats() {
  645. uni.navigateTo({
  646. url: '/subpkg/home/clockStats'
  647. })
  648. },
  649. navCourseRecommend(index) {
  650. uni.navigateTo({
  651. url: `/subpkg/home/courseRecommend?index=${index}`
  652. })
  653. }
  654. }
  655. }
  656. </script>
  657. <style lang="scss">
  658. @import '@/pages/style/tab_pages.scss';
  659. .bg2 {
  660. margin-top: -1065rpx;
  661. height: 1200rpx;
  662. border-radius: 100rpx;
  663. border-bottom-left-radius: 0;
  664. background-color: #FFF;
  665. z-index: 1;
  666. .notice {
  667. margin: 1095rpx 50rpx 20rpx 50rpx;
  668. width: 650rpx;
  669. }
  670. }
  671. .YS-title {
  672. font-size: 38rpx;
  673. }
  674. .row-margin {
  675. display: flex;
  676. align-items: center;
  677. margin: 10rpx 20rpx;
  678. }
  679. .tag {
  680. margin-left: 20rpx;
  681. }
  682. //课程出勤
  683. .class-box {
  684. display: flex;
  685. align-items: center;
  686. justify-content: space-between;
  687. width: 100%;
  688. height: 140rpx;
  689. background-color: #FFF;
  690. border-radius: $border-radius;
  691. .info-column {
  692. height: 80rpx;
  693. display: flex;
  694. flex-direction: column;
  695. align-items: center;
  696. justify-content: space-around;
  697. }
  698. }
  699. .icon-box {
  700. display: flex;
  701. align-items: center;
  702. justify-content: center;
  703. width: 80rpx;
  704. height: 80rpx;
  705. border-radius: 12rpx;
  706. z-index: 9;
  707. .t-icon {
  708. width: 50rpx;
  709. height: 50rpx;
  710. }
  711. }
  712. .clock-block {
  713. display: flex;
  714. flex-direction: column;
  715. width: 180rpx;
  716. height: 120rpx;
  717. justify-content: space-around;
  718. align-items: center;
  719. }
  720. .state {
  721. display: flex;
  722. align-items: center;
  723. margin-left: auto;
  724. border-radius: $border-radius;
  725. background-color: $color-green;
  726. padding: 24rpx 12rpx;
  727. .t-icon {
  728. width: 32rpx;
  729. height: 32rpx;
  730. }
  731. .state-text {
  732. color: #FFF;
  733. font-size: 24rpx;
  734. font-weight: bold;
  735. transform: skew(-10deg);
  736. }
  737. }
  738. .scroll-view-bottom {
  739. white-space: nowrap;
  740. padding-bottom: 20rpx;
  741. }
  742. .clock-image {
  743. margin-top: -160rpx;
  744. margin-left: 20rpx;
  745. height: 160rpx;
  746. width: 160rpx;
  747. background-size: 100%;
  748. background-repeat: no-repeat;
  749. opacity: 0.25;
  750. z-index: 1;
  751. }
  752. .box-container {
  753. margin: 0 20rpx;
  754. display: inline-block;
  755. vertical-align: top;
  756. width: 84%;
  757. .clounm-container {
  758. height: 180rpx;
  759. width: 100%;
  760. margin-bottom: 20rpx;
  761. border-radius: $border-radius;
  762. background-color: #FFF;
  763. overflow: hidden;
  764. .item-box {
  765. display: flex;
  766. width: 100%;
  767. height: 100%;
  768. .thumb {
  769. width: 180rpx;
  770. height: 180rpx;
  771. border-radius: $border-radius;
  772. background-size: cover; //背景图片自适应
  773. background-repeat: no-repeat;
  774. z-index: 50;
  775. }
  776. .info-box {
  777. display: flex;
  778. flex-direction: column;
  779. margin: 20rpx 20rpx 20rpx 30rpx;
  780. justify-content: space-between;
  781. width: 400rpx;
  782. .tag-fill {
  783. background-color: #d8deff;
  784. width: fit-content;
  785. .t-icon {
  786. width: 30rpx;
  787. height: 30rpx;
  788. margin-right: 5rpx;
  789. }
  790. .tag-text {
  791. color: #4169E1;
  792. }
  793. }
  794. .desc {
  795. line-height: 26rpx;
  796. font-size: 26rpx;
  797. color: #909399;
  798. white-space: nowrap;
  799. overflow: hidden;
  800. text-overflow: ellipsis;
  801. }
  802. }
  803. }
  804. }
  805. }
  806. </style>