mineRecord.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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">
  13. <view class="course-item">
  14. <view class="course-item-image">
  15. <image class="course-image" :src="course.imgUrl" 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. onLoad(() => {
  85. form.value.pageNumber = 1
  86. initCourse();
  87. // console.log('onLoad')
  88. })
  89. onReachBottom(()=>{
  90. // 加载
  91. initCourse()
  92. })
  93. </script>
  94. <style lang="scss" scoped>
  95. .container {
  96. height: 100vh;
  97. width: 100vw;
  98. background-color: #fff;
  99. padding: 0 20rpx env(safe-area-inset-bottom, 0);
  100. }
  101. .course-item {
  102. margin: 20rpx 0;
  103. display: flex;
  104. overflow: hidden;
  105. .course-item-image {
  106. width: 200rpx;
  107. height: 260rpx;
  108. flex: 0 0 auto;
  109. margin-right: 20rpx;
  110. .course-image {
  111. width: 100%;
  112. }
  113. }
  114. .course-item-content {
  115. flex: 1;
  116. position: relative;
  117. view {
  118. margin-bottom: 15rpx;
  119. }
  120. .course-title {
  121. font-weight: bold;
  122. margin-right: 10px;
  123. font-size: 28rpx;
  124. color: #000;
  125. }
  126. .course-type,
  127. .course-teacher,
  128. .course-date,
  129. .course-price {
  130. font-size: 30rpx;
  131. color: #000;
  132. }
  133. .course-price {
  134. color: #fe0000;
  135. letter-spacing: 2rpx;
  136. }
  137. .button::after {
  138. content: none;
  139. /* 移除内容 */
  140. }
  141. .button {
  142. position: absolute;
  143. right: 0;
  144. bottom: 0;
  145. min-width: 80px;
  146. padding: 0 40rpx;
  147. white-space: nowrap;
  148. height: 45rpx;
  149. line-height: 45rpx;
  150. font-size: 22rpx;
  151. /* padding: 0; */
  152. border-radius: 50rpx;
  153. color: white;
  154. border: none;
  155. }
  156. .free {
  157. background-color: #006af4;
  158. }
  159. .purchase {
  160. background-color: #fe0000;
  161. }
  162. .member-free {
  163. background-color: transparent;
  164. background-image: url('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  165. background-size: cover;
  166. background-repeat: no-repeat;
  167. color: #000;
  168. height: initial;
  169. padding: 6rpx 0 3rpx;
  170. border-radius: 0;
  171. }
  172. .replay {
  173. background-color: #006af4;
  174. }
  175. .purchased {
  176. background-color: #006af4;
  177. }
  178. }
  179. }
  180. </style>