page-calendar.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view class="mt-24 bg-white relative z-4">
  3. <uni-calendar :insert="true" :lunar="false" :readonly="true" :showMonth="false" :selected="selected"
  4. :endDate="endDate" @change-month="changeMonth" />
  5. <view class="wrap mt-20 w-fit mx-auto px-98 py-16 flex items-center justify-center">
  6. <ie-image src="/pagesStudy/static/image/icon-calendar.png" custom-class="w-22 h-22" />
  7. <text class="ml-4 text-20 text-primary">{{ tip }}</text>
  8. </view>
  9. <view class="mt-40 mx-40 mb-30 grid grid-cols-2 gap-x-26 gap-y-26">
  10. <view v-for="item in stat" :key="item.name" class="relative p-30 rounded-10 bg-back">
  11. <ie-image :src="item.icon" custom-class="w-52 h-70 absolute top-20 right-25" />
  12. <view class="text-30 text-fore-light font-bold">{{ item.name }}</view>
  13. <view class="mt-4">
  14. <text class="text-36 text-fore-title font-bold">{{ item.value }}</text>
  15. <text class="ml-20 text-24 text-fore-light">{{ item.unit }}</text>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script lang="ts" setup>
  22. const stat = ref([
  23. {
  24. name: '答题数',
  25. unit: '道题',
  26. value: '0/90',
  27. icon: '/pagesStudy/static/image/icon-pen.png'
  28. },
  29. {
  30. name: '课程学习',
  31. unit: '课时',
  32. value: '0/5',
  33. icon: '/pagesStudy/static/image/icon-video.png'
  34. },
  35. {
  36. name: '学习时长',
  37. unit: '分钟',
  38. value: '0/120',
  39. icon: '/pagesStudy/static/image/icon-time.png'
  40. },
  41. {
  42. name: '正确率',
  43. unit: '',
  44. value: '70%',
  45. icon: '/pagesStudy/static/image/icon-chart.png'
  46. }
  47. ])
  48. const selected = ref([
  49. {
  50. date: '2025-09-29',
  51. info: 2
  52. },
  53. {
  54. date: '2025-10-01',
  55. info: 1
  56. },
  57. {
  58. date: '2025-10-02',
  59. info: 3
  60. }
  61. ])
  62. const endDate = ref('')
  63. const todayPlanFinish = computed(() => {
  64. const todayTarget = selected.value.find(item => item.date === endDate.value)
  65. if (todayTarget) {
  66. return todayTarget.info > 2;
  67. }
  68. return false
  69. });
  70. const tip = computed(() => {
  71. if (todayPlanFinish.value) {
  72. return '恭喜你,今日计划已完成'
  73. }
  74. return '今日计划进行中,加油~'
  75. });
  76. const init = () => {
  77. endDate.value = uni.$uv.timeFormat(new Date(), 'yyyy-mm-dd')
  78. }
  79. const changeMonth = (e: any) => {
  80. console.log(e);
  81. uni.$ie.showLoading();
  82. setTimeout(() => {
  83. uni.$ie.hideLoading();
  84. }, 1000);
  85. }
  86. init();
  87. </script>
  88. <style lang="scss" scoped>
  89. .wrap {
  90. background: linear-gradient(to right, white 0%, #E5F7FF 50%, white 100%);
  91. }
  92. </style>