对接购物车列表
This commit is contained in:
@@ -34,21 +34,25 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
]
|
||||
const [selectIndex, setSelectIndex] = useState(0)
|
||||
const selectProduct = (index:number) => {
|
||||
console.log('number::',index)
|
||||
setSelectIndex(() => index)
|
||||
//重置数据
|
||||
const newList = initList(list)
|
||||
setList([...newList])
|
||||
condition.current.code_or_name = null
|
||||
setSearchShow(false)
|
||||
}
|
||||
|
||||
//获取面料颜色列表
|
||||
const {fetchData:colorFetchData, state: colorState} = GetColorList()
|
||||
const [list, setList] = useState<any[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const condition = useRef({physical_warehouse:adminUserInfo.physical_warehouse, sale_mode:selectIndex, product_id:0, code_or_name:null})
|
||||
const condition = useRef({physical_warehouse:adminUserInfo?.physical_warehouse, sale_mode:selectIndex, product_id:0, code_or_name:null})
|
||||
const getColorList = async () => {
|
||||
setLoading(() => true)
|
||||
console.log('数据:::',getFilterData(condition.current))
|
||||
let {data} = await colorFetchData(getFilterData(condition.current))
|
||||
const list = initList(data.list)
|
||||
setList([...list])
|
||||
let lists = initList(data.list)
|
||||
setList([...lists])
|
||||
setLoading(() => false)
|
||||
}
|
||||
const [showPopup, setShowPopup] = useState(false)
|
||||
@@ -63,7 +67,6 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
setSelectIndex(0)
|
||||
condition.current.code_or_name = null
|
||||
setSearchShow(false)
|
||||
|
||||
condition.current.product_id = productId
|
||||
getColorList()
|
||||
}
|
||||
@@ -138,6 +141,16 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
const {getSelfUserInfo} = UseLogin()
|
||||
const {fetchData:addFetchData} = AddShoppingCartApi()
|
||||
const addShopCart = async () => {
|
||||
try {
|
||||
await getSelfUserInfo()
|
||||
} catch(msg) {
|
||||
Taro.showToast({
|
||||
icon:'none',
|
||||
title:msg
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
if(selectCount.sumCount == 0) {
|
||||
Taro.showToast({
|
||||
icon:'none',
|
||||
@@ -145,7 +158,6 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
})
|
||||
return false
|
||||
}
|
||||
await getSelfUserInfo()
|
||||
const state = await addFetchData({
|
||||
"sale_mode": selectIndex,
|
||||
color_list: selectCount.color_list
|
||||
@@ -165,7 +177,7 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
}
|
||||
|
||||
//显示金额
|
||||
const priceFormat = useCallback((item) => {
|
||||
const priceFormat = (item) => {
|
||||
let price = 0
|
||||
if(selectIndex == 0) {
|
||||
price = formatMillionYuan(item.bulk_price, 100).num
|
||||
@@ -175,15 +187,7 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
price = formatMillionYuan(item.weight_cut_price, 100).num
|
||||
}
|
||||
return <View className={styles.priceText}><Text>¥</Text>{Number(price) }<Text>{' /' + selectList[selectIndex].eunit}</Text></View>
|
||||
}, [list, selectIndex])
|
||||
|
||||
//重置数据
|
||||
useEffect(() => {
|
||||
const newList = initList(list)
|
||||
setList([...newList])
|
||||
// condition.current.code_or_name = null
|
||||
// setSearchShow(false)
|
||||
}, [selectIndex])
|
||||
}
|
||||
|
||||
//筛选数据
|
||||
const searchInput = (e) => {
|
||||
@@ -219,7 +223,7 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
<View className={styles.text} onClick={() => clearSearch()}>取消</View>
|
||||
</View>}
|
||||
<View className={styles.colorNum}>
|
||||
<View className={styles.title}>颜色分类 (13)</View>
|
||||
<View className={styles.title}>颜色分类 ({list.length})</View>
|
||||
{!searchShow&&<View className={classnames('iconfont icon-sousuo', styles.miconfont)} onClick={() => changeSearchShow()}></View>}
|
||||
</View>
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { formatImgUrl } from "@/common/fotmat"
|
||||
import { Image, Swiper, SwiperItem, View } from "@tarojs/components"
|
||||
import { useMemo, useRef, useState } from "react"
|
||||
import styles from './index.module.scss'
|
||||
@@ -27,7 +28,7 @@ export default ({list = []}: params) => {
|
||||
{list.map((item) => {
|
||||
return <SwiperItem key={item.id}>
|
||||
<View className={styles.image_item} >
|
||||
<Image mode="aspectFill" src='https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F811%2F021315104H2%2F150213104H2-3-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651817947&t=5467a207f845ddfc7737d55934e6b26d'></Image>
|
||||
<Image mode="aspectFill" src={formatImgUrl(item)}></Image>
|
||||
</View>
|
||||
</SwiperItem>
|
||||
})}
|
||||
|
||||
Reference in New Issue
Block a user