forked from natuka/web.puabadge.com
上拉加载更多
This commit is contained in:
1 parent
e6ebca45cb
commit
f2a24a0004
3 files changed
+108
-51
No files matched your search
Vendored
+2
@@ -24,7 +24,9 @@ declare module '@vue/runtime-core' {
|
|||||||
VanDivider: typeof import('vant/es')['Divider']
|
VanDivider: typeof import('vant/es')['Divider']
|
||||||
VanField: typeof import('vant/es')['Field']
|
VanField: typeof import('vant/es')['Field']
|
||||||
VanIcon: typeof import('vant/es')['Icon']
|
VanIcon: typeof import('vant/es')['Icon']
|
||||||
|
VanImage: typeof import('vant/es')['Image']
|
||||||
VanList: typeof import('vant/es')['List']
|
VanList: typeof import('vant/es')['List']
|
||||||
|
VanPullRefresh: typeof import('vant/es')['PullRefresh']
|
||||||
VanStepper: typeof import('vant/es')['Stepper']
|
VanStepper: typeof import('vant/es')['Stepper']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ function getOrder() {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
badgeApi.getMyOrder({
|
badgeApi.getMyOrder({
|
||||||
page: page.value,
|
page: page.value,
|
||||||
pageSize: 10,
|
size: 30,
|
||||||
status: 0,
|
status: 0,
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if(page.value === 1) {
|
if(page.value === 1) {
|
||||||
@@ -38,7 +38,7 @@ function getOrder() {
|
|||||||
} else {
|
} else {
|
||||||
orders.value.push(...res.list)
|
orders.value.push(...res.list)
|
||||||
}
|
}
|
||||||
if(res.list.length < 10) {
|
if(res.total <= orders.value.length) {
|
||||||
finished.value = true
|
finished.value = true
|
||||||
} else {
|
} else {
|
||||||
page.value++
|
page.value++
|
||||||
|
|||||||
+104
-49
@@ -5,6 +5,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="record-container">
|
<div class="record-container">
|
||||||
<div class="record-note">注:可点击效果图进行下单打印</div>
|
<div class="record-note">注:可点击效果图进行下单打印</div>
|
||||||
|
<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
|
||||||
<van-list
|
<van-list
|
||||||
v-model:loading="loading"
|
v-model:loading="loading"
|
||||||
:finished="finished"
|
:finished="finished"
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
<div class="record-images" v-if="images.length > 0">
|
<div class="record-images" v-if="images.length > 0">
|
||||||
<div class="record-image-item" v-for="item in images" :key="item.id">
|
<div class="record-image-item" v-for="item in images" :key="item.id">
|
||||||
<block v-if="item.status == 1" @click="goPreview(item)">
|
<block v-if="item.status == 1" @click="goPreview(item)">
|
||||||
<img :src="item.path" :alt="item.name" style="width: 100%; height: 100%; object-fit: cover; border-radius: 50%;">
|
<img :src="item.path" :alt="item.name" class="record-image">
|
||||||
<div class="record-image-item-shadow"></div>
|
<div class="record-image-item-shadow"></div>
|
||||||
</block>
|
</block>
|
||||||
<div v-else-if="item.status == 0" class="record-image-item-loading">
|
<div v-else-if="item.status == 0" class="record-image-item-loading">
|
||||||
@@ -25,49 +26,67 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="loading && page.value === 1" class="record-image-item-loading">
|
||||||
|
加载中...
|
||||||
|
</div>
|
||||||
<div v-else class="record-image-item-null">
|
<div v-else class="record-image-item-null">
|
||||||
<img src="@/assets/badge/null-data.png" alt="暂无数据">
|
<img src="@/assets/badge/null-data.png" alt="暂无数据">
|
||||||
</div>
|
</div>
|
||||||
</van-list>
|
</van-list>
|
||||||
|
</van-pull-refresh>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import * as badgeApi from '@/api/badge';
|
import * as badgeApi from '@/api/badge';
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref, onUnmounted } from 'vue';
|
||||||
|
const router = useRouter();
|
||||||
const images = ref([]);
|
const images = ref([]);
|
||||||
onMounted(() => {
|
const page = ref(1);
|
||||||
getList();
|
const loading = ref(false);
|
||||||
});
|
const finished = ref(false);
|
||||||
const page = ref(1)
|
const error = ref(null);
|
||||||
const loading = ref(false)
|
const refreshing = ref(false);
|
||||||
const finished = ref(false)
|
|
||||||
|
|
||||||
function getList() {
|
// 获取设计记录列表
|
||||||
if(loading.value) return
|
async function getList() {
|
||||||
loading.value = true
|
// 如果正在加载或者已经加载完所有数据,则返回
|
||||||
|
console.log(loading.value, finished.value);
|
||||||
|
if (loading.value || finished.value) return;
|
||||||
|
|
||||||
badgeApi.getLogOage({
|
loading.value = true;
|
||||||
|
error.value = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 修复API调用中的拼写错误
|
||||||
|
const res = await badgeApi.getLogOage({
|
||||||
page: page.value,
|
page: page.value,
|
||||||
size: 100,
|
size: 20,
|
||||||
}).then(res => {
|
});
|
||||||
if(page.value === 1) {
|
|
||||||
images.value = res.list
|
if (page.value === 1) {
|
||||||
|
images.value = res.list || [];
|
||||||
} else {
|
} else {
|
||||||
images.value.push(...res.list)
|
images.value.push(...(res.list || []));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(res.total <= images.value.length) {
|
// 判断是否还有更多数据
|
||||||
finished.value = true
|
if (!res.list || res.list.length < 20) {
|
||||||
|
finished.value = true;
|
||||||
} else {
|
} else {
|
||||||
page.value++
|
page.value++;
|
||||||
|
}
|
||||||
|
} catch (err: any) {
|
||||||
|
error.value = err.message || '获取数据失败';
|
||||||
|
console.error('获取设计记录失败', err);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
|
||||||
loading.value = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查看设计预览
|
||||||
function goPreview(item) {
|
function goPreview(item) {
|
||||||
router.push({
|
router.push({
|
||||||
path: '/badge/preview',
|
path: '/badge/preview',
|
||||||
@@ -77,53 +96,85 @@ function goPreview(item) {
|
|||||||
key: item.num,
|
key: item.num,
|
||||||
prod_id: item.prod_id
|
prod_id: item.prod_id
|
||||||
},
|
},
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 上拉加载更多
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
getList()
|
loading.value = false;
|
||||||
|
getList();
|
||||||
}
|
}
|
||||||
const router = useRouter();
|
|
||||||
|
// 下拉刷新
|
||||||
|
async function onRefresh() {
|
||||||
|
refreshing.value = true;
|
||||||
|
page.value = 1;
|
||||||
|
finished.value = false;
|
||||||
|
await getList();
|
||||||
|
refreshing.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回上一页
|
||||||
function goBack() {
|
function goBack() {
|
||||||
router.push('/badge');
|
router.push('/badge');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 组件挂载时获取数据
|
||||||
|
onMounted(() => {
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 组件卸载时清理
|
||||||
|
onUnmounted(() => {
|
||||||
|
loading.value = false;
|
||||||
|
finished.value = false;
|
||||||
|
page.value = 1;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.header {
|
.header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #999;
|
color: #999;
|
||||||
padding: 16px 16px 0 16px;
|
padding: 16px 16px 0 16px;
|
||||||
}
|
}
|
||||||
.back-icon {
|
|
||||||
|
.back-icon {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
color: #222;
|
color: #222;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.record-container {
|
|
||||||
|
.record-container {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
.record-note {
|
|
||||||
|
.record-note {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
color: #999;
|
color: #999;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
.record-images {
|
|
||||||
|
.record-images {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
grid-template-columns: repeat(2, 1fr);
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
.record-image-item {
|
|
||||||
|
.record-image-item {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding-bottom: 100%;
|
padding-bottom: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
}
|
}
|
||||||
.record-image-item img {
|
|
||||||
|
.record-image {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -131,18 +182,20 @@ function goBack() {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
.record-image-item-shadow {
|
|
||||||
|
.record-image-item-shadow {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.5),inset -2px -2px 4px rgba(0, 0, 0, 0.2);
|
box-shadow: inset 2px 2px 4px rgba(255, 255, 255, 0.5), inset -2px -2px 4px rgba(0, 0, 0, 0.2);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
}
|
}
|
||||||
.record-image-item-loading {
|
|
||||||
|
.record-image-item-loading {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -155,15 +208,17 @@ function goBack() {
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
.record-image-item-null {
|
|
||||||
|
.record-image-item-null {
|
||||||
height: 50vh;
|
height: 50vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.record-image-item-null img {
|
|
||||||
|
.record-image-item-null img {
|
||||||
width: 80vw;
|
width: 80vw;
|
||||||
height: 200px;
|
height: 200px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in new issue
Block a user