tab_home.vue 27 KB

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