<template> <!-- 设备 --> <view class="work-container"> <view class="cartNull" v-show="!token"> 还没有登录,请<navigator open-type="navigate" url="/pages/login">先登录</navigator> </view> <view class="" v-show='token'> <Search :searchData='searchData' @search='search' @screen='screen' :isShowScreen='false'/> <view class="list"> <view class="item" v-for="(item,index) in list" :key='index'> <u-image :src="item.images" width='160' height="160"> <template v-slot:error> <view class="image-error"> <u-icon name="photo" color="#c7c7c7" size="38"></u-icon> <view style="font-size: 24rpx;">暂无图片</view> </view> </template> </u-image> <view class="text"> <view class="title"> {{item.name}} </view> <view class="dec1"> {{item.number}} </view> <view class="dec2"> {{item.factoryAreaName}} </view> </view> </view> </view> <view style="height: 94rpx;padding-top: 30rpx;"> <u-loadmore :status="status" v-if="status != 'loadmore'" /> </view> </view> <view style="height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom);"></view> </view> </template> <script setup lang="ts"> import { onShow, onReachBottom } from '@dcloudio/uni-app' import { ref, getCurrentInstance } from 'vue' import { getAccessToken } from '@/utils/auth' import * as moldApi from "@/api/mold.js" import Search from '../../components/search/index.vue' const { proxy } = getCurrentInstance() const params = ref({ pageNo: 1, pageSize: 10, type: '', name: '' }) const status = ref('loadmore') //是否显示没有更多了 const list = ref([]) const token = ref('') const searchData = ref({ placeholder:'请输入模具名称' }) // 搜索 function search(keyWord) { params.value.name = keyWord params.value.pageNo = 1 list.value = [] status.value = 'loadmore' getList() } function screen() { proxy.$tab.navigateTo(`/pages/device/screen`) } function getList() { if (status.value == 'nomore') return; status.value = 'loading'; proxy.$modal.loading('加载中') moldApi.moldPage(params.value).then((res) => { proxy.$modal.closeLoading() if (res.data.list.length > 0) { list.value = list.value.concat(res.data.list); params.value.pageNo++; status.value = 'loadmore' } else { status.value = 'nomore' } }).catch(() => { }) } onShow(() => { if (getAccessToken()) { token.value = getAccessToken() params.value.pageNo = 1 list.value = [] status.value = 'loadmore' getList() } }) onReachBottom(() => { getList() }) </script> <style lang="scss" scoped> .work-container{ min-height: 100vh; background: #f5f5f5; } .list { padding-bottom: 20rpx; .item { margin-top: 20rpx; background: white; padding: 30rpx; display: flex; align-items: center; .text { margin-left: 20rpx; .title { font-size: 32rpx; font-weight: bold; word-wrap: break-word; } .dec1 { font-size: 28rpx; margin-top: 16rpx; color: #acacac; } .dec2 { font-size: 28rpx; margin-top: 6rpx; color: #acacac; } } } } .image-error { text-align: center; } .cartNull { text-align: center; padding: 500rpx 40rpx 0; font-size: 28rpx; color: #888; } .cartNull navigator { color: #2979ff; } </style>