diff --git a/src/pages/address/index.jsx b/src/pages/address/index.jsx index d960d2a..20f1ae6 100644 --- a/src/pages/address/index.jsx +++ b/src/pages/address/index.jsx @@ -86,11 +86,13 @@ function Index() { { list.map((item, index) => { return - { - setAddrId(item.id) - }}> - - + { + !home && { + setAddrId(item.id) + }}> + + + } { setAddrId(item.id) onSelect(item.id) diff --git a/src/pages/home/index.jsx b/src/pages/home/index.jsx index 1d0f7d4..38ea0f8 100644 --- a/src/pages/home/index.jsx +++ b/src/pages/home/index.jsx @@ -118,7 +118,7 @@ const Index = () => { 我的属性 - + {user.contribution} 贡献值 @@ -134,7 +134,7 @@ const Index = () => { 我的钱包 - + { navigateTo('/pages/balance/index') }}> @@ -169,19 +169,25 @@ const Index = () => { 邀请好友 - + { + navigateTo('/pages/shopping/index?source=shopping_score_mall') + }}> 购物金商城 - + { + navigateTo('/pages/address/index?home=home') + }}> 地址管理 - + { + navigateTo('/pages/team/index') + }}> diff --git a/src/pages/index/index.jsx b/src/pages/index/index.jsx index e6cc9c2..a4f793f 100644 --- a/src/pages/index/index.jsx +++ b/src/pages/index/index.jsx @@ -10,7 +10,7 @@ import Taro from '@tarojs/taro'; function Index() { - const limit = 10 + const limit = 20 const [list, setList] = useState([]) const [total, setTotal] = useState(0) const [page, setPage] = useState(1) @@ -32,7 +32,7 @@ function Index() { if (res.items?.length + list.length >= res.total) { setHasMore(false) } - setList(res.items) + setList(it => [...it, ...res.items]) setTotal(res.total) } diff --git a/src/pages/shopping/index.jsx b/src/pages/shopping/index.jsx index dcfd094..4655840 100644 --- a/src/pages/shopping/index.jsx +++ b/src/pages/shopping/index.jsx @@ -10,27 +10,41 @@ import { useEffect } from 'react'; import { useState } from 'react'; import Taro from '@tarojs/taro'; +import { mallList } from '../../utils/api'; +import { useRouter } from '@tarojs/taro'; function Index() { - + const param = useRouter().params + const limit = 20 const [list, setList] = useState([]) + const [total, setTotal] = useState(0) const [page, setPage] = useState(1) const [hasMore, setHasMore] = useState(true) + const [chan] = useState(param.source != 'shopping_score_mall' ? 'mall' : 'shopping_score_mall') + + useEffect(() => { - if (list.length > 50) { - setHasMore(false) + if (page < 1) { return } - let l = [] - for (let i = list.length; i < 10 + list.length; i++) { - l.push(i) - } - setList([...list, ...l]) - + fetchList(page) }, [page]) + const fetchList = async (page) => { + + const offset = (page - 1) * limit + const res = await mallList(chan, offset, limit) + + if (!res) return + if (res.items?.length + list.length >= res.total) { + setHasMore(false) + } + setList(it => [...it, ...res.items]) + setTotal(res.total) + } + // 跳转 const navDetailFn = (id) => { @@ -59,22 +73,22 @@ function Index() { { list.map(item => { - return { - navDetailFn(item) + return { + navDetailFn(item.id) }}> - + - 这个是商品的名称,但是可能有一点点的长 + {item.name} - + {/* 这个是商品的介绍 - - - ¥199 - 原价888 + */} + + ¥{item.price} + {/* 原价888 */}