|
@@ -14,6 +14,7 @@ import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
|
|
// 必须导入需要用到的页面生命周期(即使在当前页面上没有直接使用到)(使用页面滚动)
|
|
// 必须导入需要用到的页面生命周期(即使在当前页面上没有直接使用到)(使用页面滚动)
|
|
|
|
|
|
import { getList } from '@/api/product'
|
|
import { getList } from '@/api/product'
|
|
|
|
+import { toPage } from '@/utils/page'
|
|
|
|
|
|
defineOptions({
|
|
defineOptions({
|
|
name: 'Index', // 首页
|
|
name: 'Index', // 首页
|
|
@@ -84,47 +85,14 @@ const navIcons = ref([
|
|
},
|
|
},
|
|
])
|
|
])
|
|
|
|
|
|
-function toPage(url: string) {
|
|
|
|
- if (url) {
|
|
|
|
- uni.navigateTo({
|
|
|
|
- url,
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// 新品列表
|
|
// 新品列表
|
|
-const newProducts = ref([
|
|
|
|
- {
|
|
|
|
- image: 'https://picsum.photos/260?random=1',
|
|
|
|
- title: 'Chanel Rouge Coco Shine…',
|
|
|
|
- price: '123',
|
|
|
|
- sold: 100,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- image: 'https://picsum.photos/260?random=2',
|
|
|
|
- title: 'Chanel Rouge Coco Shine…',
|
|
|
|
- price: '123',
|
|
|
|
- sold: 100,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- image: 'https://picsum.photos/260?random=3',
|
|
|
|
- title: 'Chanel Rouge Coco Shine…',
|
|
|
|
- price: '123',
|
|
|
|
- sold: 100,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- image: 'https://picsum.photos/260?random=4',
|
|
|
|
- title: 'Chanel Rouge Coco Shine…',
|
|
|
|
- price: '123',
|
|
|
|
- sold: 100,
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- image: 'https://picsum.photos/260?random=5',
|
|
|
|
- title: 'Chanel Rouge Coco Shine…',
|
|
|
|
- price: '123',
|
|
|
|
- sold: 100,
|
|
|
|
- },
|
|
|
|
-])
|
|
|
|
|
|
+const newProducts = ref<any>([])
|
|
|
|
+
|
|
|
|
+async function getNewList() {
|
|
|
|
+ const res = await getList({ page: 1, size: 10, isNew: true })
|
|
|
|
+ console.log(res)
|
|
|
|
+ newProducts.value = res.data.list
|
|
|
|
+}
|
|
|
|
|
|
// 商品列表
|
|
// 商品列表
|
|
const priceTab = ref<number>(0)
|
|
const priceTab = ref<number>(0)
|
|
@@ -149,29 +117,20 @@ const priceTabList = ref([
|
|
},
|
|
},
|
|
])
|
|
])
|
|
|
|
|
|
-const dataList = ref([])
|
|
|
|
|
|
+const dataList = ref<any>([])
|
|
async function queryList(pageNo, pageSize) {
|
|
async function queryList(pageNo, pageSize) {
|
|
const data = { page: pageNo, size: pageSize }
|
|
const data = { page: pageNo, size: pageSize }
|
|
const res = await getList(data)
|
|
const res = await getList(data)
|
|
- console.log(res)
|
|
|
|
- paging.value.complete(dataList.value)
|
|
|
|
|
|
+ paging.value.complete(res.data.list)
|
|
}
|
|
}
|
|
|
|
|
|
-function toProductDetail(item) {
|
|
|
|
- const data = JSON.stringify({ id: item.id })
|
|
|
|
- uni.navigateTo({
|
|
|
|
- url: `/pages/productDetail/productDetail?data=${encodeURIComponent(data)}`,
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
-function toNotifications() {
|
|
|
|
- uni.navigateTo({
|
|
|
|
- url: '/pages/notifications/notifications',
|
|
|
|
- })
|
|
|
|
-}
|
|
|
|
|
|
+onLoad(() => {
|
|
|
|
+ getNewList()
|
|
|
|
+})
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<template>
|
|
<template>
|
|
- <z-paging ref="paging" use-page-scroll @query="queryList">
|
|
|
|
|
|
+ <z-paging ref="paging" v-model="dataList" use-page-scroll @query="queryList">
|
|
<template #top>
|
|
<template #top>
|
|
<view
|
|
<view
|
|
class="flex items-center justify-between bg-white pb-40rpx pl-42rpx pr-34rpx pt-26rpx"
|
|
class="flex items-center justify-between bg-white pb-40rpx pl-42rpx pr-34rpx pt-26rpx"
|
|
@@ -180,7 +139,7 @@ function toNotifications() {
|
|
<image src="/static/header-logo.png" class="h-54rpx w-250rpx" />
|
|
<image src="/static/header-logo.png" class="h-54rpx w-250rpx" />
|
|
<view class="flex items-center">
|
|
<view class="flex items-center">
|
|
<wd-icon custom-class="mr-20rpx" name="search1" size="38rpx" @click="toSearch" />
|
|
<wd-icon custom-class="mr-20rpx" name="search1" size="38rpx" @click="toSearch" />
|
|
- <wd-icon name="notification" size="38rpx" @click="toNotifications" />
|
|
|
|
|
|
+ <wd-icon name="notification" size="38rpx" @click="toPage('/pages/notifications/notifications')" />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
</template>
|
|
@@ -207,7 +166,7 @@ function toNotifications() {
|
|
</view>
|
|
</view>
|
|
<scroll-view scroll-x>
|
|
<scroll-view scroll-x>
|
|
<view class="flex items-center gap-22rpx pb-24rpx">
|
|
<view class="flex items-center gap-22rpx pb-24rpx">
|
|
- <product v-for="(item, index) in newProducts" :key="index" :item="item" @item-click="toProductDetail" />
|
|
|
|
|
|
+ <product v-for="(item, index) in newProducts" :key="index" :item="item" @item-click="toPage('/pages/productDetail/productDetail', { id: item.id })" />
|
|
</view>
|
|
</view>
|
|
</scroll-view>
|
|
</scroll-view>
|
|
</view>
|
|
</view>
|
|
@@ -217,9 +176,8 @@ function toNotifications() {
|
|
<wd-tab :title="item.title" />
|
|
<wd-tab :title="item.title" />
|
|
</block>
|
|
</block>
|
|
</wd-tabs>
|
|
</wd-tabs>
|
|
- <view class="flex flex-wrap gap-22rpx">
|
|
|
|
- <product v-for="(item, index) in newProducts" :key="index" :height="340" :item="item" @item-click="toProductDetail" />
|
|
|
|
- <view />
|
|
|
|
|
|
+ <view class="grid grid-cols-2 gap-22rpx">
|
|
|
|
+ <product v-for="(item, index) in newProducts" :key="index" flex width="100%" :height="340" :item="item" @item-click="toPage('/pages/productDetail/productDetail', { id: item.id })" />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|