trainRecord.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="container">
  3. <u-sticky>
  4. <view class="search-box">
  5. <u-search v-model="searchForm.keyword" :clearabled="true" bg-color="#E5E5E5" placeholder="请输入搜索内容"
  6. @search="onSearchConfirm" @custom="onSearchConfirm"></u-search>
  7. </view>
  8. </u-sticky>
  9. <view class="list-box">
  10. <view class="list-item-box" v-for="item in list" :key="item.id" @click="onDynamicClick(item)">
  11. <view class="main-box">
  12. <view class="icon-box">
  13. <!-- <view class="iconfont icon-yingfengdongtai"></view> -->
  14. <image
  15. mode="aspectFill"
  16. style="width: 250rpx;height: 200rpx;"
  17. :src="item.cover ? item.cover : '/static/images/avatar-img/1.png'"></image>
  18. </view>
  19. <view class="content-box">
  20. <view class="title" style="margin-bottom: 30rpx;">
  21. {{item.title}}
  22. </view>
  23. <view class="date" style="text-align: right;">
  24. {{item.date}}
  25. </view>
  26. </view>
  27. </view>
  28. <view class="line-box"></view>
  29. </view>
  30. </view>
  31. <u-loadmore :status="status" :load-text="loadText" style="margin: 20rpx 0;"/>
  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 { loadRecordList } from '@/api/edu.js'
  42. const uToast = ref()
  43. import configService from '@/utils/baseurl.js'
  44. const FILE_URL = configService.FILE_URL;
  45. const searchInputStyle = {
  46. backgroundColor: '#E5E5E5'
  47. }
  48. const searchForm = ref({
  49. keyword: '',
  50. pageNumber: 1,
  51. pageSize: 10
  52. })
  53. const total = ref(0);
  54. const status = ref('loadmore');
  55. const loadText = ref({
  56. loadmore: '点击或上拉加载更多',
  57. loading: '努力加载中',
  58. nomore: '已加载全部数据'
  59. })
  60. const list = ref([])
  61. function onDynamicClick(dynamic) {
  62. uni.navigateTo({
  63. url: `/pages/dynamic/dynamicDetail/dynamicDetail?id=${dynamic.id}&title=${dynamic.title}`
  64. })
  65. }
  66. function onSearchConfirm() {
  67. // console.log(searchForm.value.keyword, 1211)
  68. searchForm.value.pageNumber = 1
  69. search()
  70. }
  71. function search() {
  72. status.value = 'loading'
  73. list.value = searchForm.value.pageNumber === 1 ? [] : list.value
  74. loadRecordList(searchForm.value).then(res => {
  75. total.value = res.count
  76. list.value = [...list.value, ...res.data]
  77. searchForm.value.pageNumber = searchForm.value.pageNumber + 1
  78. if(total.value === list.value.length){
  79. status.value = 'nomore'
  80. }else{
  81. status.value = 'loadmore'
  82. }
  83. }).catch(err=>{
  84. status.value = 'nomore'
  85. })
  86. }
  87. onLoad(() => {
  88. searchForm.value.pageNumber = 1
  89. search()
  90. })
  91. onReachBottom(()=>{
  92. if(status.value === 'nomore'){
  93. return
  94. }
  95. search()
  96. })
  97. </script>
  98. <style lang="scss" scoped>
  99. .container {
  100. width: 100vw;
  101. background-color: #FFFFFF;
  102. padding: 0 20rpx env(safe-area-inset-bottom, 0);
  103. .search-box {
  104. margin-bottom: 20rpx;
  105. ::v-deep(.u-search) {
  106. background-color: #e5e5e5;
  107. border-radius: 50rpx;
  108. .u-action {
  109. width: 18%;
  110. background-color: $uni-color-primary;
  111. border-radius: 50rpx;
  112. color: $uni-text-color-inverse;
  113. margin-right: 8rpx;
  114. font-size: 28rpx;
  115. line-height: 50rpx;
  116. letter-spacing: 3rpx;
  117. text-align: center;
  118. }
  119. }
  120. }
  121. .list-box {
  122. padding: 0 20rpx;
  123. .list-item-box {
  124. .main-box {
  125. display: flex;
  126. // justify-content: space-between;
  127. // align-items: center;
  128. padding: 15rpx 0;
  129. &:active {
  130. background-color: $uni-bg-color-hover;
  131. }
  132. .icon-box {
  133. flex: 0 0 auto;
  134. // width: 15%;
  135. margin-right: 20rpx;
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. image{
  140. border-radius: 20rpx;
  141. }
  142. .icon {
  143. width: 70rpx;
  144. height: 70rpx;
  145. }
  146. .iconfont {
  147. font-size: 60rpx;
  148. color: #0069f6;
  149. }
  150. }
  151. .content-box {
  152. // width: 67%;
  153. display: flex;
  154. flex-direction: column;
  155. // justify-content: space-around;
  156. justify-content: center;
  157. gap: 10rpx;
  158. width: 100%;
  159. .title {
  160. // height: calc(70% - 5rpx);
  161. font-size: $uni-title-font-size-2;
  162. font-weight: bold;
  163. }
  164. .text {
  165. height: calc(30% - 5rpx);
  166. font-size: $uni-font-size-3;
  167. color: $uni-text-color-grey;
  168. @include text-overflow();
  169. }
  170. }
  171. .other-box {
  172. width: 18%;
  173. display: flex;
  174. flex-direction: column;
  175. justify-content: space-around;
  176. align-items: center;
  177. gap: 10rpx;
  178. .date {
  179. font-size: $uni-font-size-3;
  180. color: $uni-text-color-grey;
  181. }
  182. .tag {
  183. font-size: $uni-font-size-3;
  184. width: 42rpx;
  185. background-color: $uni-color-error;
  186. color: $uni-text-color-inverse;
  187. border-radius: 20rpx;
  188. text-align: center;
  189. }
  190. }
  191. }
  192. .line-box {
  193. height: 1rpx;
  194. width: 80%;
  195. background-color: #E5E5E5;
  196. margin: 0 auto;
  197. }
  198. }
  199. }
  200. }
  201. </style>