index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <!-- 头部 -->
  3. <nav-bar height="224" backPath="workspace" title="教师专业发展" :tabList="state.tabList" :onlyTitle="false" :showFilterPicker="false" :showTabs="true" rightWidth="0rpx" @CommonFilterData="CommonFilterData"></nav-bar>
  4. <view class="page_content">
  5. <scroll-view
  6. class="scroll_view_y"
  7. :scroll-top="state.scrollTop"
  8. scroll-y="true"
  9. :refresher-enabled="false"
  10. :enable-back-to-top="true"
  11. :show-scrollbar="false"
  12. :scroll-with-animation="true"
  13. refresher-default-style="none"
  14. refresher-background="#F8F9FD"
  15. :refresher-triggered="state.isRefreshing"
  16. @scrolltolower="OnLoadMore"
  17. @refresherrefresh="OnRefresh"
  18. @scroll="OnScroll">
  19. <view class="refresh_loading" v-if="state.isRefreshing"><uni-load-more status="loading" /></view>
  20. <view class="page_list">
  21. <view class="list_item" v-for="item in state.pageList" :key="item.id" @click="GoVideoDetails(item.id)">
  22. <view class="teacher_name">
  23. <image class="icon" src="@/static/image/icon/person.png"></image>
  24. <text class="name">{{item.teacherName}}</text>
  25. </view>
  26. <view class="honor_count">共<text class="count">{{item.honorCount}}</text>个奖项</view>
  27. <view class="honor_desc">{{item.honorName}}</view>
  28. <view class="honor_date">更新时间:{{item?.createdAt?.slice(0, 10)}}</view>
  29. </view>
  30. </view>
  31. <view class="no_data" v-if="!state.isLoading && state.pageList.length == 0">
  32. <image class="no_data_img" src="@/static/image/bg/no_data.png"></image>
  33. <text class="no_data_text">暂无数据</text>
  34. </view>
  35. <uni-load-more v-if="state.pageList.length > 0" :status="state.loadStatus" />
  36. </scroll-view>
  37. </view>
  38. </template>
  39. <script setup>
  40. import navBar from '@/components/nav-bar.vue';
  41. import {queryHonorTeacherListData} from '@/reqApi/teacherHonor.js';
  42. import {
  43. reactive,
  44. ref,
  45. onMounted,
  46. nextTick
  47. } from 'vue';
  48. const state = reactive({
  49. tabList:[ {
  50. label:'更新时间',
  51. value:'0',
  52. },{
  53. label:'获奖数量',
  54. value:'1',
  55. },{
  56. label:'姓名',
  57. value:'2',
  58. }],
  59. pageList:[],//列表数据
  60. sortType:'0',
  61. queryStr: '',
  62. pageSize: 30,
  63. pageNum: 1,
  64. scrollTop:0,
  65. oldScrollTop:0,
  66. isRefreshing:false,//设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
  67. isLoading:true,//加载中
  68. noMoreData:false,//没有更多数据了
  69. loadStatus:'more',//loading状态
  70. })
  71. onMounted(() => {
  72. OnLoadData(true);
  73. });
  74. //切换条件选择器
  75. const CommonFilterData = (searchWord,filterPicker,tabsSelected,type) => {
  76. state.queryStr = searchWord;
  77. state.sortType = tabsSelected;
  78. OnLoadData(true)
  79. }
  80. /*
  81. *获取数据
  82. * initPage:初始分页 从第一开始
  83. */
  84. const OnLoadData = (initPage) => {
  85. // uni.showLoading({
  86. // title: '加载中'
  87. // });
  88. state.isLoading = true;
  89. state.loadStatus = 'loading';
  90. if (initPage) {
  91. state.pageNum = 1;//如果是下拉刷新、重新查询 默认加载第一页
  92. }
  93. queryHonorTeacherListData({
  94. queryStr:state.queryStr,
  95. sortType:state.sortType
  96. }).then(res=>{
  97. if(res.code == 200){
  98. const recordsData = res?.data || [];
  99. const total = recordsData.length;//总数
  100. const pages = Math.ceil(total / state.pageSize);//总页数
  101. state.pageList = initPage ? recordsData : [...state.pageList,...recordsData];
  102. state.noMoreData = state.pageNum == pages;
  103. state.pageNum++;
  104. }
  105. }).finally(()=>{
  106. // uni.hideLoading();
  107. state.isLoading = false;
  108. state.isRefreshing = false;//下拉刷新未被触发
  109. if(state.noMoreData){
  110. state.loadStatus = 'no-more';
  111. }else{
  112. state.loadStatus = 'more';
  113. }
  114. //返回到页面顶部
  115. if(initPage){
  116. GoTop();
  117. }
  118. })
  119. }
  120. // 自定义下拉刷新被触发 下拉刷新
  121. const OnRefresh = () =>{
  122. state.isRefreshing = true;//下拉刷新已经被触发
  123. OnLoadData(true);
  124. }
  125. //滚动到底部/右边 触发上拉刷新
  126. const OnLoadMore = () => {
  127. if (state.isLoading || state.noMoreData) return;
  128. OnLoadData(false);
  129. }
  130. // 滚动时触发
  131. const OnScroll = (e) => {
  132. state.oldScrollTop = e.detail.scrollTop;
  133. }
  134. //返回到顶部
  135. const GoTop = () => {
  136. // 解决view层不同步的问题
  137. state.scrollTop = state.oldScrollTop;
  138. nextTick(() => {
  139. state.scrollTop = 0
  140. });
  141. }
  142. //视频详情
  143. const GoVideoDetails = (id) => {
  144. // uni.navigateTo({
  145. // url: `/pages/studentStudy/videoDetails?id=${id}`
  146. // });
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. .page_content{
  151. height: calc(100% - 448rpx);
  152. .scroll_view_y{
  153. height: 100%;
  154. .refresh_loading{
  155. padding: 10rpx 0;
  156. }
  157. }
  158. .page_list{
  159. display: flex;
  160. width: 100%;
  161. flex-wrap: wrap;
  162. gap:22rpx;
  163. .list_item{
  164. &:nth-child(1){
  165. margin-top: 0rpx;
  166. }
  167. &:nth-child(2){
  168. margin-top: 0rpx;
  169. }
  170. width: calc((100% - 22rpx) / 2);
  171. // min-height: 280rpx;
  172. padding: 16rpx 12rpx 18rpx 16rpx;
  173. background-color: #F8FAFE;
  174. border-radius: 16rpx;
  175. border: 2rpx solid #EBEEF5;
  176. box-sizing: border-box;
  177. margin-top: 24rpx;
  178. overflow: hidden;
  179. display: flex;
  180. flex-direction: column;
  181. .teacher_name{
  182. display: flex;
  183. width: 100%;
  184. align-items: center;
  185. .icon{
  186. width: 40rpx;
  187. height: 40rpx;
  188. margin-right: 16rpx;
  189. flex-shrink: 0;
  190. }
  191. .name{
  192. font-weight: 500;
  193. font-size: 36rpx;
  194. color: #333333;
  195. overflow: hidden;
  196. white-space: nowrap;
  197. text-overflow: ellipsis;
  198. }
  199. }
  200. .honor_count{
  201. display: flex;
  202. flex-wrap: wrap;
  203. align-items: center;
  204. width: 100%;
  205. margin-top: 8rpx;
  206. font-weight: 500;
  207. font-size: 28rpx;
  208. color: #666666;
  209. .count{
  210. color: #2E64FA;
  211. margin:0 8rpx;
  212. }
  213. }
  214. .honor_desc{
  215. display: -webkit-box;
  216. -webkit-line-clamp: 2;
  217. -webkit-box-orient: vertical;
  218. overflow: hidden;
  219. text-overflow: ellipsis;
  220. flex-wrap: wrap;
  221. word-break: break-all;
  222. width: 100%;
  223. margin-top: 16rpx;
  224. font-weight: 400;
  225. font-size: 28rpx;
  226. color: #999999;
  227. }
  228. .honor_date{
  229. width: 100%;
  230. display: flex;
  231. font-weight: 400;
  232. font-size: 24rpx;
  233. color: #999999;
  234. margin-top: 18rpx;
  235. }
  236. }
  237. }
  238. }
  239. </style>