index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="calendar-page">
  3. <!-- 导航栏 -->
  4. <u-navbar bgColor="red">
  5. <view class="u-nav-slot" slot="left">
  6. <text class="text-bold text-xxl text-white">{{ $t('schedule') }}</text>
  7. </view>
  8. <view class="u-nav-slot" slot="right"></view>
  9. </u-navbar>
  10. <!-- 日历 -->
  11. <uni-calendar insert foldAble :selected="selected" @change="change" />
  12. <!-- hint -->
  13. <view class="bg-gray flex justify-between align-center padding-lr-sm">
  14. <view v-for="(item, index) in hints" :key="index">
  15. <view class="flex justify-between align-center">
  16. <view class="hint-icon" :style="{ 'background-color': item.color}"></view>
  17. <text class="text-sm">{{ item.title }}</text>
  18. </view>
  19. </view>
  20. </view>
  21. <!-- 列表 -->
  22. <scroll-list ref="list" :option="option" @load="load" @refresh="refresh">
  23. <view class="list-item" v-for="(item, index) in list" :key="index">
  24. <view class="avatar">{{ index + 1 }}</view>
  25. <view class="info">
  26. <view class="info-item"></view>
  27. <view class="info-item"></view>
  28. </view>
  29. </view>
  30. </scroll-list>
  31. </view>
  32. </template>
  33. <script>
  34. import Api from '../../api/api.js';
  35. import UniCalendar from '../../components/uni-calendar/uni-calendar.vue';
  36. export default {
  37. components: {
  38. UniCalendar
  39. },
  40. data() {
  41. return {
  42. currentDate: '',
  43. show: false,
  44. mode: 'range',
  45. selected: [
  46. { date: '2022-01-05', info: '签到', data: { custom: '自定义信息', name: '自定义消息头' } },
  47. { date: '2022-01-09', info: '打卡', data: { custom: '自定义信息', name: '自定义消息头' } },
  48. { date: '2022-02-03', info: '打卡', data: { custom: '自定义信息', name: '自定义消息头' } }
  49. ],
  50. option: {
  51. size: 10,
  52. auto: false
  53. },
  54. list: [],
  55. hints: [
  56. { index: 0, color: 'red', title: '未上课' },
  57. { index: 1, color: 'green', title: '已上课' },
  58. { index: 2, color: 'blue', title: '未上完课' },
  59. { index: 3, color: 'grey', title: '班级取消' }
  60. ]
  61. };
  62. },
  63. onReady() {},
  64. mounted() {
  65. // let now = new Date()
  66. // let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(now)
  67. // let mo = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(now)
  68. // this.currentDate = `${ye}${mo}` /// 202201
  69. let now = new Date();
  70. var year = now.getFullYear();
  71. var month = now.getMonth() + 1;
  72. this.currentDate = `${year}${month}`; /// 202201
  73. console.log(this.currentDate);
  74. this.getClassSchedule();
  75. },
  76. methods: {
  77. async getClassSchedule() {
  78. Api.classSchedule(this.currentDate).then(res => {
  79. console.log(res);
  80. });
  81. },
  82. previousBtnDidClick() {
  83. console.log('previousBtnDidClick');
  84. },
  85. nextBtnDidClick() {
  86. console.log('nextBtnDidClick');
  87. },
  88. change(e) {
  89. console.log(e);
  90. },
  91. uploadAction() {
  92. uni.navigateTo({ url: '../test/upload' });
  93. },
  94. monitoringBtnClick() {
  95. uni.navigateTo({
  96. url: '../launch/index'
  97. });
  98. },
  99. // 加载数据
  100. load(paging) {
  101. setTimeout(() => {
  102. let list = [];
  103. for (var i = 0; i < paging.size; i++) {
  104. list.push(i);
  105. }
  106. this.list = [...this.list, ...list];
  107. // 加载成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
  108. this.$refs.list.loadSuccess({ list: this.list, total: 50 });
  109. // 加载失败
  110. // this.$refs.list.loadFail()
  111. }, this.$u.random(100, 1000));
  112. },
  113. // 刷新刷剧
  114. refresh(paging) {
  115. setTimeout(() => {
  116. let list = [];
  117. for (var i = 0; i < paging.size; i++) {
  118. list.push(i);
  119. }
  120. this.list = list;
  121. // 刷新成功 参数对象{list: 当前列表,total: 数据总长度(后端查询的total)}
  122. this.$refs.list.refreshSuccess({ list: this.list, total: 50 });
  123. // 刷新失败
  124. // this.$refs.list.refreshFail()
  125. }, this.$u.random(100, 1000));
  126. }
  127. }
  128. };
  129. </script>
  130. <style scoped>
  131. .hint-box {
  132. height: 5px;
  133. }
  134. .hint-item {
  135. margin: 0 5px 0 5px;
  136. }
  137. .hint-icon {
  138. width: 8px;
  139. height: 8px;
  140. border-radius: 50%;
  141. margin-right: 5px;
  142. }
  143. </style>