classSchedule.vue 7.9 KB

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