mineRecord.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="container">
  3. <u-empty
  4. mode="data"
  5. v-if="courses.length === 0"
  6. iconSize="120"
  7. textSize="58"
  8. text="暂无数据"
  9. >
  10. </u-empty>
  11. <view class="course-list">
  12. <view v-for="(course,index) in courses" :key="course.id" @click="toCourse(course)">
  13. <view class="course-item">
  14. <view class="course-item-image">
  15. <image class="course-image" :src="course.thumImg ? course.thumImg : course.cover" mode="aspectFit"></image>
  16. </view>
  17. <view class="course-item-content">
  18. <view class="course-title">
  19. <text>{{ course.title }}</text>
  20. </view>
  21. <view class="course-type">{{ course.type }}</view>
  22. <view class="course-date">
  23. <u-icon name="clock" size="28"></u-icon>
  24. {{ getDateWeek(course.viewDate) }}
  25. </view>
  26. </view>
  27. </view>
  28. <u-line />
  29. </view>
  30. </view>
  31. <u-loadmore :status="status" v-if="courses.length !== 0 && status!=='nomore'"/>
  32. </view>
  33. </template>
  34. <script setup>
  35. import {
  36. ref
  37. } from 'vue'
  38. import {
  39. onLoad, onReachBottom
  40. } from '@dcloudio/uni-app'
  41. import {
  42. loadCourseHistory
  43. } from '@/api/edu.js'
  44. function getDateWeek(val) {
  45. const date = new Date(val);
  46. const daysOfWeek = ['日', '一', '二', '三', '四', '五', '六'];
  47. const year = date.getFullYear();
  48. const month = date.getMonth() + 1; // 注意:月份从0开始
  49. const day = date.getDate();
  50. const dayOfWeek = daysOfWeek[date.getUTCDay()];
  51. // const result = `${year}年${month}月${day}日(星期${dayOfWeek})`
  52. return `${year}年${month}月${day}日(星期${dayOfWeek})`
  53. }
  54. const form = ref({
  55. pageNumber: 1,
  56. pageSize: 20
  57. })
  58. const status = ref('loadmore')
  59. const total = ref(0)
  60. const courses = ref([]);
  61. const initCourse = () => {
  62. if(status.value==='nomore'){
  63. return
  64. }
  65. status.value === 'loading'
  66. loadCourseHistory(form.value).then(res=>{
  67. if(res && res?.code===0){
  68. total.value = res.count;
  69. if(form.value.pageNumber===1){
  70. courses.value = res.data
  71. }else{
  72. courses.value = [...courses.value, ...res.data]
  73. }
  74. if(courses.value.length === res.count){
  75. status.value = 'nomore'
  76. }else{
  77. status.value = 'loadmore'
  78. }
  79. }else{
  80. status.value = 'loadmore'
  81. }
  82. })
  83. }
  84. const toCourse = (course) =>{
  85. uni.navigateTo({
  86. url: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${course.courseId}&title=${course.courseName}`
  87. });
  88. }
  89. onLoad(() => {
  90. form.value.pageNumber = 1
  91. initCourse();
  92. // console.log('onLoad')
  93. })
  94. onReachBottom(()=>{
  95. // 加载
  96. initCourse()
  97. })
  98. </script>
  99. <style lang="scss" scoped>
  100. .container {
  101. height: 100vh;
  102. width: 100vw;
  103. background-color: #fff;
  104. padding: 0 20rpx env(safe-area-inset-bottom, 0);
  105. }
  106. .course-item {
  107. margin: 20rpx 0;
  108. display: flex;
  109. overflow: hidden;
  110. .course-item-image {
  111. width: 200rpx;
  112. height: 260rpx;
  113. flex: 0 0 auto;
  114. margin-right: 20rpx;
  115. .course-image {
  116. width: 100%;
  117. height: 100%;
  118. }
  119. }
  120. .course-item-content {
  121. flex: 1;
  122. position: relative;
  123. view {
  124. margin-bottom: 15rpx;
  125. }
  126. .course-title {
  127. font-weight: bold;
  128. margin-right: 10px;
  129. font-size: 28rpx;
  130. color: #000;
  131. }
  132. .course-type,
  133. .course-teacher,
  134. .course-date,
  135. .course-price {
  136. font-size: 30rpx;
  137. color: #000;
  138. }
  139. .course-price {
  140. color: #fe0000;
  141. letter-spacing: 2rpx;
  142. }
  143. .button::after {
  144. content: none;
  145. /* 移除内容 */
  146. }
  147. .button {
  148. position: absolute;
  149. right: 0;
  150. bottom: 0;
  151. min-width: 80px;
  152. padding: 0 40rpx;
  153. white-space: nowrap;
  154. height: 45rpx;
  155. line-height: 45rpx;
  156. font-size: 22rpx;
  157. /* padding: 0; */
  158. border-radius: 50rpx;
  159. color: white;
  160. border: none;
  161. }
  162. .free {
  163. background-color: #006af4;
  164. }
  165. .purchase {
  166. background-color: #fe0000;
  167. }
  168. .member-free {
  169. background-color: transparent;
  170. background-image: url('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  171. background-size: cover;
  172. background-repeat: no-repeat;
  173. color: #000;
  174. height: initial;
  175. padding: 6rpx 0 3rpx;
  176. border-radius: 0;
  177. }
  178. .replay {
  179. background-color: #006af4;
  180. }
  181. .purchased {
  182. background-color: #006af4;
  183. }
  184. }
  185. }
  186. </style>