对接api3
This commit is contained in:
@@ -11,7 +11,7 @@ export default ({desStatus = true, productList = []}:Params) => {
|
||||
return (
|
||||
<View className={styles.products_list}>
|
||||
{productList.map(item => {
|
||||
return <View className={styles.products_item} onClick={() => goLink('/pages/details/index?id=1')}>
|
||||
return <View className={styles.products_item} onClick={() => goLink(`/pages/details/index?id=${item.id}`)}>
|
||||
<View className={styles.item_img}>
|
||||
<Image src={item.texture_url}/>
|
||||
<View className={styles.num}>{item.product_color_count}色</View>
|
||||
|
||||
@@ -8,6 +8,7 @@ import styles from "./index.module.scss"
|
||||
import { useEffect, useState } from "react";
|
||||
import Taro from "@tarojs/taro";
|
||||
import { goLink } from "@/common/common";
|
||||
import {GetShoppingCartApi} from "@/api/shopCart"
|
||||
|
||||
type param = {
|
||||
show?: true|false,
|
||||
@@ -20,21 +21,21 @@ export default ({show = false, onClose}: param) => {
|
||||
setSelectIndex(index)
|
||||
}
|
||||
|
||||
//获取数据
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const {fetchData} = GetShoppingCartApi()
|
||||
const getShoppingCart = async () => {
|
||||
setLoading(true)
|
||||
const {data} = await fetchData()
|
||||
setList(data)
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if(!show) return
|
||||
let lists:any[] = []
|
||||
for(let i = 0; i < 20; i++) {
|
||||
lists = [...lists, {
|
||||
title:`${i}#薄荷绿`,
|
||||
subtitle: '0770# 21S单面平纹(食毛)',
|
||||
tag: '剪板',
|
||||
select: i%2?true: false
|
||||
}]
|
||||
}
|
||||
setList([...lists])
|
||||
getShoppingCart()
|
||||
}, [show])
|
||||
|
||||
useEffect(() => {
|
||||
@@ -137,7 +138,7 @@ export default ({show = false, onClose}: param) => {
|
||||
})}
|
||||
</View>
|
||||
</InfiniteScroll>}
|
||||
{!loading&&list.length > 0&&<View className={styles.empty}>
|
||||
{!loading&&list.length == 0 &&<View className={styles.empty}>
|
||||
<View className={styles.title}>暂未选择商品</View>
|
||||
<View className={styles.btn}>去选购</View>
|
||||
</View>}
|
||||
|
||||
Reference in New Issue
Block a user