mall-app-t/pages/index/product.vue

83 lines
1.9 KiB
Vue
Raw Normal View History

2024-05-22 15:42:13 +08:00
<template>
2024-05-28 18:22:58 +08:00
<pb-layout
title="产品"
navbar="normal"
tabbar="/pages/index/product"
:bgStyle="bgStyle"
opacityBgUi="bg-white"
color="black"
>
<view v-if="state.pagination.total > 0" class="goods-list ss-m-t-20">
<view class="ss-p-l-20 ss-p-r-20" v-for="item in state.pagination.list" :key="item.id">
<p-goods-column
size="lg"
:data="item"
:topRadius="10"
bottomRadius="10"
@click="peach.$router.go('/pages/goods/index', { id: item.id })"
/>
</view>
</view>
2024-05-27 00:51:03 +08:00
2024-05-28 18:22:58 +08:00
<uni-load-more
v-if="state.pagination.total > 0"
:status="state.loadStatus"
:content-text="{
contentdown: '上拉加载更多',
}"
@click="loadMore"
/>
<p-empty v-if="state.pagination.total === 0" icon="/static/soldout-empty.png" text="暂无产品" />
</pb-layout>
2024-05-22 15:42:13 +08:00
</template>
<script setup>
2024-05-27 00:51:03 +08:00
import { ref } from 'vue'
import { onLoad, onReachBottom } from '@dcloudio/uni-app'
import peach from '@/peach'
import _ from 'lodash'
2024-05-28 18:22:58 +08:00
import { resetPagination } from '@/peach/utils'
2024-05-27 00:51:03 +08:00
2024-05-22 15:42:13 +08:00
const bgStyle = {
2024-05-28 18:22:58 +08:00
backgroundImage: '',
backgroundColor: '',
description: '',
2024-05-27 00:51:03 +08:00
}
const state = ref({
2024-05-28 18:22:58 +08:00
pagination: {
list: [],
total: 0,
pageNo: 1,
pageSize: 6,
},
2024-05-27 00:51:03 +08:00
})
function emptyList() {
2024-05-28 18:22:58 +08:00
resetPagination(state.value.pagination)
2024-05-27 00:51:03 +08:00
}
function onSearch() {
2024-05-28 18:22:58 +08:00
emptyList()
getList()
2024-05-22 15:42:13 +08:00
}
2024-05-27 00:51:03 +08:00
2024-05-28 18:22:58 +08:00
function getList() {}
2024-05-27 00:51:03 +08:00
function loadMore() {
2024-05-28 18:22:58 +08:00
if (state.value.loadStatus === 'noMore') {
return
}
state.value.pagination.pageNo++
getList()
2024-05-27 00:51:03 +08:00
}
onLoad(async (options) => {
2024-05-28 18:22:58 +08:00
getList()
2024-05-27 00:51:03 +08:00
})
onReachBottom(() => {
2024-05-28 18:22:58 +08:00
loadMore()
2024-05-27 00:51:03 +08:00
})
2024-05-22 15:42:13 +08:00
</script>