123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <s-layout>
- <scroll-view scroll-y class="list-container" refresher-enabled :refresher-triggered="triggered"
- @refresherrefresh="onRefresh" @scrolltolower="loadMore">
- <view>
- <view class="add-btn" @click="goToAdd">
- <u-icon name="plus" size="28"></u-icon>
- <text>添加营业执照</text>
- </view>
- <u-empty v-if="list.length === 0" text="暂无数据"></u-empty>
- <view v-else class="card-list">
- <view v-for="(item, index) in list" :key="index" class="card-item">
- <u-card :title="item.companyName" :sub-title="item.creditCode">
- <template #body>
- <view class="card-content" @click="goToEdit(item)">
- <view class="info-row">
- <text class="label">法定代表人:</text>
- <text class="value">{{ item.legalRepresentative }}</text>
- </view>
- <view class="info-row">
- <text class="label">注册资本:</text>
- <text class="value">{{ item.registeredCapital }}</text>
- </view>
- <view class="info-row">
- <text class="label">成立日期:</text>
- <text class="value">{{ dayjs(item.establishDate).format("YYYY-MM-DD") }}</text>
- </view>
- <view class="info-row">
- <text class="label">营业期限:</text>
- <text class="value">{{ dayjs(item.businessTermStart).format("YYYY-MM-DD") }} - {{
- dayjs(item.businessTermEnd).format("YYYY-MM-DD") }}</text>
- </view>
- <view class="info-row">
- <text class="label">经营范围:</text>
- <text class="value">{{ item.businessScope }}</text>
- </view>
- <!-- <view class="info-row">
- <text class="label">住所:</text>
- <text class="value">{{ item.address }}</text>
- </view> -->
- </view>
- </template>
- </u-card>
- </view>
- </view>
- <u-loadmore v-if="list.length > 0" :status="loadMoreStatus" />
- </view>
- </scroll-view>
- </s-layout>
- </template>
- <script setup>
- import { ref, onMounted } from 'vue';
- import { onLoad, onShow } from '@dcloudio/uni-app';
- import EnterApi from '@/sheep/api/enter/index.js';
- import dayjs from 'dayjs';
- import sheep from '@/sheep';
- const triggered = ref(false);
- const list = ref([]);
- const page = ref(1);
- const loadMoreStatus = ref('loadmore');
- // 跳转到添加页面
- const goToAdd = () => {
- sheep.$router.go('/pages/enter/businessLicenseEnter/index', { formType: 'create' })
- };
- const goToEdit = (item) => {
- sheep.$router.go('/pages/enter/businessLicenseEnter/index', { formType: 'edit', id: item.id })
- };
- // 获取列表数据
- const getList = async (isRefresh = false) => {
- try {
- if (isRefresh) {
- page.value = 1;
- }
- const res = await EnterApi.getUserBusinessLicensePage({
- page: page.value,
- pageSize: 10
- });
- if (res.code === 0) {
- if (isRefresh) {
- list.value = res.data.list;
- } else {
- list.value = [...list.value, ...res.data.list];
- }
- loadMoreStatus.value = res.data.hasMore ? 'loadmore' : 'nomore';
- } else {
- uni.showToast({
- title: res.msg,
- icon: 'none'
- });
- }
- } catch (error) {
- console.error(error);
- uni.showToast({
- title: '获取数据失败',
- icon: 'none'
- });
- }
- };
- // 下拉刷新
- const onRefresh = async () => {
- triggered.value = true;
- await getList(true);
- triggered.value = false;
- };
- // 加载更多
- const loadMore = async () => {
- if (loadMoreStatus.value === 'nomore') return;
- loadMoreStatus.value = 'loading';
- page.value++;
- await getList();
- };
- onLoad(() => {
- })
- onShow(() => {
- // 页面显示时重新加载数据
- page.value = 0;
- list.value = [];
- loadMoreStatus.value = 'loadmore';
- loadMore();
- })
- onMounted(() => {
- // // 页面显示时重新加载数据
- // page.value = 1;
- // list.value = [];
- // loadMoreStatus.value = 'loadmore';
- // loadMore();
- });
- </script>
- <style lang="scss" scoped>
- .list-container {
- width: 100%;
- background: #f5f5f5;
- .add-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- margin: 20rpx;
- padding: 20rpx;
- background: #fff;
- border-radius: 8rpx;
- box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
- text {
- margin-left: 10rpx;
- font-size: 28rpx;
- color: #333;
- }
- }
- .card-list {
- .card-item {
- margin-bottom: 20rpx;
- .card-content {
- padding: 20rpx;
- .info-row {
- display: flex;
- margin-bottom: 16rpx;
- .label {
- width: 160rpx;
- color: #666;
- font-size: 28rpx;
- }
- .value {
- flex: 1;
- color: #333;
- font-size: 28rpx;
- }
- }
- }
- }
- }
- }
- </style>
|