mineFavi.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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" style="margin-bottom: 20rpx;">
  12. <view class="list-box">
  13. <view class="list-item-box" v-for="item in courses" :key="item.id" @click="toCourse(item)">
  14. <view class="info-box">
  15. <view class="title">
  16. {{item.title}}
  17. </view>
  18. <view class="text">
  19. 【{{item.typeName}}】
  20. </view>
  21. </view>
  22. <view class="suffix-box">
  23. <view class="button">
  24. 查看
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <u-loadmore :status="status" v-if="courses.length !== 0 && status!=='nomore'"/>
  31. </view>
  32. </template>
  33. <script setup>
  34. import {
  35. ref
  36. } from 'vue'
  37. import {
  38. onLoad, onReachBottom
  39. } from '@dcloudio/uni-app'
  40. import {
  41. query
  42. } from '@/api/collect.js'
  43. // 日期格式:xxxx年xx月xx日(星期x)
  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. "keyword": "",
  56. "type": "2",
  57. "pageNumber": 1,
  58. "pageSize": 30
  59. })
  60. const status = ref('loadmore')
  61. const count = ref(0)
  62. const courses = ref([]);
  63. const initCourse = () => {
  64. if(status.value === 'nomore'){
  65. return;
  66. }
  67. status.value = 'loading'
  68. query(form.value).then(res=>{
  69. if(res && res?.code ===0){
  70. count.value = res.count
  71. if(form.value.pageNumber===1){
  72. courses.value = res.data
  73. }else{
  74. courses.value = [...courses.value, ...res.data]
  75. }
  76. if(courses.value.length === res.count){
  77. status.value = 'nomore'
  78. }else{
  79. status.value = 'loadmore'
  80. }
  81. form.value.pageNumber = form.value.pageNumber + 1
  82. }else{
  83. status.value = 'loadmore'
  84. }
  85. })
  86. }
  87. const toCourse = (item)=>{
  88. uni.navigateTo({
  89. url: `/pages/goOnEdu/course/courseDetail/courseDetail?id=${item.objId}&name=${item.title}`
  90. });
  91. }
  92. onLoad(() => {
  93. form.value.pageNumber = 1;
  94. initCourse();
  95. })
  96. onReachBottom(()=>{
  97. // 加载
  98. initCourse()
  99. })
  100. </script>
  101. <style lang="scss" scoped>
  102. .container {
  103. height: 100vh;
  104. width: 100vw;
  105. background-color: #fff;
  106. padding: 0 20rpx env(safe-area-inset-bottom, 0);
  107. }
  108. .course-item {
  109. margin: 20rpx 0;
  110. display: flex;
  111. overflow: hidden;
  112. .course-item-image {
  113. width: 200rpx;
  114. height: 260rpx;
  115. flex: 0 0 auto;
  116. margin-right: 20rpx;
  117. .course-image {
  118. width: 100%;
  119. }
  120. }
  121. .course-item-content {
  122. flex: 1;
  123. position: relative;
  124. view {
  125. margin-bottom: 15rpx;
  126. }
  127. .course-title {
  128. font-weight: bold;
  129. margin-right: 10px;
  130. font-size: 28rpx;
  131. color: #000;
  132. }
  133. .course-type,
  134. .course-teacher,
  135. .course-date,
  136. .course-price {
  137. font-size: 30rpx;
  138. color: #000;
  139. }
  140. .course-price {
  141. color: #fe0000;
  142. letter-spacing: 2rpx;
  143. }
  144. .button::after {
  145. content: none;
  146. /* 移除内容 */
  147. }
  148. .button {
  149. position: absolute;
  150. right: 0;
  151. bottom: 0;
  152. min-width: 80px;
  153. padding: 0 40rpx;
  154. white-space: nowrap;
  155. height: 45rpx;
  156. line-height: 45rpx;
  157. font-size: 22rpx;
  158. /* padding: 0; */
  159. border-radius: 50rpx;
  160. color: white;
  161. border: none;
  162. }
  163. .free {
  164. background-color: #006af4;
  165. }
  166. .purchase {
  167. background-color: #fe0000;
  168. }
  169. .member-free {
  170. background-color: transparent;
  171. background-image: url('http://www.gzrea.org.cn:8543/icon/wxmp/bg-label.png');
  172. background-size: cover;
  173. background-repeat: no-repeat;
  174. color: #000;
  175. height: initial;
  176. padding: 6rpx 0 3rpx;
  177. border-radius: 0;
  178. }
  179. .replay {
  180. background-color: #006af4;
  181. }
  182. .purchased {
  183. background-color: #006af4;
  184. }
  185. }
  186. }
  187. .list-box {
  188. .list-item-box {
  189. padding: 20rpx 10rpx;
  190. border-bottom: 5rpx solid #E6E6E6;
  191. display: flex;
  192. &:active {
  193. background-color: $uni-bg-color-hover;
  194. }
  195. .icon-box {
  196. width: 3%;
  197. padding-top: 10rpx;
  198. .icon {
  199. width: 10rpx;
  200. height: 10rpx;
  201. background-color: $uni-color-primary;
  202. border-radius: 50%;
  203. }
  204. }
  205. .info-box {
  206. width: 82%;
  207. .title {
  208. font-size: $uni-title-font-size-2;
  209. font-weight: bold;
  210. margin-bottom: 5rpx;
  211. @include text-overflow()
  212. }
  213. .text {
  214. line-height: 40rpx;
  215. font-size: $uni-font-size-2;
  216. font-weight: bold;
  217. }
  218. }
  219. .suffix-box {
  220. width: 15%;
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. .button {
  225. color: $uni-text-color-inverse;
  226. padding: 5rpx 18rpx;
  227. border-radius: $uni-card-border-radius;
  228. background-color: $uni-color-primary;
  229. font-size: $uni-font-size-3;
  230. letter-spacing: 3rpx;
  231. }
  232. }
  233. }
  234. }
  235. </style>