|
|
@@ -1,6 +1,8 @@
|
|
|
import * as WebBrowser from 'expo-web-browser';
|
|
|
import * as React from 'react';
|
|
|
import { StyleSheet, View, Image } from 'react-native';
|
|
|
+import { Div, Text } from 'react-native-magnus';
|
|
|
+
|
|
|
import { Flex } from '@ant-design/react-native';
|
|
|
import { Modal, TouchableRipple, Badge } from 'react-native-paper';
|
|
|
import { ScrollView } from 'react-native-gesture-handler';
|
|
|
@@ -9,9 +11,9 @@ import { useCreation, useRequest } from '@umijs/hooks';
|
|
|
import { useNavigation, useFocusEffect } from '@react-navigation/native';
|
|
|
import useModel from 'flooks';
|
|
|
import Detail from './model';
|
|
|
+import MapModel from '../Map/model';
|
|
|
|
|
|
import Icon from '../../components/SvgIcon';
|
|
|
-import Text from '../../components/Text';
|
|
|
import Button from '../../components/Button';
|
|
|
import Plus from '../../components/Plus';
|
|
|
|
|
|
@@ -30,7 +32,8 @@ export default function Cart() {
|
|
|
clearCart,
|
|
|
setCartMap,
|
|
|
changeNum,
|
|
|
- } = useModel(Detail, ['id', 'merchantInfo']);
|
|
|
+ cartMoneyInfo,
|
|
|
+ } = useModel(Detail, ['id', 'merchantInfo', 'cartMoneyInfo']);
|
|
|
|
|
|
useFocusEffect(
|
|
|
React.useCallback(() => {
|
|
|
@@ -42,7 +45,7 @@ export default function Cart() {
|
|
|
|
|
|
const [cartList, setcartList] = React.useState([]);
|
|
|
|
|
|
- const { deliveryAmount, startingAmount } = merchantInfo;
|
|
|
+ const { startingAmount } = merchantInfo;
|
|
|
|
|
|
const [showList, setshowList] = React.useState(false);
|
|
|
|
|
|
@@ -83,11 +86,31 @@ export default function Cart() {
|
|
|
setCartMap(cartMap);
|
|
|
}, [cartMap]);
|
|
|
|
|
|
+ const {
|
|
|
+ deliveryAmount,
|
|
|
+ goodsTotal,
|
|
|
+ fullReduction,
|
|
|
+ packingPrice,
|
|
|
+ reducedAmount,
|
|
|
+ } = cartMoneyInfo;
|
|
|
+
|
|
|
+ // 钱
|
|
|
+
|
|
|
const price = useCreation(() => {
|
|
|
- return cartList.reduce((total, item) => {
|
|
|
- return accAdd(total, accMul(item.num, item.goodsRealPrice));
|
|
|
- }, 0);
|
|
|
- }, [num]);
|
|
|
+ if (goodsTotal) {
|
|
|
+ return (goodsTotal - reducedAmount).toFixed(2);
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }, [goodsTotal, reducedAmount]);
|
|
|
+
|
|
|
+ const total = useCreation(() => {
|
|
|
+ if (goodsTotal) {
|
|
|
+ return (goodsTotal + packingPrice - fullReduction).toFixed(2);
|
|
|
+ } else {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }, [goodsTotal, fullReduction, packingPrice]);
|
|
|
|
|
|
const canSubmit = useCreation(() => {
|
|
|
if (price >= startingAmount && num > 0) {
|
|
|
@@ -154,17 +177,26 @@ export default function Cart() {
|
|
|
</TouchableRipple>
|
|
|
|
|
|
<Flex.Item style={styles.center}>
|
|
|
- <Text
|
|
|
- size="s1"
|
|
|
- style={{
|
|
|
- lineHeight: 18,
|
|
|
- marginVertical: 0,
|
|
|
- }}
|
|
|
- color={num === 0 ? '#B4B4B4' : '#fff'}
|
|
|
- >
|
|
|
- {num === 0 ? '未选购商品' : `¥${price}`}
|
|
|
- </Text>
|
|
|
- <Text size="c2" type="info">
|
|
|
+ <Div row alignItems="center" h={18}>
|
|
|
+ <Text
|
|
|
+ fontSize="xl"
|
|
|
+ lineHeight={18}
|
|
|
+ color={num === 0 ? 'gray300' : 'white'}
|
|
|
+ >
|
|
|
+ {num === 0 ? '未选购商品' : `¥${price}`}
|
|
|
+ </Text>
|
|
|
+ <Text
|
|
|
+ fontSize="sm"
|
|
|
+ color="gray300"
|
|
|
+ lineHeight={18}
|
|
|
+ textDecorLine="line-through"
|
|
|
+ textDecorColor="gray300"
|
|
|
+ ml={5}
|
|
|
+ >
|
|
|
+ ¥{total}
|
|
|
+ </Text>
|
|
|
+ </Div>
|
|
|
+ <Text fontSize="xs" color="gray300">
|
|
|
另需配送费¥{deliveryAmount || 0}
|
|
|
</Text>
|
|
|
</Flex.Item>
|