四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
3.2 KiB

  1. <template>
  2. <uv-popup
  3. mode="bottom"
  4. ref="coursePopup"
  5. round="32rpx"
  6. bg-color="#f8f8f8"
  7. safeAreaInsetBottom
  8. >
  9. <view class="course-popup">
  10. <view class="popup-header">
  11. <view>
  12. <uv-icon name="arrow-down" color="black" size="20"></uv-icon>
  13. </view>
  14. <view class="popup-title">课程</view>
  15. <view class="popup-title" @click="toggleSort">
  16. 倒序
  17. </view>
  18. </view>
  19. <view class="course-list">
  20. <view
  21. v-for="course in displayCourseList"
  22. :key="course.id"
  23. class="course-item"
  24. :class="{ 'active': course.id === currentCourse }"
  25. @click="selectCourse(course.id)"
  26. >
  27. <view class="course-number" :class="{ 'highlight': course.id === currentCourse }">
  28. {{ String(course.index).padStart(2, '0') }}
  29. </view>
  30. <view class="course-content">
  31. <view class="course-english" :class="{ 'highlight': course.id === currentCourse }">
  32. {{ course.english }}
  33. </view>
  34. <view class="course-chinese" :class="{ 'highlight': course.id === currentCourse }">
  35. {{ course.chinese }}
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </uv-popup>
  42. </template>
  43. <script>
  44. export default {
  45. name: 'CoursePopup',
  46. props: {
  47. courseList: {
  48. type: Array,
  49. default: () => []
  50. },
  51. currentCourse: {
  52. type: [String, Number],
  53. default: 1
  54. },
  55. isReversed: {
  56. type: Boolean,
  57. default: false
  58. }
  59. },
  60. computed: {
  61. displayCourseList() {
  62. return this.isReversed ? [...this.courseList].reverse() : this.courseList;
  63. }
  64. },
  65. methods: {
  66. open() {
  67. if (this.$refs.coursePopup) {
  68. this.$refs.coursePopup.open()
  69. }
  70. },
  71. close() {
  72. if (this.$refs.coursePopup) {
  73. this.$refs.coursePopup.close()
  74. }
  75. },
  76. toggleSort() {
  77. this.$emit('toggle-sort')
  78. },
  79. selectCourse(courseId) {
  80. this.$emit('select-course', courseId)
  81. this.close()
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. /* 课程弹出窗样式 */
  88. .course-popup {
  89. padding: 0 32rpx;
  90. max-height: 80vh;
  91. }
  92. .popup-header {
  93. display: flex;
  94. justify-content: space-between;
  95. align-items: center;
  96. padding: 20rpx 0;
  97. border-bottom: 2rpx solid #EEEEEE;
  98. }
  99. .popup-title {
  100. font-family: PingFang SC;
  101. font-weight: 500;
  102. font-size: 34rpx;
  103. color: #181818;
  104. }
  105. .course-list {
  106. max-height: 60vh;
  107. overflow-y: auto;
  108. }
  109. .course-item {
  110. display: flex;
  111. align-items: center;
  112. gap: 24rpx;
  113. padding-top: 24rpx;
  114. padding-right: 8rpx;
  115. padding-bottom: 24rpx;
  116. padding-left: 8rpx;
  117. border-bottom: 1px solid #EEEEEE;
  118. cursor: pointer;
  119. &:last-child {
  120. border-bottom: none;
  121. }
  122. }
  123. .course-number {
  124. width: 80rpx;
  125. font-family: PingFang SC;
  126. font-size: 36rpx;
  127. color: #999;
  128. &.highlight {
  129. color: #06DADC;
  130. }
  131. }
  132. .course-content {
  133. flex: 1;
  134. }
  135. .course-english {
  136. font-family: PingFang SC;
  137. font-weight: 600;
  138. font-size: 36rpx;
  139. line-height: 44rpx;
  140. color: #252545;
  141. margin-bottom: 8rpx;
  142. &.highlight {
  143. color: #06DADC;
  144. }
  145. }
  146. .course-chinese {
  147. font-size: 28rpx;
  148. line-height: 48rpx;
  149. color: #3B3D3D;
  150. &.highlight {
  151. color: #06DADC;
  152. }
  153. }
  154. </style>