feat: 添加收支明细页面、修改我的店铺展示、ai店铺-列表记录添加分页
This commit is contained in:
+52
-62
@@ -4,71 +4,63 @@
|
||||
<view class="share-btn" @tap="onShare">一键分享</view>
|
||||
</template>
|
||||
<view class="list-record-page">
|
||||
<view class="hero">
|
||||
<image class="hero-img" :src="cover || '/static/home/bc.png'" mode="aspectFill" />
|
||||
</view>
|
||||
<card_mescroll ref="cardPages" @upCallback="getList" :height="scrollHeight" :pageSize="pageSize">
|
||||
<view class="hero">
|
||||
<image class="hero-img" :src="cover || '/static/home/bc.png'" mode="aspectFill" />
|
||||
</view>
|
||||
|
||||
<view class="record-list">
|
||||
<view class="record-card" v-for="(item, i) in recordList" :key="item.id || i">
|
||||
<view class="record-head flex-between">
|
||||
<view class="record-title lineOne">{{ item.title }}</view>
|
||||
<view class="record-status" :class="`status-${item.status}`">{{ item.statusText }}</view>
|
||||
</view>
|
||||
|
||||
<view class="record-progress">
|
||||
<view class="progress-bar">
|
||||
<view class="progress" :style="{ width: `${item.progress}%` }"></view>
|
||||
<view class="progress-percent">{{ formatPercent(item.progress) }}%</view>
|
||||
<view class="record-list">
|
||||
<view class="record-card" v-for="(item, i) in recordList" :key="item.id || i">
|
||||
<view class="record-head flex-between">
|
||||
<view class="record-title lineOne">{{ item.title }}</view>
|
||||
<view class="record-status" :class="`status-${item.status}`">{{ item.statusText }}</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="record-meta">
|
||||
<view class="meta-row flex-row-end">
|
||||
<view class="record-total-inline">
|
||||
<!-- <view class="total-price">¥{{ formatMoney(item.total) }}</view> -->
|
||||
<view class="record-progress">
|
||||
<view class="progress-bar">
|
||||
<view class="progress" :style="{ width: `${item.progress}%` }"></view>
|
||||
<view class="progress-percent">{{ formatPercent(item.progress) }}%</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="meta-row flex-between">
|
||||
<view class="record-time">下单时间:{{ item.time }}</view>
|
||||
<view class="record-qty">数量 {{ item.qty }}</view>
|
||||
|
||||
<view class="record-meta">
|
||||
<view class="meta-row flex-row-end">
|
||||
<view class="record-total-inline">
|
||||
<!-- <view class="total-price">¥{{ formatMoney(item.total) }}</view> -->
|
||||
</view>
|
||||
</view>
|
||||
<view class="meta-row flex-between">
|
||||
<view class="record-time">下单时间:{{ item.time }}</view>
|
||||
<view class="record-qty">数量 {{ item.qty }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</card_mescroll>
|
||||
</view>
|
||||
</s-pages>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
|
||||
import { ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import sheep from '@/sheep';
|
||||
import { getAiShopPage } from '@/sheep/api/ai';
|
||||
import card_mescroll from '@/components/card_pages/card_mescroll.vue';
|
||||
|
||||
const skuId = ref('');
|
||||
const cover = ref('');
|
||||
|
||||
const recordList = ref([]);
|
||||
const state = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
loading: false,
|
||||
finished: false,
|
||||
});
|
||||
const cardPages = ref(null);
|
||||
const pageSize = 10;
|
||||
const scrollHeight = ref('100%');
|
||||
|
||||
onLoad((query) => {
|
||||
skuId.value = query?.skuId ?? query?.shopId ?? '';
|
||||
fetchList(true);
|
||||
});
|
||||
|
||||
onPullDownRefresh(() => {
|
||||
fetchList(true).finally(() => {
|
||||
uni.stopPullDownRefresh();
|
||||
});
|
||||
});
|
||||
|
||||
onReachBottom(() => {
|
||||
fetchList(false);
|
||||
const sysInfo = uni.getSystemInfoSync();
|
||||
scrollHeight.value =
|
||||
sysInfo.windowHeight - sysInfo.statusBarHeight - uni.upx2px(88) + 'px';
|
||||
});
|
||||
|
||||
const formatPercent = (value) => {
|
||||
@@ -118,41 +110,35 @@
|
||||
};
|
||||
};
|
||||
|
||||
const fetchList = async (reset = false) => {
|
||||
if (state.loading) return;
|
||||
const getList = async (mescroll) => {
|
||||
if (!skuId.value) {
|
||||
uni.showToast({ title: '缺少 skuId', icon: 'none' });
|
||||
if (mescroll?.num === 1) recordList.value = [];
|
||||
cardPages.value?.getState(true, 0);
|
||||
return;
|
||||
}
|
||||
if (!reset && state.finished) return;
|
||||
state.loading = true;
|
||||
try {
|
||||
if (reset) {
|
||||
state.pageNo = 1;
|
||||
state.finished = false;
|
||||
}
|
||||
const res = await getAiShopPage({
|
||||
skuId: String(skuId.value),
|
||||
pageNo: String(state.pageNo),
|
||||
pageSize: String(state.pageSize),
|
||||
pageNo: String(mescroll?.num || 1),
|
||||
pageSize: String(mescroll?.size || pageSize),
|
||||
}).catch(() => ({ code: -1 }));
|
||||
if (res?.code !== 0) return;
|
||||
if (res?.code !== 0) {
|
||||
cardPages.value?.getState(false);
|
||||
return;
|
||||
}
|
||||
const list = Array.isArray(res?.data?.list) ? res.data.list : [];
|
||||
if (!cover.value && list.length) {
|
||||
if (mescroll?.num === 1 && list.length) {
|
||||
const firstItem = Array.isArray(list?.[0]?.items) ? list[0].items[0] : null;
|
||||
const picUrl = firstItem?.picUrl || '';
|
||||
if (picUrl) cover.value = sheep.$url.cdn(picUrl);
|
||||
}
|
||||
const mapped = list.map(mapOrderToRecord);
|
||||
if (reset) recordList.value = [];
|
||||
if (mescroll?.num === 1) recordList.value = [];
|
||||
recordList.value = recordList.value.concat(mapped);
|
||||
if (list.length < state.pageSize) {
|
||||
state.finished = true;
|
||||
} else {
|
||||
state.pageNo += 1;
|
||||
}
|
||||
cardPages.value?.getState(true, list.length);
|
||||
} catch (e) {
|
||||
cardPages.value?.getState(false);
|
||||
} finally {
|
||||
state.loading = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -162,6 +148,10 @@
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
:deep(.scon) {
|
||||
overflow-y: hidden !important;
|
||||
}
|
||||
|
||||
.list-record-page {
|
||||
padding: 0 32rpx 32rpx;
|
||||
min-height: 100%;
|
||||
|
||||
Reference in New Issue
Block a user