1
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {Image, ScrollView, View, Text } from "@tarojs/components"
|
||||
import {Image, ScrollView, View, Text, CustomWrapper } from "@tarojs/components"
|
||||
import Popup from "@/components/popup"
|
||||
import LoadingCard from "@/components/loadingCard";
|
||||
import Search from "@/components/search";
|
||||
@@ -27,20 +27,24 @@ type param = {
|
||||
export default memo(({show = false, onClose, title = '', productId = 0}: param) => {
|
||||
const {adminUserInfo} = useSelector(state => state.userInfo)
|
||||
|
||||
const selectList = [
|
||||
{id: 0, step:1, digits:0, maxNum:100000, defaultNum:1, title:'大货', unit:'件', eunit:'kg'},
|
||||
{id: 1, step:1, digits:2, maxNum:9.99, defaultNum:1, title:'剪板', unit:'米', eunit:'m'},
|
||||
{id: 2, step:1, digits:2, minNum:10, maxNum:100000, defaultNum:10, title:'散剪', unit:'米', eunit:'kg'},
|
||||
]
|
||||
const [selectList, setSelectList] = useState([
|
||||
{id: 0, step:1, digits:0, maxNum:100000, defaultNum:1, title:'大货', unit:'件', eunit:'kg', priceField:'bulk_price'},
|
||||
{id: 1, step:1, digits:2, maxNum:9.99, defaultNum:1, title:'剪板', unit:'米', eunit:'m', priceField:'length_cut_price'},
|
||||
{id: 2, step:1, digits:2, minNum:10, maxNum:100000, defaultNum:10, title:'散剪', unit:'米', eunit:'kg', priceField:'weight_cut_price'},
|
||||
])
|
||||
const [selectIndex, setSelectIndex] = useState(0)
|
||||
const selectProduct = (index:number) => {
|
||||
setSelectIndex(() => index)
|
||||
//重置数据
|
||||
|
||||
}
|
||||
|
||||
//重置数据
|
||||
useEffect(() => {
|
||||
const newList = initList(list)
|
||||
setList([...newList])
|
||||
condition.current.code_or_name = null
|
||||
setSearchShow(false)
|
||||
}
|
||||
}, [selectIndex])
|
||||
|
||||
//获取面料颜色列表
|
||||
const {fetchData:colorFetchData, state: colorState} = GetColorList()
|
||||
@@ -176,19 +180,6 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
|
||||
}
|
||||
|
||||
//显示金额
|
||||
const priceFormat = (item) => {
|
||||
let price = 0
|
||||
if(selectIndex == 0) {
|
||||
price = formatMillionYuan(item.bulk_price, 100).num
|
||||
} else if(selectIndex == 1) {
|
||||
price = formatMillionYuan(item.length_cut_price, 100).num
|
||||
} else {
|
||||
price = formatMillionYuan(item.weight_cut_price, 100).num
|
||||
}
|
||||
return <View className={styles.priceText}><Text>¥</Text>{Number(price) }<Text>{' /' + selectList[selectIndex].eunit}</Text></View>
|
||||
}
|
||||
|
||||
//筛选数据
|
||||
const searchInput = (e) => {
|
||||
condition.current.code_or_name = e
|
||||
@@ -202,6 +193,13 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
setSearchShow(false)
|
||||
}
|
||||
|
||||
//格式化金额
|
||||
const formatPrice = useCallback((item) => {
|
||||
const price = Number(formatMillionYuan(item[selectList[selectIndex].priceField], 100).num)
|
||||
return <View className={styles.priceText}><Text>¥</Text>{price}<Text> /{selectList[selectIndex].eunit}</Text></View>
|
||||
}, [selectIndex])
|
||||
|
||||
|
||||
return (
|
||||
<View className={styles.shop_cart_main}>
|
||||
|
||||
@@ -229,35 +227,39 @@ export default memo(({show = false, onClose, title = '', productId = 0}: param)
|
||||
|
||||
<View className={styles.product_color_con}>
|
||||
{(list.length <= 0 && colorState.loading)&&<LoadingCard/>}
|
||||
{(list.length > 0&& !colorState.loading)&&<InfiniteScroll moreStatus={false}>
|
||||
<View className={styles.color_con}>
|
||||
{list.map(item => {
|
||||
return <View className={styles.item}>
|
||||
<View className={styles.item_color}>
|
||||
<Image src={item.texture_url}/>
|
||||
{(list.length > 0&& !colorState.loading)&&
|
||||
|
||||
<InfiniteScroll moreStatus={false}>
|
||||
<View className={styles.color_con}>
|
||||
{list.map(item => {
|
||||
return <View className={styles.item} key={item.id}>
|
||||
<View className={styles.item_color}>
|
||||
<Image src={item.texture_url}/>
|
||||
</View>
|
||||
<View className={styles.item_con}>
|
||||
<View className={styles.title}>{formatHashTag(item.code, item.name)}</View>
|
||||
<View className={styles.num}>
|
||||
{formatPrice(item)}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.btn_con}>
|
||||
{!item.show&&<View className={styles.btn} onClick={() => onAdd(item)}>添加</View>
|
||||
||<View className={styles.btn_count}>
|
||||
<Counter
|
||||
onBlue={(e) => getInputValue(e, item)}
|
||||
defaultNum={item.count}
|
||||
step={selectList[selectIndex].step}
|
||||
digits={selectList[selectIndex].digits}
|
||||
onClickBtn={(e) => getInputValue(e, item)}
|
||||
unit={selectList[selectIndex].unit}
|
||||
minNum={selectList[selectIndex].minNum}
|
||||
maxNum={selectList[selectIndex].maxNum}
|
||||
/>
|
||||
</View>}
|
||||
</View>
|
||||
</View>
|
||||
<View className={styles.item_con}>
|
||||
<View className={styles.title}>{formatHashTag(item.code, item.name)}</View>
|
||||
<View className={styles.num}>{priceFormat(item)}</View>
|
||||
</View>
|
||||
<View className={styles.btn_con}>
|
||||
{!item.show&&<View className={styles.btn} onClick={() => onAdd(item)}>添加</View>
|
||||
||<View className={styles.btn_count}>
|
||||
<Counter
|
||||
onBlue={(e) => getInputValue(e, item)}
|
||||
defaultNum={item.count}
|
||||
step={selectList[selectIndex].step}
|
||||
digits={selectList[selectIndex].digits}
|
||||
onClickBtn={(e) => getInputValue(e, item)}
|
||||
unit={selectList[selectIndex].unit}
|
||||
minNum={selectList[selectIndex].minNum}
|
||||
maxNum={selectList[selectIndex].maxNum}
|
||||
/>
|
||||
</View>}
|
||||
</View>
|
||||
</View>
|
||||
})}
|
||||
</View>
|
||||
})}
|
||||
</View>
|
||||
</InfiniteScroll>}
|
||||
{(list.length <= 0 && !colorState.loading)&&<View className={styles.noData}>暂无此商品</View>}
|
||||
</View>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
import { Button, Image, RichText, ScrollView, Swiper, SwiperItem, Text, View } from '@tarojs/components'
|
||||
import { Button, CustomWrapper, Image, RichText, ScrollView, Swiper, SwiperItem, Text, View } from '@tarojs/components'
|
||||
import Taro, { useDidShow, usePullDownRefresh, useRouter, useShareAppMessage } from '@tarojs/taro';
|
||||
import classnames from "classnames";
|
||||
import DesSwiper from './components/swiper';
|
||||
@@ -170,7 +170,9 @@ export default (props:params) => {
|
||||
|| <View className={styles.buy_btn} onClick={(e) => placeOrder(e)}>开始下单</View>
|
||||
}
|
||||
</View>
|
||||
<OrderCount show={showOrderCount} onClose={() => setShowOrderCount(false)} title={productName} productId={productInfo.id}/>
|
||||
<CustomWrapper>
|
||||
<OrderCount show={showOrderCount} onClose={() => setShowOrderCount(false)} title={productName} productId={productInfo.id}/>
|
||||
</CustomWrapper>
|
||||
<ShopCart show={showCart} onClose={() => setShowCart(false)}/>
|
||||
<Preview value={colorInfo} show={showPreview} onClose={() => setShowPreview(false)}/>
|
||||
<View className='common_safe_area_y'></View>
|
||||
|
||||
Reference in New Issue
Block a user