123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <template>
- <view class="container">
- <u-sticky>
- <view class="search-box">
- <u-search v-model="searchForm.keyword" :clearabled="true" bg-color="#E5E5E5" placeholder="请输入搜索内容"
- @search="onSearchConfirm" @custom="onSearchConfirm"></u-search>
- </view>
- </u-sticky>
- <view class="list-box">
- <view class="list-item-box" v-for="item in list" :key="item.id" @click="onDynamicClick(item)">
- <view class="main-box">
- <view class="icon-box">
- <!-- <view class="iconfont icon-yingfengdongtai"></view> -->
- <image
- mode="aspectFill"
- style="width: 250rpx;height: 200rpx;"
- :src="item.cover ? item.cover : '/static/images/avatar-img/1.png'"></image>
- </view>
- <view class="content-box">
- <view class="title" style="margin-bottom: 30rpx;">
- {{item.title}}
- </view>
- <view class="date" style="text-align: right;">
- {{item.date}}
- </view>
- </view>
- </view>
- <view class="line-box"></view>
- </view>
- </view>
- <u-loadmore :status="status" :load-text="loadText" style="margin: 20rpx 0;"/>
- </view>
- </template>
- <script setup>
- import {
- ref
- } from 'vue'
- import {
- onLoad,onReachBottom
- } from '@dcloudio/uni-app'
- import { loadRecordList } from '@/api/edu.js'
- const uToast = ref()
- import configService from '@/utils/baseurl.js'
- const FILE_URL = configService.FILE_URL;
- const searchInputStyle = {
- backgroundColor: '#E5E5E5'
- }
- const searchForm = ref({
- keyword: '',
- pageNumber: 1,
- pageSize: 10
- })
- const total = ref(0);
- const status = ref('loadmore');
- const loadText = ref({
- loadmore: '点击或上拉加载更多',
- loading: '努力加载中',
- nomore: '已加载全部数据'
- })
- const list = ref([])
- function onDynamicClick(dynamic) {
- uni.navigateTo({
- url: `/pages/dynamic/dynamicDetail/dynamicDetail?id=${dynamic.id}&title=${dynamic.title}`
- })
- }
- function onSearchConfirm() {
- // console.log(searchForm.value.keyword, 1211)
- searchForm.value.pageNumber = 1
- search()
- }
- function search() {
- status.value = 'loading'
- list.value = searchForm.value.pageNumber === 1 ? [] : list.value
- loadRecordList(searchForm.value).then(res => {
- total.value = res.count
- list.value = [...list.value, ...res.data]
- searchForm.value.pageNumber = searchForm.value.pageNumber + 1
- if(total.value === list.value.length){
- status.value = 'nomore'
- }else{
- status.value = 'loadmore'
- }
- }).catch(err=>{
- status.value = 'nomore'
- })
- }
- onLoad(() => {
- searchForm.value.pageNumber = 1
- search()
- })
- onReachBottom(()=>{
- if(status.value === 'nomore'){
- return
- }
- search()
- })
- </script>
- <style lang="scss" scoped>
- .container {
- width: 100vw;
- background-color: #FFFFFF;
- padding: 0 20rpx env(safe-area-inset-bottom, 0);
- .search-box {
- margin-bottom: 20rpx;
- ::v-deep(.u-search) {
- background-color: #e5e5e5;
- border-radius: 50rpx;
- .u-action {
- width: 18%;
- background-color: $uni-color-primary;
- border-radius: 50rpx;
- color: $uni-text-color-inverse;
- margin-right: 8rpx;
- font-size: 28rpx;
- line-height: 50rpx;
- letter-spacing: 3rpx;
- text-align: center;
- }
- }
- }
- .list-box {
- padding: 0 20rpx;
- .list-item-box {
- .main-box {
- display: flex;
- // justify-content: space-between;
- // align-items: center;
- padding: 15rpx 0;
- &:active {
- background-color: $uni-bg-color-hover;
- }
- .icon-box {
- flex: 0 0 auto;
- // width: 15%;
- margin-right: 20rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- image{
- border-radius: 20rpx;
- }
- .icon {
- width: 70rpx;
- height: 70rpx;
- }
- .iconfont {
- font-size: 60rpx;
- color: #0069f6;
- }
- }
- .content-box {
- // width: 67%;
- display: flex;
- flex-direction: column;
- // justify-content: space-around;
- justify-content: center;
- gap: 10rpx;
- width: 100%;
- .title {
- // height: calc(70% - 5rpx);
- font-size: $uni-title-font-size-2;
- font-weight: bold;
- }
- .text {
- height: calc(30% - 5rpx);
- font-size: $uni-font-size-3;
- color: $uni-text-color-grey;
- @include text-overflow();
- }
- }
- .other-box {
- width: 18%;
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- align-items: center;
- gap: 10rpx;
- .date {
- font-size: $uni-font-size-3;
- color: $uni-text-color-grey;
- }
- .tag {
- font-size: $uni-font-size-3;
- width: 42rpx;
- background-color: $uni-color-error;
- color: $uni-text-color-inverse;
- border-radius: 20rpx;
- text-align: center;
- }
- }
- }
- .line-box {
- height: 1rpx;
- width: 80%;
- background-color: #E5E5E5;
- margin: 0 auto;
- }
- }
- }
- }
- </style>
|