2022-11-22 07:45:36 +00:00
|
|
|
<template>
|
|
|
|
<su-popup :show="show" showClose round="10" backgroundColor="#eee" @close="emits('close')">
|
|
|
|
<view class="select-popup">
|
|
|
|
<view class="title">
|
|
|
|
<span>{{ mode == 'goods' ? '我的浏览' : '我的订单' }}</span>
|
|
|
|
</view>
|
|
|
|
<scroll-view
|
|
|
|
class="scroll-box"
|
|
|
|
scroll-y="true"
|
|
|
|
:scroll-with-animation="true"
|
|
|
|
:show-scrollbar="false"
|
|
|
|
@scrolltolower="loadmore"
|
|
|
|
>
|
|
|
|
<view
|
|
|
|
class="item"
|
|
|
|
v-for="item in state.pagination.data"
|
2024-07-09 08:17:56 +00:00
|
|
|
:key="item.id"
|
2022-11-22 07:45:36 +00:00
|
|
|
@tap="emits('select', { type: mode, data: item })"
|
|
|
|
>
|
|
|
|
<template v-if="mode == 'goods'">
|
2024-07-09 08:17:56 +00:00
|
|
|
<GoodsItem :goodsData="item" />
|
2022-11-22 07:45:36 +00:00
|
|
|
</template>
|
|
|
|
<template v-if="mode == 'order'">
|
|
|
|
<OrderItem :orderData="item" />
|
|
|
|
</template>
|
|
|
|
</view>
|
|
|
|
<uni-load-more :status="state.loadStatus" :content-text="{ contentdown: '上拉加载更多' }" />
|
|
|
|
</scroll-view>
|
|
|
|
</view>
|
|
|
|
</su-popup>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { reactive, watch } from 'vue';
|
2024-08-04 09:11:12 +00:00
|
|
|
import _ from 'lodash-es';
|
2022-11-22 07:45:36 +00:00
|
|
|
import GoodsItem from './goods.vue';
|
|
|
|
import OrderItem from './order.vue';
|
2024-01-17 11:45:39 +00:00
|
|
|
import OrderApi from '@/sheep/api/trade/order';
|
|
|
|
import SpuHistoryApi from '@/sheep/api/product/history';
|
2022-11-22 07:45:36 +00:00
|
|
|
|
|
|
|
const emits = defineEmits(['select', 'close']);
|
|
|
|
const props = defineProps({
|
|
|
|
mode: {
|
|
|
|
type: String,
|
|
|
|
default: 'goods',
|
|
|
|
},
|
|
|
|
show: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => props.mode,
|
|
|
|
() => {
|
|
|
|
state.pagination.data = [];
|
|
|
|
if (props.mode) {
|
|
|
|
getList(state.pagination.page);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
|
|
|
|
const state = reactive({
|
|
|
|
loadStatus: '',
|
|
|
|
pagination: {
|
|
|
|
data: [],
|
|
|
|
current_page: 1,
|
|
|
|
total: 1,
|
|
|
|
last_page: 1,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
async function getList(page, list_rows = 5) {
|
|
|
|
state.loadStatus = 'loading';
|
|
|
|
const res =
|
|
|
|
props.mode == 'goods'
|
2024-01-17 11:45:39 +00:00
|
|
|
? await SpuHistoryApi.getBrowseHistoryPage({
|
2022-11-22 07:45:36 +00:00
|
|
|
page,
|
|
|
|
list_rows,
|
|
|
|
})
|
2024-01-17 11:45:39 +00:00
|
|
|
: await OrderApi.getOrderPage({
|
2022-11-22 07:45:36 +00:00
|
|
|
page,
|
|
|
|
list_rows,
|
|
|
|
});
|
2024-07-09 08:17:56 +00:00
|
|
|
let orderList = _.concat(state.pagination.data, res.data.list);
|
2022-11-22 07:45:36 +00:00
|
|
|
state.pagination = {
|
|
|
|
...res.data,
|
|
|
|
data: orderList,
|
|
|
|
};
|
|
|
|
if (state.pagination.current_page < state.pagination.last_page) {
|
|
|
|
state.loadStatus = 'more';
|
|
|
|
} else {
|
|
|
|
state.loadStatus = 'noMore';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadmore() {
|
|
|
|
if (state.loadStatus !== 'noMore') {
|
|
|
|
getList(state.pagination.current_page + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.select-popup {
|
|
|
|
max-height: 600rpx;
|
|
|
|
|
|
|
|
.title {
|
|
|
|
height: 100rpx;
|
|
|
|
line-height: 100rpx;
|
|
|
|
padding: 0 26rpx;
|
|
|
|
background: #fff;
|
|
|
|
border-radius: 20rpx 20rpx 0 0;
|
|
|
|
|
|
|
|
span {
|
|
|
|
font-size: 32rpx;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
content: '';
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 2px;
|
|
|
|
z-index: 1;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
bottom: -15px;
|
|
|
|
background: var(--ui-BG-Main);
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.scroll-box {
|
|
|
|
height: 500rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.item {
|
|
|
|
background: #fff;
|
|
|
|
margin: 26rpx 26rpx 0;
|
|
|
|
border-radius: 20rpx;
|
|
|
|
|
|
|
|
:deep() {
|
|
|
|
.image {
|
|
|
|
width: 140rpx;
|
|
|
|
height: 140rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|