Files
lilishop-uniapp/pages/product/shopPageGoods.vue
Yer11214 349ffa4f34 refactor: 重构多个组件以支持 Vue 3 语法和功能
- 将多个组件转换为 `<script setup>` 语法,提升可读性和性能
- 优化状态管理和事件处理逻辑,简化代码结构
- 更新样式和布局以适应新组件结构
- 添加新功能和修复已知问题,提升用户体验
2026-07-08 18:37:11 +08:00

77 lines
1.6 KiB
Vue

<template>
<div>
<u-navbar
:title="title"
:fixed="true"
:placeholder="true"
:border="false"
:auto-back="true"
></u-navbar>
<!-- 商品 -->
<div class="contant">
<view v-if="!goodsList.length" class="empty">暂无商品信息</view>
<goodsTemplate style="width: 100%;" :res='goodsList' :storeName='false' />
</div>
</div>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue'
import { onLoad, onReachBottom, onShow } from '@dcloudio/uni-app'
import { getGoodsList } from '@/api/goods.js'
import goodsTemplate from '@/components/m-goods-list/list'
const title = ref('')
const routerVal = ref<any>('')
const goodsList = ref<any[]>([])
const params = reactive({
pageNumber: 1,
pageSize: 10,
keyword: '',
storeCatId: '',
storeId: '',
})
async function getGoodsData() {
const res = await getGoodsList(params)
if (res.data.success) {
goodsList.value.push(...res.data.result.records)
}
}
onLoad((options: any) => {
routerVal.value = options
params.storeId = options.storeId
params.storeCatId = options.id
title.value = options.title
})
onShow(() => {
goodsList.value = []
params.pageNumber = 1
getGoodsData()
})
onReachBottom(() => {
params.pageNumber++
getGoodsData()
})
</script>
<style lang="scss" scoped>
.contant {
margin-top: 20rpx;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
>.empty {
width: 100%;
display: flex;
justify-content: center;
margin-top: 40rpx;
}
}
</style>