classSchedule.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <view>
  3. <u-navbar title="课程表">
  4. <view class="slot-wrap" @click="getToday()">
  5. 今天
  6. </view>
  7. </u-navbar>
  8. <!-- 日期 -->
  9. <view class="date-picker">
  10. <view class="check" @click="beforeWeek">
  11. <u-icon name="arrow-left" size="32"></u-icon>前一周
  12. </view>
  13. <view class="date">
  14. {{date}}
  15. </view>
  16. <view class="check" @click="afterWeek">
  17. 后一周<u-icon name="arrow-right" size="32"></u-icon>
  18. </view>
  19. </view>
  20. <view class="date-item">
  21. <view class="item" v-for="(item,index) in weekDate" :key="index"
  22. :class="activeClass == index ? 'checked' : ''" @click="activeClassClick(item,index)">
  23. <view :class="item.isDotShow ? 'dot' : ''" :style="activeClass == index ? 'background-color: #fff;' : ''">
  24. </view>
  25. <view class="week ">
  26. {{item.week}}
  27. </view>
  28. <view class="day ">
  29. {{parseInt(item.day.slice(8))}}
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 课表信息 -->
  34. <!-- <view class="courses-learned">
  35. 已学课程
  36. </view> -->
  37. <view class="class-box" v-for="(item,index) in courseList" :key="index"
  38. @click="gotoUrl('pages/parents/classSchedule/classScheduleDetails?id=' + item.sheetId)">
  39. <view class="picture">
  40. <img src="../../../assets/img/classschedule.png" alt="">
  41. </view>
  42. <view class="infos">
  43. <view class="title">
  44. {{item.className}}
  45. </view>
  46. <view class="tag">
  47. <view class="item">
  48. {{item.classroomName}}
  49. </view>
  50. <view class="item">
  51. {{item.coursePeriods}}
  52. </view>
  53. </view>
  54. <view class="else">
  55. <view class="teacher">
  56. <view class="photo">
  57. <img src="../../../assets/img/teachercard.png" alt="">
  58. </view>
  59. <view class="name">
  60. {{item.teacherNames}}老师
  61. </view>
  62. </view>
  63. <view class="class-times">
  64. <view class="text">
  65. 课次
  66. </view>
  67. <view class="num">
  68. {{item.courseAmount + item.freeAmount}}
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- <view class="courses-learned">
  75. 未学课程
  76. </view> -->
  77. <!-- <view class="class-box">
  78. <view class="picture">
  79. <img src="../../../assets/img/classschedule.png" alt="">
  80. </view>
  81. <view class="infos">
  82. <view class="title">
  83. 中国舞十级班
  84. </view>
  85. <view class="tag">
  86. <view class="item">
  87. 二楼舞蹈一教室
  88. </view>
  89. <view class="item">
  90. 08:30-10:00
  91. </view>
  92. </view>
  93. <view class="else">
  94. <view class="teacher">
  95. <view class="photo">
  96. <img src="../../../assets/img/teachercard.png" alt="">
  97. </view>
  98. <view class="name">
  99. 陈老师
  100. </view>
  101. </view>
  102. <view class="class-times">
  103. <view class="text">
  104. 课次
  105. </view>
  106. <view class="num">
  107. 22
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </view> -->
  113. </view>
  114. </template>
  115. <script>
  116. import * as classScheduleApi from '@/apis/parents/classSchedule.js'
  117. export default {
  118. data() {
  119. return {
  120. date: '',
  121. weekDate: [],
  122. weekN: ["一", "二", "三", "四", "五", "六", "日"],
  123. activeClass: 0,
  124. weekDate1: '',
  125. courseList: [],
  126. studentId: ''
  127. }
  128. },
  129. onReady() {
  130. if(this.carhelp.getStudentId()) {
  131. this.studentId = this.carhelp.getStudentId().studentId;
  132. }
  133. this.getToday();
  134. },
  135. methods: {
  136. getCourseList() {
  137. this.courseList = [];
  138. uni.showLoading({
  139. title: "加载中",
  140. mask: true,
  141. })
  142. classScheduleApi.loadMySchedule({
  143. studentId: this.studentId,
  144. startDate: this.weekDate[0].day,
  145. endDate: this.weekDate[6].day
  146. }).then((response) => {
  147. uni.hideLoading();
  148. var list = response.data;
  149. for (var i = 0; i < list.length; i++) {
  150. if(this.date == list[i].courseDate) {
  151. this.courseList.push(list[i]);
  152. }
  153. for (var j = 0; j < this.weekDate.length; j++) {
  154. if(this.weekDate[j].day == list[i].courseDate) {
  155. this.weekDate[j].isDotShow = true;
  156. }
  157. }
  158. }
  159. }).catch(error => {
  160. uni.showToast({
  161. title: error,
  162. icon: "none"
  163. })
  164. })
  165. },
  166. getToday() {
  167. this.weekDate = [];
  168. let date = new Date(); //当前日期
  169. let year = date.getFullYear(); //当前年
  170. let month = date.getMonth() + 1; //当前月
  171. let day = date.getDate(); //当天
  172. let mydate = new Date(year, month - 1, day);
  173. let weekday = mydate.getDay();
  174. this.weekDate1 = new Date(year, month - 1, day + 1 - weekday);
  175. this.getWeekDate(true);
  176. },
  177. getWeekDate(bl) {
  178. let weekDate2 = new Date(this.weekDate1.getTime());
  179. for (var i = 0; i < 7; i++) {
  180. for (var j = 0; j < this.weekN.length; j++) {
  181. if (i == j) {
  182. this.weekDate.push({
  183. week: this.weekN[j],
  184. day: this.getFormatDate(new Date(weekDate2.setDate(this.weekDate1.getDate() + i))),
  185. isDotShow: false
  186. })
  187. }
  188. }
  189. }
  190. if (bl) {
  191. let date = new Date(); //当前日期
  192. date = this.getFormatDate(date);
  193. for (var m = 0; m < this.weekDate.length; m++) {
  194. if (date == this.weekDate[m].day) {
  195. this.activeClass = m;
  196. this.date = this.weekDate[m].day;
  197. }
  198. }
  199. this.getCourseList();
  200. }
  201. },
  202. getFormatDate(date) {
  203. let myyear = date.getFullYear();
  204. let mymonth = date.getMonth() + 1;
  205. let myweekday = date.getDate();
  206. if (mymonth < 10) {
  207. mymonth = "0" + mymonth;
  208. }
  209. if (myweekday < 10) {
  210. myweekday = "0" + myweekday;
  211. }
  212. return (myyear + "-" + mymonth + "-" + myweekday);
  213. },
  214. beforeWeek() {
  215. this.weekDate = [];
  216. this.weekDate1 = new Date(this.weekDate1.setDate(this.weekDate1.getDate() - 7));
  217. this.getWeekDate();
  218. for (var m = 0; m < this.weekDate.length; m++) {
  219. if (this.activeClass == m) {
  220. this.date = this.weekDate[m].day;
  221. }
  222. }
  223. this.getCourseList();
  224. },
  225. afterWeek() {
  226. this.weekDate = [];
  227. this.weekDate1 = new Date(this.weekDate1.setDate(this.weekDate1.getDate() + 7));
  228. this.getWeekDate();
  229. for (var m = 0; m < this.weekDate.length; m++) {
  230. if (this.activeClass == m) {
  231. this.date = this.weekDate[m].day;
  232. }
  233. }
  234. this.getCourseList();
  235. },
  236. activeClassClick(item, index) {
  237. this.activeClass = index;
  238. for (var m = 0; m < this.weekDate.length; m++) {
  239. if (index == m) {
  240. this.date = this.weekDate[m].day;
  241. }
  242. }
  243. this.getCourseList();
  244. },
  245. }
  246. }
  247. </script>
  248. <style lang="scss" scoped>
  249. // 日期
  250. .date-picker {
  251. background-color: #fff;
  252. display: flex;
  253. justify-content: space-between;
  254. padding: 10px 12px 17px 12px;
  255. color: rgba(13, 186, 199, 1);
  256. .date {
  257. font-size: 16px;
  258. color: #333333;
  259. }
  260. }
  261. .date-item {
  262. background-color: #fff;
  263. display: flex;
  264. justify-content: space-around;
  265. padding: 0 12px 16px 12px;
  266. border-radius: 0px 0px 9px 9px;
  267. box-shadow: 0px 4px 4px 0px #CFD2D5;
  268. .item {
  269. line-height: 20px;
  270. border-radius: 8px;
  271. background-color: rgba(238, 238, 238, 1);
  272. color: #1C222A;
  273. text-align: center;
  274. width: 12%;
  275. padding: 12rpx 0;
  276. position: relative;
  277. .week {
  278. font-size: 12px;
  279. }
  280. .day {
  281. font-size: 16px;
  282. font-weight: bold;
  283. }
  284. }
  285. .checked {
  286. background-color: rgba(13, 186, 199, 1);
  287. color: #fff;
  288. }
  289. .dot {
  290. width: 6px;
  291. height: 6px;
  292. background-color: rgba(13, 186, 199, 1);
  293. border-radius: 999px;
  294. position: absolute;
  295. top: 8rpx;
  296. right: 8rpx;
  297. }
  298. .dot-checked {
  299. background-color: #fff;
  300. }
  301. }
  302. // 课表信息
  303. .courses-learned{
  304. margin-top: 40rpx;
  305. padding: 0 32rpx;
  306. color: rgba(51, 51, 51, 1);
  307. font-size: 16px;
  308. font-weight: bold;
  309. }
  310. .class-box {
  311. margin: 12px 16px;
  312. padding: 24rpx 0 24rpx 24rpx;
  313. border-radius: 24rpx;
  314. background-color: rgba(255, 255, 255, 1);
  315. display: flex;
  316. .picture {
  317. width: 200rpx;
  318. height: 200rpx;
  319. border-radius: 4px;
  320. overflow: hidden;
  321. img {
  322. width: 100%;
  323. height: 100%;
  324. }
  325. }
  326. .infos {
  327. margin-left: 24rpx;
  328. display: flex;
  329. flex-direction: column;
  330. justify-content: space-between;
  331. flex: 1;
  332. .title {
  333. color: rgba(51, 51, 51, 1);
  334. font-size: 16px;
  335. font-weight: bold;
  336. }
  337. .tag {
  338. display: flex;
  339. .item {
  340. line-height: 40rpx;
  341. border-radius: 8rpx;
  342. background-color: rgba(241, 243, 244, 1);
  343. color: rgba(16, 16, 16, 1);
  344. text-align: center;
  345. margin-right: 12rpx;
  346. font-size: 24rpx;
  347. padding: 0 8rpx;
  348. }
  349. @media screen and (max-width: 310px) {
  350. .item {
  351. padding: 0 4rpx;
  352. margin-right: 8rpx;
  353. }
  354. }
  355. }
  356. .else {
  357. display: flex;
  358. justify-content: space-between;
  359. padding-right: 24rpx;
  360. .teacher {
  361. display: flex;
  362. align-items: center;
  363. .photo {
  364. width: 64rpx;
  365. height: 64rpx;
  366. border-radius: 50px;
  367. overflow: hidden;
  368. img {
  369. width: 100%;
  370. height: 100%;
  371. }
  372. }
  373. .name {
  374. color: rgba(16, 16, 16, 1);
  375. margin-left: 12px;
  376. }
  377. }
  378. .class-times {
  379. display: flex;
  380. align-items: center;
  381. .text {
  382. color: rgba(119, 119, 119, 1);
  383. font-size: 16px;
  384. }
  385. .num {
  386. line-height: 20px;
  387. border-radius: 4px;
  388. background-color: rgba(13, 186, 199, 1);
  389. color: rgba(255, 255, 255, 1);
  390. text-align: center;
  391. margin-left: 8rpx;
  392. padding: 0 4px;
  393. }
  394. }
  395. }
  396. }
  397. }
  398. /deep/.u-slot-content {
  399. display: block;
  400. text-align: right !important;
  401. margin-right: 16px;
  402. color: #333333;
  403. }
  404. </style>