mineRecord.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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.cover" mode="aspectFill"></image>
  16. </view>
  17. <view class="course-item-content">
  18. <view class="course-title">
  19. <text>{{ course.courseName }}</text>
  20. </view>
  21. <view class="course-type">{{ course.courseType }}</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. }
  118. }
  119. .course-item-content {
  120. flex: 1;
  121. position: relative;
  122. view {
  123. margin-bottom: 15rpx;
  124. }
  125. .course-title {
  126. font-weight: bold;
  127. margin-right: 10px;
  128. font-size: 28rpx;
  129. color: #000;
  130. }
  131. .course-type,
  132. .course-teacher,
  133. .course-date,
  134. .course-price {
  135. font-size: 30rpx;
  136. color: #000;
  137. }
  138. .course-price {
  139. color: #fe0000;
  140. letter-spacing: 2rpx;
  141. }
  142. .button::after {
  143. content: none;
  144. /* 移除内容 */
  145. }
  146. .button {
  147. position: absolute;
  148. right: 0;
  149. bottom: 0;
  150. min-width: 80px;
  151. padding: 0 40rpx;
  152. white-space: nowrap;
  153. height: 45rpx;
  154. line-height: 45rpx;
  155. font-size: 22rpx;
  156. /* padding: 0; */
  157. border-radius: 50rpx;
  158. color: white;
  159. border: none;
  160. }
  161. .free {
  162. background-color: #006af4;
  163. }
  164. .purchase {
  165. background-color: #fe0000;
  166. }
  167. .member-free {
  168. background-color: transparent;
  169. background-image: url('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  170. background-size: cover;
  171. background-repeat: no-repeat;
  172. color: #000;
  173. height: initial;
  174. padding: 6rpx 0 3rpx;
  175. border-radius: 0;
  176. }
  177. .replay {
  178. background-color: #006af4;
  179. }
  180. .purchased {
  181. background-color: #006af4;
  182. }
  183. }
  184. }
  185. </style>