暂时完成相关接口
This commit is contained in:
parent
dad0452831
commit
6d62c87253
@ -86,11 +86,13 @@ function Index() {
|
|||||||
{
|
{
|
||||||
list.map((item, index) => {
|
list.map((item, index) => {
|
||||||
return <View className='addr-item' key={item.id}>
|
return <View className='addr-item' key={item.id}>
|
||||||
<View className='addr-icon w-6 h-6' onClick={() => {
|
{
|
||||||
setAddrId(item.id)
|
!home && <View className='addr-icon w-6 h-6' onClick={() => {
|
||||||
}}>
|
setAddrId(item.id)
|
||||||
<Image src={addrId == item.id ? checked : uncheck} className="w-6 h-6" />
|
}}>
|
||||||
</View>
|
<Image src={addrId == item.id ? checked : uncheck} className="w-6 h-6" />
|
||||||
|
</View>
|
||||||
|
}
|
||||||
<View className='addr-item-content' onClick={() => {
|
<View className='addr-item-content' onClick={() => {
|
||||||
setAddrId(item.id)
|
setAddrId(item.id)
|
||||||
onSelect(item.id)
|
onSelect(item.id)
|
||||||
|
@ -118,7 +118,7 @@ const Index = () => {
|
|||||||
<View className='my-tool-box-title'>
|
<View className='my-tool-box-title'>
|
||||||
我的属性
|
我的属性
|
||||||
</View>
|
</View>
|
||||||
<View className='flex-around justify-center mt-22'>
|
<View className='flex-around justify-center mt18'>
|
||||||
<View className='bal-item-content flex-col items-center'>
|
<View className='bal-item-content flex-col items-center'>
|
||||||
<Text>{user.contribution}</Text>
|
<Text>{user.contribution}</Text>
|
||||||
<Text className='bal-item-helper'>贡献值</Text>
|
<Text className='bal-item-helper'>贡献值</Text>
|
||||||
@ -134,7 +134,7 @@ const Index = () => {
|
|||||||
<View className='my-tool-box-title'>
|
<View className='my-tool-box-title'>
|
||||||
我的钱包
|
我的钱包
|
||||||
</View>
|
</View>
|
||||||
<View className='flex-between mt-22'>
|
<View className='flex-between mt18'>
|
||||||
<View className='bal-item-content flex-col items-center' onClick={() => {
|
<View className='bal-item-content flex-col items-center' onClick={() => {
|
||||||
navigateTo('/pages/balance/index')
|
navigateTo('/pages/balance/index')
|
||||||
}}>
|
}}>
|
||||||
@ -169,19 +169,25 @@ const Index = () => {
|
|||||||
<Text>邀请好友</Text>
|
<Text>邀请好友</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View className='flex-col my-order-tool-item'>
|
<View className='flex-col my-order-tool-item' onClick={() => {
|
||||||
|
navigateTo('/pages/shopping/index?source=shopping_score_mall')
|
||||||
|
}}>
|
||||||
<View className="relative my-order-tool-box">
|
<View className="relative my-order-tool-box">
|
||||||
<Image className='my-tool-icon' src={mall} />
|
<Image className='my-tool-icon' src={mall} />
|
||||||
</View>
|
</View>
|
||||||
<Text>购物金商城</Text>
|
<Text>购物金商城</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className='flex-col my-order-tool-item'>
|
<View className='flex-col my-order-tool-item' onClick={() => {
|
||||||
|
navigateTo('/pages/address/index?home=home')
|
||||||
|
}}>
|
||||||
<View className="relative my-order-tool-box">
|
<View className="relative my-order-tool-box">
|
||||||
<Image className='my-tool-icon' src={addr} />
|
<Image className='my-tool-icon' src={addr} />
|
||||||
</View>
|
</View>
|
||||||
<Text>地址管理</Text>
|
<Text>地址管理</Text>
|
||||||
</View>
|
</View>
|
||||||
<View className='flex-col my-order-tool-item'>
|
<View className='flex-col my-order-tool-item' onClick={() => {
|
||||||
|
navigateTo('/pages/team/index')
|
||||||
|
}}>
|
||||||
<View className="relative my-order-tool-box">
|
<View className="relative my-order-tool-box">
|
||||||
<Image className='my-tool-icon' src={team} />
|
<Image className='my-tool-icon' src={team} />
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import Taro from '@tarojs/taro';
|
|||||||
|
|
||||||
|
|
||||||
function Index() {
|
function Index() {
|
||||||
const limit = 10
|
const limit = 20
|
||||||
const [list, setList] = useState([])
|
const [list, setList] = useState([])
|
||||||
const [total, setTotal] = useState(0)
|
const [total, setTotal] = useState(0)
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
@ -32,7 +32,7 @@ function Index() {
|
|||||||
if (res.items?.length + list.length >= res.total) {
|
if (res.items?.length + list.length >= res.total) {
|
||||||
setHasMore(false)
|
setHasMore(false)
|
||||||
}
|
}
|
||||||
setList(res.items)
|
setList(it => [...it, ...res.items])
|
||||||
setTotal(res.total)
|
setTotal(res.total)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,27 +10,41 @@ import { useEffect } from 'react';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
|
import { mallList } from '../../utils/api';
|
||||||
|
import { useRouter } from '@tarojs/taro';
|
||||||
|
|
||||||
|
|
||||||
function Index() {
|
function Index() {
|
||||||
|
const param = useRouter().params
|
||||||
|
const limit = 20
|
||||||
const [list, setList] = useState([])
|
const [list, setList] = useState([])
|
||||||
|
const [total, setTotal] = useState(0)
|
||||||
const [page, setPage] = useState(1)
|
const [page, setPage] = useState(1)
|
||||||
const [hasMore, setHasMore] = useState(true)
|
const [hasMore, setHasMore] = useState(true)
|
||||||
|
const [chan] = useState(param.source != 'shopping_score_mall' ? 'mall' : 'shopping_score_mall')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (list.length > 50) {
|
if (page < 1) {
|
||||||
setHasMore(false)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let l = []
|
fetchList(page)
|
||||||
for (let i = list.length; i < 10 + list.length; i++) {
|
|
||||||
l.push(i)
|
|
||||||
}
|
|
||||||
setList([...list, ...l])
|
|
||||||
|
|
||||||
}, [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) => {
|
const navDetailFn = (id) => {
|
||||||
@ -59,22 +73,22 @@ function Index() {
|
|||||||
<View className='shopping-container '>
|
<View className='shopping-container '>
|
||||||
{
|
{
|
||||||
list.map(item => {
|
list.map(item => {
|
||||||
return <View className='shopping-item' key={item} onClick={() => {
|
return <View className='shopping-item' key={item.id} onClick={() => {
|
||||||
navDetailFn(item)
|
navDetailFn(item.id)
|
||||||
}}>
|
}}>
|
||||||
<View className='shopping-item-image'>
|
<View className='shopping-item-image'>
|
||||||
<Image src='https://img.yzcdn.cn/vant/cat.jpeg' />
|
<Image src={item.cover_image} />
|
||||||
</View>
|
</View>
|
||||||
<View className='shopping-item-content'>
|
<View className='shopping-item-content'>
|
||||||
<View className='shopping-item-name line-clamp-2'>
|
<View className='shopping-item-name line-clamp-2'>
|
||||||
这个是商品的名称,但是可能有一点点的长
|
{item.name}
|
||||||
</View>
|
</View>
|
||||||
<View className='shopping-item-desc line-clamp-2 '>
|
{/* <View className='shopping-item-desc line-clamp-2 '>
|
||||||
这个是商品的介绍
|
这个是商品的介绍
|
||||||
</View>
|
</View> */}
|
||||||
<View className='shopping-item-price text-right'>
|
<View className='shopping-item-price text-left'>
|
||||||
<Text className='shopping-item-price-sale'>¥199</Text>
|
<Text className='shopping-item-price-sale'>¥{item.price}</Text>
|
||||||
<Text className='shopping-item-price-origin'>原价888</Text>
|
{/* <Text className='shopping-item-price-origin'>原价888</Text> */}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user