|
|
|
@ -12,6 +12,7 @@ import {
|
|
|
|
|
Platform, |
|
|
|
|
StatusBar, |
|
|
|
|
SafeAreaView, |
|
|
|
|
ActivityIndicator, |
|
|
|
|
} from "react-native"; |
|
|
|
|
import fontSize from "../utils/fontsizeUtils"; |
|
|
|
|
import CircleOutlineIcon from "../components/CircleOutlineIcon"; |
|
|
|
@ -33,7 +34,11 @@ import useUserStore from "../store/user";
|
|
|
|
|
import { t } from "../i18n"; |
|
|
|
|
import { payApi } from "../services/api/payApi"; |
|
|
|
|
import IconComponent from "../components/IconComponent"; |
|
|
|
|
import {getSubjectTransLanguage,getAttributeTransLanguage} from "../utils/languageUtils"; |
|
|
|
|
import { |
|
|
|
|
getSubjectTransLanguage, |
|
|
|
|
getAttributeTransLanguage, |
|
|
|
|
} from "../utils/languageUtils"; |
|
|
|
|
import Toast from "react-native-toast-message"; |
|
|
|
|
|
|
|
|
|
export const CartScreen = () => { |
|
|
|
|
const [cartList, setCartList] = useState<GetCartList[]>([]); |
|
|
|
@ -45,7 +50,9 @@ export const CartScreen = () => {
|
|
|
|
|
}>({}); |
|
|
|
|
const [allSelected, setAllSelected] = useState(false); |
|
|
|
|
const [totalAmount, setTotalAmount] = useState(0); |
|
|
|
|
const [convertedMinAmount, setConvertedMinAmount] = useState<number | null>(null); |
|
|
|
|
const [convertedMinAmount, setConvertedMinAmount] = useState<number | null>( |
|
|
|
|
null |
|
|
|
|
); |
|
|
|
|
const [deleteModalVisible, setDeleteModalVisible] = useState(false); |
|
|
|
|
const [itemToDelete, setItemToDelete] = useState<{ |
|
|
|
|
cartId: number; |
|
|
|
@ -63,6 +70,7 @@ export const CartScreen = () => {
|
|
|
|
|
const { setItems } = useCreateOrderStore(); |
|
|
|
|
const [minQuantityModalVisible, setMinQuantityModalVisible] = useState(false); |
|
|
|
|
const [minQuantityMessage, setMinQuantityMessage] = useState(""); |
|
|
|
|
const [loading, setLoading] = useState(false); |
|
|
|
|
|
|
|
|
|
// 货币转换函数
|
|
|
|
|
const convertCurrency = async () => { |
|
|
|
@ -72,16 +80,7 @@ export const CartScreen = () => {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log(country_code); |
|
|
|
|
|
|
|
|
|
// 如果 country_code 是 255,不需要转换
|
|
|
|
|
if (country_code === 225) { |
|
|
|
|
setConvertedMinAmount(null); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
console.log(`Converting currency for country_code: ${country_code}, from FCFA to ${currency}`); |
|
|
|
|
|
|
|
|
|
const data = { |
|
|
|
|
from_currency: "FCFA", // 固定使用 FCFA
|
|
|
|
|
to_currency: currency, // 使用用户的货币
|
|
|
|
@ -93,22 +92,28 @@ export const CartScreen = () => {
|
|
|
|
|
const response = await payApi.convertCurrency(data); |
|
|
|
|
console.log("Currency conversion response:", response); |
|
|
|
|
|
|
|
|
|
if (response && response.converted_amounts_list && response.converted_amounts_list.length > 0) { |
|
|
|
|
if ( |
|
|
|
|
response && |
|
|
|
|
response.converted_amounts_list && |
|
|
|
|
response.converted_amounts_list.length > 0 |
|
|
|
|
) { |
|
|
|
|
const convertedTotal = response.converted_amounts_list.find( |
|
|
|
|
(item: any) => item.item_key === "total_amount" |
|
|
|
|
); |
|
|
|
|
if (convertedTotal) { |
|
|
|
|
console.log(`Converted minimum amount: ${convertedTotal.converted_amount} ${currency}`); |
|
|
|
|
setConvertedMinAmount(convertedTotal.converted_amount); |
|
|
|
|
console.log( |
|
|
|
|
`Converted minimum amount: ${convertedTotal.converted_amount} ${currency}` |
|
|
|
|
); |
|
|
|
|
return convertedTotal.converted_amount; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
console.warn("No converted amounts found in response"); |
|
|
|
|
setConvertedMinAmount(null); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error("货币转换失败:", error); |
|
|
|
|
// 转换失败时不设置转换金额,使用原始逻辑
|
|
|
|
|
setConvertedMinAmount(null); |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -461,17 +466,20 @@ export const CartScreen = () => {
|
|
|
|
|
// 只有在用户已登录时才执行API调用
|
|
|
|
|
if (user_id) { |
|
|
|
|
getCart(); |
|
|
|
|
convertCurrency(); // 添加货币转换调用
|
|
|
|
|
} |
|
|
|
|
}, [user_id]) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const gotoOrder = () => { |
|
|
|
|
const gotoOrder = async () => { |
|
|
|
|
if (!user_id) { |
|
|
|
|
Alert.alert(t("cart.add_failed"), t("cart.login_required")); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 立即设置loading状态
|
|
|
|
|
setLoading(true); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
// 检查是否有选中的商品
|
|
|
|
|
const items: { cart_item_id: number }[] = []; |
|
|
|
|
cartList.forEach((item) => { |
|
|
|
@ -493,54 +501,92 @@ export const CartScreen = () => {
|
|
|
|
|
// 检查每个商品组的最小起订量
|
|
|
|
|
for (const item of cartList) { |
|
|
|
|
// 检查该商品组是否有选中的SKU
|
|
|
|
|
const hasSelectedSku = item.skus.some(sku => sku.selected === 1); |
|
|
|
|
const hasSelectedSku = item.skus.some((sku) => sku.selected === 1); |
|
|
|
|
if (hasSelectedSku) { |
|
|
|
|
const currentGroupTotal = calculateProductGroupTotalQuantity(item.cart_id); |
|
|
|
|
if (currentGroupTotal < item.min_order_quantity) { |
|
|
|
|
Alert.alert( |
|
|
|
|
t("cart.notice"), |
|
|
|
|
`${getSubjectTransLanguage(item)} ${t("cart.min_order")}${item.min_order_quantity}${t("cart.pieces")},${t("cart.current_quantity", "当前数量")}${currentGroupTotal}${t("cart.pieces")}` |
|
|
|
|
const currentGroupTotal = calculateProductGroupTotalQuantity( |
|
|
|
|
item.cart_id |
|
|
|
|
); |
|
|
|
|
if (currentGroupTotal < item.min_order_quantity) { |
|
|
|
|
Toast.show({ |
|
|
|
|
text1: `${getSubjectTransLanguage(item)} ${t("cart.min_order")}${ |
|
|
|
|
item.min_order_quantity |
|
|
|
|
}${t("cart.pieces")},${t( |
|
|
|
|
"cart.current_quantity", |
|
|
|
|
"当前数量" |
|
|
|
|
)}${currentGroupTotal}${t("cart.pieces")}`,
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
console.log(totalAmount); |
|
|
|
|
|
|
|
|
|
// 检查最低订单金额
|
|
|
|
|
console.log(country_code); |
|
|
|
|
|
|
|
|
|
const conver = await convertCurrency(); |
|
|
|
|
console.log(conver); |
|
|
|
|
|
|
|
|
|
let isFei = true |
|
|
|
|
if (country_code !== 225) { |
|
|
|
|
// 只有当 country_code 不是 255 时才进行最低订单金额检查
|
|
|
|
|
if (convertedMinAmount !== null) { |
|
|
|
|
// 如果有转换后的最低金额,检查当前总价是否满足要求
|
|
|
|
|
console.log(`Checking converted minimum amount: ${convertedMinAmount} ${currency} vs current total: ${totalAmount}`); |
|
|
|
|
if (totalAmount < convertedMinAmount) { |
|
|
|
|
Alert.alert( |
|
|
|
|
t("cart.notice"),
|
|
|
|
|
t("cart.minimum_order_required", { |
|
|
|
|
amount: convertedMinAmount.toFixed(2), |
|
|
|
|
currency: currency |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
if (totalAmount < conver) { |
|
|
|
|
Toast.show({ |
|
|
|
|
text1: `${t('cart.minimum')}${conver}${currency}`, |
|
|
|
|
}); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
}else{ |
|
|
|
|
// 如果转换失败,使用原始的 50,000 FCFA 检查
|
|
|
|
|
console.log(`Checking original minimum amount: 50000 FCFA vs current total: ${totalAmount}`); |
|
|
|
|
if (totalAmount < 50000) { |
|
|
|
|
Alert.alert( |
|
|
|
|
t("cart.notice"),
|
|
|
|
|
t("cart.minimum_order_required", { |
|
|
|
|
amount: "50,000", |
|
|
|
|
currency: "FCFA" |
|
|
|
|
}) |
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (totalAmount < conver) { |
|
|
|
|
isFei = false |
|
|
|
|
}else{ |
|
|
|
|
isFei = true |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 检查最低订单金额
|
|
|
|
|
// if (country_code !== 225) {
|
|
|
|
|
// // 只有当 country_code 不是 255 时才进行最低订单金额检查
|
|
|
|
|
// if (convertedMinAmount !== null) {
|
|
|
|
|
// // 如果有转换后的最低金额,检查当前总价是否满足要求
|
|
|
|
|
// console.log(`Checking converted minimum amount: ${convertedMinAmount} ${currency} vs current total: ${totalAmount}`);
|
|
|
|
|
// if (totalAmount < convertedMinAmount) {
|
|
|
|
|
// Alert.alert(
|
|
|
|
|
// t("cart.notice"),
|
|
|
|
|
// t("cart.minimum_order_required", {
|
|
|
|
|
// amount: convertedMinAmount.toFixed(2),
|
|
|
|
|
// currency: currency
|
|
|
|
|
// })
|
|
|
|
|
// );
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// // 如果转换失败,使用原始的 50,000 FCFA 检查
|
|
|
|
|
// console.log(`Checking original minimum amount: 50000 FCFA vs current total: ${totalAmount}`);
|
|
|
|
|
// if (totalAmount < 50000) {
|
|
|
|
|
// Alert.alert(
|
|
|
|
|
// t("cart.notice"),
|
|
|
|
|
// t("cart.minimum_order_required", {
|
|
|
|
|
// amount: "50,000",
|
|
|
|
|
// currency: "FCFA"
|
|
|
|
|
// })
|
|
|
|
|
// );
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// 如果 country_code === 255,则不进行任何最低订单金额检查
|
|
|
|
|
|
|
|
|
|
setItems(items); |
|
|
|
|
navigation.navigate("PreviewAddress"); |
|
|
|
|
navigation.navigate("PreviewAddress",{isFei:isFei}); |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error("提交订单失败:", error); |
|
|
|
|
Toast.show({ |
|
|
|
|
text1: t("cart.submit_failed", "提交失败,请重试"), |
|
|
|
|
}); |
|
|
|
|
} finally { |
|
|
|
|
// 确保在所有情况下都重置loading状态
|
|
|
|
|
setLoading(false); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 添加更新商品数量的方法
|
|
|
|
@ -596,7 +642,7 @@ export const CartScreen = () => {
|
|
|
|
|
|
|
|
|
|
// 计算同一商品组的总数量
|
|
|
|
|
const calculateProductGroupTotalQuantity = (cartId: number) => { |
|
|
|
|
const product = cartList.find(item => item.cart_id === cartId); |
|
|
|
|
const product = cartList.find((item) => item.cart_id === cartId); |
|
|
|
|
if (!product) return 0; |
|
|
|
|
|
|
|
|
|
return product.skus.reduce((total, sku) => total + sku.quantity, 0); |
|
|
|
@ -621,7 +667,11 @@ export const CartScreen = () => {
|
|
|
|
|
if (newGroupTotal >= minOrderQuantity) { |
|
|
|
|
updateQuantity(cartId, cartItemId, currentQuantity - 1); |
|
|
|
|
} else { |
|
|
|
|
showMinQuantityModal(`${t("cart.notice")}:${t("cart.min_order")}${minOrderQuantity}${t("cart.pieces")}`); |
|
|
|
|
showMinQuantityModal( |
|
|
|
|
`${t("cart.notice")}:${t("cart.min_order")}${minOrderQuantity}${t( |
|
|
|
|
"cart.pieces" |
|
|
|
|
)}` |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -653,17 +703,23 @@ export const CartScreen = () => {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const { cartId, cartItemId } = editingItem; |
|
|
|
|
const product = cartList.find(item => item.cart_id === cartId); |
|
|
|
|
const product = cartList.find((item) => item.cart_id === cartId); |
|
|
|
|
const minOrderQuantity = product?.min_order_quantity || 1; |
|
|
|
|
|
|
|
|
|
// 计算修改数量后,该商品组的总数量
|
|
|
|
|
const currentGroupTotal = calculateProductGroupTotalQuantity(cartId); |
|
|
|
|
const currentSkuQuantity = product?.skus.find(sku => sku.cart_item_id === cartItemId)?.quantity || 0; |
|
|
|
|
const currentSkuQuantity = |
|
|
|
|
product?.skus.find((sku) => sku.cart_item_id === cartItemId)?.quantity || |
|
|
|
|
0; |
|
|
|
|
const quantityDifference = newQuantity - currentSkuQuantity; |
|
|
|
|
const newGroupTotal = currentGroupTotal + quantityDifference; |
|
|
|
|
|
|
|
|
|
if (newGroupTotal < minOrderQuantity) { |
|
|
|
|
showMinQuantityModal(`${t("cart.notice")}:${t("cart.min_order")}${minOrderQuantity}${t("cart.pieces")}`); |
|
|
|
|
showMinQuantityModal( |
|
|
|
|
`${t("cart.notice")}:${t("cart.min_order")}${minOrderQuantity}${t( |
|
|
|
|
"cart.pieces" |
|
|
|
|
)}` |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
updateQuantity(cartId, cartItemId, newQuantity); |
|
|
|
|
setQuantityInputVisible(false); |
|
|
|
@ -750,7 +806,9 @@ export const CartScreen = () => {
|
|
|
|
|
{getSubjectTransLanguage(item) || item.subject} |
|
|
|
|
</Text> |
|
|
|
|
<Text style={styles.productDetailsTextStyle1}> |
|
|
|
|
{t("cart.min_order")}: {calculateProductGroupTotalQuantity(item.cart_id)}/{item.min_order_quantity} |
|
|
|
|
{t("cart.min_order")}:{" "} |
|
|
|
|
{calculateProductGroupTotalQuantity(item.cart_id)}/ |
|
|
|
|
{item.min_order_quantity} |
|
|
|
|
{t("cart.pieces")} |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
@ -768,11 +826,13 @@ export const CartScreen = () => {
|
|
|
|
|
alignItems: "center", |
|
|
|
|
width: 80, |
|
|
|
|
}} |
|
|
|
|
onPress={() => handleDeleteSku( |
|
|
|
|
onPress={() => |
|
|
|
|
handleDeleteSku( |
|
|
|
|
item.cart_id, |
|
|
|
|
sku.cart_item_id, |
|
|
|
|
item.cart_id |
|
|
|
|
)} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
disabled={!user_id} |
|
|
|
|
> |
|
|
|
|
<Text |
|
|
|
@ -800,11 +860,14 @@ export const CartScreen = () => {
|
|
|
|
|
> |
|
|
|
|
<View style={styles.svgContainer1}> |
|
|
|
|
<TouchableOpacity |
|
|
|
|
onPress={() => user_id && toggleSelection( |
|
|
|
|
onPress={() => |
|
|
|
|
user_id && |
|
|
|
|
toggleSelection( |
|
|
|
|
String(sku.cart_item_id), |
|
|
|
|
index1, |
|
|
|
|
index |
|
|
|
|
)} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
disabled={!user_id} |
|
|
|
|
> |
|
|
|
|
<View style={[styles.iconContainer]}> |
|
|
|
@ -823,7 +886,8 @@ export const CartScreen = () => {
|
|
|
|
|
? sku.attributes[0]?.sku_image_url |
|
|
|
|
: item.product_image, |
|
|
|
|
}} |
|
|
|
|
style={styles.productImageDisplayStyle} /> |
|
|
|
|
style={styles.productImageDisplayStyle} |
|
|
|
|
/> |
|
|
|
|
<View style={styles.productCardWidget1}> |
|
|
|
|
{/* 1. SKU attributes at the top */} |
|
|
|
|
{sku.attributes[0]?.value && ( |
|
|
|
@ -833,9 +897,17 @@ export const CartScreen = () => {
|
|
|
|
|
numberOfLines={2} |
|
|
|
|
ellipsizeMode="tail" |
|
|
|
|
> |
|
|
|
|
{getAttributeTransLanguage(sku.attributes[0]) || sku.attributes[0].attribute_name_trans}{" "} |
|
|
|
|
{getAttributeTransLanguage( |
|
|
|
|
sku.attributes[0] |
|
|
|
|
) || |
|
|
|
|
sku.attributes[0].attribute_name_trans}{" "} |
|
|
|
|
{sku.attributes[1] ? "/" : ""}{" "} |
|
|
|
|
{sku.attributes[1] ? getAttributeTransLanguage(sku.attributes[1]) || sku.attributes[1].attribute_name_trans : ""} |
|
|
|
|
{sku.attributes[1] |
|
|
|
|
? getAttributeTransLanguage( |
|
|
|
|
sku.attributes[1] |
|
|
|
|
) || |
|
|
|
|
sku.attributes[1].attribute_name_trans |
|
|
|
|
: ""} |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
)} |
|
|
|
@ -853,8 +925,11 @@ export const CartScreen = () => {
|
|
|
|
|
<View style={styles.vipContainer}> |
|
|
|
|
<Image |
|
|
|
|
source={require("../../assets/img/zkVIP1.png")} |
|
|
|
|
style={styles.VipImg} /> |
|
|
|
|
<Text style={styles.discountPercentageTextStyle}> |
|
|
|
|
style={styles.VipImg} |
|
|
|
|
/> |
|
|
|
|
<Text |
|
|
|
|
style={styles.discountPercentageTextStyle} |
|
|
|
|
> |
|
|
|
|
-{((1 - vip_discount) * 100).toFixed(0)}% |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
@ -878,12 +953,15 @@ export const CartScreen = () => {
|
|
|
|
|
styles.svgContainer4, |
|
|
|
|
{ borderRightWidth: 0 }, |
|
|
|
|
]} |
|
|
|
|
onPress={() => user_id && handleDecreaseQuantity( |
|
|
|
|
onPress={() => |
|
|
|
|
user_id && |
|
|
|
|
handleDecreaseQuantity( |
|
|
|
|
item.cart_id, |
|
|
|
|
sku.cart_item_id, |
|
|
|
|
sku.quantity, |
|
|
|
|
item.min_order_quantity |
|
|
|
|
)} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
disabled={!user_id} |
|
|
|
|
> |
|
|
|
|
<Text |
|
|
|
@ -898,11 +976,14 @@ export const CartScreen = () => {
|
|
|
|
|
</TouchableOpacity> |
|
|
|
|
<TouchableOpacity |
|
|
|
|
style={styles.quantityLabelContainer} |
|
|
|
|
onPress={() => user_id && handleQuantityPress( |
|
|
|
|
onPress={() => |
|
|
|
|
user_id && |
|
|
|
|
handleQuantityPress( |
|
|
|
|
item.cart_id, |
|
|
|
|
sku.cart_item_id, |
|
|
|
|
sku.quantity |
|
|
|
|
)} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
disabled={!user_id} |
|
|
|
|
> |
|
|
|
|
<Text style={styles.quantityText}> |
|
|
|
@ -914,11 +995,14 @@ export const CartScreen = () => {
|
|
|
|
|
styles.svgContainer4, |
|
|
|
|
{ borderLeftWidth: 0, marginLeft: 0 }, |
|
|
|
|
]} |
|
|
|
|
onPress={() => user_id && handleIncreaseQuantity( |
|
|
|
|
onPress={() => |
|
|
|
|
user_id && |
|
|
|
|
handleIncreaseQuantity( |
|
|
|
|
item.cart_id, |
|
|
|
|
sku.cart_item_id, |
|
|
|
|
sku.quantity |
|
|
|
|
)} |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
disabled={!user_id} |
|
|
|
|
> |
|
|
|
|
<Text |
|
|
|
@ -952,7 +1036,7 @@ export const CartScreen = () => {
|
|
|
|
|
{/* Fixed Bottom Section */} |
|
|
|
|
<View style={styles.fixedBottomContainer}> |
|
|
|
|
{/* Order Summary */} |
|
|
|
|
{country_code !== 225 && ( |
|
|
|
|
{/* {country_code !== 225 && ( |
|
|
|
|
<View style={styles.orderSummaryHeader}> |
|
|
|
|
<View style={styles.svgContainer6}> |
|
|
|
|
<Image |
|
|
|
@ -971,11 +1055,14 @@ export const CartScreen = () => {
|
|
|
|
|
</Text> |
|
|
|
|
</Text> |
|
|
|
|
</View> |
|
|
|
|
)} |
|
|
|
|
)} */} |
|
|
|
|
|
|
|
|
|
<View style={styles.flexboxContainerWithButton}> |
|
|
|
|
<View style={styles.productInfoContainer}> |
|
|
|
|
<TouchableOpacity onPress={user_id ? selectAllHandel : undefined} disabled={!user_id}> |
|
|
|
|
<TouchableOpacity |
|
|
|
|
onPress={user_id ? selectAllHandel : undefined} |
|
|
|
|
disabled={!user_id} |
|
|
|
|
> |
|
|
|
|
<View style={styles.svgContainer1}> |
|
|
|
|
{allSelected ? ( |
|
|
|
|
<OrangeCircleIcon size={fontSize(24)} /> |
|
|
|
@ -994,10 +1081,17 @@ export const CartScreen = () => {
|
|
|
|
|
<Text style={styles.priceLabel}>{currency}</Text> |
|
|
|
|
</View> |
|
|
|
|
<TouchableOpacity |
|
|
|
|
style={[styles.submitButtonStyle, !user_id && styles.disabledButton]} |
|
|
|
|
onPress={user_id ? gotoOrder : undefined} |
|
|
|
|
disabled={!user_id} |
|
|
|
|
style={[ |
|
|
|
|
styles.submitButtonStyle, |
|
|
|
|
!user_id && styles.disabledButton, |
|
|
|
|
loading && styles.disabledButton, |
|
|
|
|
]} |
|
|
|
|
onPress={user_id && !loading ? gotoOrder : undefined} |
|
|
|
|
disabled={!user_id || loading} |
|
|
|
|
> |
|
|
|
|
{loading ? ( |
|
|
|
|
<ActivityIndicator size="small" color="white" /> |
|
|
|
|
) : ( |
|
|
|
|
<Text |
|
|
|
|
style={{ |
|
|
|
|
color: "white", |
|
|
|
@ -1007,6 +1101,7 @@ export const CartScreen = () => {
|
|
|
|
|
> |
|
|
|
|
{t("cart.submit")} |
|
|
|
|
</Text> |
|
|
|
|
)} |
|
|
|
|
</TouchableOpacity> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
@ -1024,7 +1119,10 @@ export const CartScreen = () => {
|
|
|
|
|
{t("cart.login_required_title", "请先登录")} |
|
|
|
|
</Text> |
|
|
|
|
<Text style={styles.loginPromptSubtitle}> |
|
|
|
|
{t("cart.login_required_subtitle", "登录后即可使用购物车功能")} |
|
|
|
|
{t( |
|
|
|
|
"cart.login_required_subtitle", |
|
|
|
|
"登录后即可使用购物车功能" |
|
|
|
|
)} |
|
|
|
|
</Text> |
|
|
|
|
<TouchableOpacity |
|
|
|
|
style={styles.loginButton} |
|
|
|
@ -1127,12 +1225,16 @@ export const CartScreen = () => {
|
|
|
|
|
<View style={styles.warningIconContainer}> |
|
|
|
|
<IconComponent name="exclamation" size={28} color="#FF5100" /> |
|
|
|
|
</View> |
|
|
|
|
<Text style={[styles.promptText, styles.minQuantityText]}>{minQuantityMessage}</Text> |
|
|
|
|
<Text style={[styles.promptText, styles.minQuantityText]}> |
|
|
|
|
{minQuantityMessage} |
|
|
|
|
</Text> |
|
|
|
|
<TouchableOpacity |
|
|
|
|
style={[styles.confirmButton, styles.minQuantityButton]} |
|
|
|
|
onPress={() => setMinQuantityModalVisible(false)} |
|
|
|
|
> |
|
|
|
|
<Text style={[styles.confirmText, styles.minQuantityButtonText]}>{t("cart.confirm")}</Text> |
|
|
|
|
<Text style={[styles.confirmText, styles.minQuantityButtonText]}> |
|
|
|
|
{t("cart.confirm")} |
|
|
|
|
</Text> |
|
|
|
|
</TouchableOpacity> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
@ -1317,12 +1419,12 @@ const styles = StyleSheet.create({
|
|
|
|
|
fontFamily: "PingFang SC", |
|
|
|
|
fontWeight: "600", |
|
|
|
|
color: "#9a9a9a", |
|
|
|
|
textDecorationLine: 'line-through', |
|
|
|
|
textDecorationLine: "line-through", |
|
|
|
|
}, |
|
|
|
|
vipContainer: { |
|
|
|
|
position: 'relative', |
|
|
|
|
justifyContent: 'center', |
|
|
|
|
alignItems: 'center', |
|
|
|
|
position: "relative", |
|
|
|
|
justifyContent: "center", |
|
|
|
|
alignItems: "center", |
|
|
|
|
marginLeft: 10, |
|
|
|
|
}, |
|
|
|
|
VipImg: { |
|
|
|
@ -1330,13 +1432,13 @@ const styles = StyleSheet.create({
|
|
|
|
|
height: widthUtils(28, 28).height, |
|
|
|
|
}, |
|
|
|
|
discountPercentageTextStyle: { |
|
|
|
|
position: 'absolute', |
|
|
|
|
position: "absolute", |
|
|
|
|
fontSize: fontSize(12), |
|
|
|
|
fontFamily: "Segoe UI", |
|
|
|
|
fontWeight: "900", |
|
|
|
|
fontStyle: "italic", |
|
|
|
|
color: "#4e2000", |
|
|
|
|
textAlign: 'center', |
|
|
|
|
textAlign: "center", |
|
|
|
|
}, |
|
|
|
|
borderBoxDivider: { |
|
|
|
|
width: "100%", |
|
|
|
@ -1819,30 +1921,31 @@ const styles = StyleSheet.create({
|
|
|
|
|
opacity: 0.6, |
|
|
|
|
}, |
|
|
|
|
loginOverlay: { |
|
|
|
|
position: 'absolute', |
|
|
|
|
position: "absolute", |
|
|
|
|
top: 0, |
|
|
|
|
left: 0, |
|
|
|
|
right: 0, |
|
|
|
|
bottom: 0, |
|
|
|
|
backgroundColor: 'rgba(255, 255, 255, 0.9)', |
|
|
|
|
backdropFilter: 'blur(10px)', // iOS 毛玻璃效果
|
|
|
|
|
justifyContent: 'center', |
|
|
|
|
alignItems: 'center', |
|
|
|
|
backgroundColor: "rgba(255, 255, 255, 0.9)", |
|
|
|
|
backdropFilter: "blur(10px)", // iOS 毛玻璃效果
|
|
|
|
|
justifyContent: "center", |
|
|
|
|
alignItems: "center", |
|
|
|
|
zIndex: 1000, |
|
|
|
|
}, |
|
|
|
|
blurContainer: { |
|
|
|
|
width: '100%', |
|
|
|
|
height: '100%', |
|
|
|
|
justifyContent: 'center', |
|
|
|
|
alignItems: 'center', |
|
|
|
|
backgroundColor: Platform.OS === 'android' ? 'rgba(255, 255, 255, 0.95)' : 'transparent', |
|
|
|
|
width: "100%", |
|
|
|
|
height: "100%", |
|
|
|
|
justifyContent: "center", |
|
|
|
|
alignItems: "center", |
|
|
|
|
backgroundColor: |
|
|
|
|
Platform.OS === "android" ? "rgba(255, 255, 255, 0.95)" : "transparent", |
|
|
|
|
}, |
|
|
|
|
loginPromptContainer: { |
|
|
|
|
backgroundColor: 'white', |
|
|
|
|
backgroundColor: "white", |
|
|
|
|
borderRadius: 20, |
|
|
|
|
padding: 40, |
|
|
|
|
alignItems: 'center', |
|
|
|
|
shadowColor: '#000', |
|
|
|
|
alignItems: "center", |
|
|
|
|
shadowColor: "#000", |
|
|
|
|
shadowOffset: { |
|
|
|
|
width: 0, |
|
|
|
|
height: 2, |
|
|
|
@ -1850,90 +1953,90 @@ const styles = StyleSheet.create({
|
|
|
|
|
shadowOpacity: 0.25, |
|
|
|
|
shadowRadius: 3.84, |
|
|
|
|
elevation: 5, |
|
|
|
|
maxWidth: '80%', |
|
|
|
|
maxWidth: "80%", |
|
|
|
|
}, |
|
|
|
|
loginIcon: { |
|
|
|
|
width: 80, |
|
|
|
|
height: 80, |
|
|
|
|
marginBottom: 20, |
|
|
|
|
justifyContent: 'center', |
|
|
|
|
alignItems: 'center', |
|
|
|
|
backgroundColor: 'rgba(255, 81, 0, 0.1)', |
|
|
|
|
justifyContent: "center", |
|
|
|
|
alignItems: "center", |
|
|
|
|
backgroundColor: "rgba(255, 81, 0, 0.1)", |
|
|
|
|
borderRadius: 40, |
|
|
|
|
}, |
|
|
|
|
loginIconText: { |
|
|
|
|
fontSize: 40, |
|
|
|
|
fontWeight: 'bold', |
|
|
|
|
color: '#FF5100', |
|
|
|
|
fontWeight: "bold", |
|
|
|
|
color: "#FF5100", |
|
|
|
|
}, |
|
|
|
|
loginPromptTitle: { |
|
|
|
|
fontSize: fontSize(24), |
|
|
|
|
fontWeight: '700', |
|
|
|
|
color: '#333', |
|
|
|
|
fontWeight: "700", |
|
|
|
|
color: "#333", |
|
|
|
|
marginBottom: 10, |
|
|
|
|
textAlign: 'center', |
|
|
|
|
textAlign: "center", |
|
|
|
|
}, |
|
|
|
|
loginPromptSubtitle: { |
|
|
|
|
fontSize: fontSize(16), |
|
|
|
|
color: '#666', |
|
|
|
|
color: "#666", |
|
|
|
|
marginBottom: 30, |
|
|
|
|
textAlign: 'center', |
|
|
|
|
textAlign: "center", |
|
|
|
|
lineHeight: fontSize(22), |
|
|
|
|
}, |
|
|
|
|
loginButton: { |
|
|
|
|
backgroundColor: '#FF5100', |
|
|
|
|
backgroundColor: "#FF5100", |
|
|
|
|
paddingHorizontal: 40, |
|
|
|
|
paddingVertical: 15, |
|
|
|
|
borderRadius: 25, |
|
|
|
|
minWidth: 160, |
|
|
|
|
}, |
|
|
|
|
loginButtonText: { |
|
|
|
|
color: 'white', |
|
|
|
|
color: "white", |
|
|
|
|
fontSize: fontSize(18), |
|
|
|
|
fontWeight: '700', |
|
|
|
|
textAlign: 'center', |
|
|
|
|
fontWeight: "700", |
|
|
|
|
textAlign: "center", |
|
|
|
|
}, |
|
|
|
|
warningIconContainer: { |
|
|
|
|
backgroundColor: "#FFF2E9", |
|
|
|
|
borderRadius: 20, |
|
|
|
|
padding: 12, |
|
|
|
|
marginBottom: 16, |
|
|
|
|
alignSelf: 'center', |
|
|
|
|
alignSelf: "center", |
|
|
|
|
width: 52, |
|
|
|
|
height: 52, |
|
|
|
|
justifyContent: 'center', |
|
|
|
|
alignItems: 'center', |
|
|
|
|
justifyContent: "center", |
|
|
|
|
alignItems: "center", |
|
|
|
|
}, |
|
|
|
|
warningIcon: { |
|
|
|
|
width: 32, |
|
|
|
|
height: 32, |
|
|
|
|
}, |
|
|
|
|
minQuantityPopup: { |
|
|
|
|
width: '80%', |
|
|
|
|
width: "80%", |
|
|
|
|
padding: 24, |
|
|
|
|
}, |
|
|
|
|
minQuantityText: { |
|
|
|
|
fontSize: fontSize(16), |
|
|
|
|
color: '#333', |
|
|
|
|
color: "#333", |
|
|
|
|
marginVertical: 16, |
|
|
|
|
textAlign: 'center', |
|
|
|
|
textAlign: "center", |
|
|
|
|
lineHeight: fontSize(22), |
|
|
|
|
fontWeight: '500', |
|
|
|
|
fontWeight: "500", |
|
|
|
|
}, |
|
|
|
|
minQuantityButton: { |
|
|
|
|
width: '100%', |
|
|
|
|
width: "100%", |
|
|
|
|
height: 44, |
|
|
|
|
borderRadius: 22, |
|
|
|
|
backgroundColor: '#FF5100', |
|
|
|
|
backgroundColor: "#FF5100", |
|
|
|
|
marginTop: 16, |
|
|
|
|
}, |
|
|
|
|
minQuantityButtonText: { |
|
|
|
|
fontSize: fontSize(16), |
|
|
|
|
fontWeight: '600', |
|
|
|
|
fontWeight: "600", |
|
|
|
|
}, |
|
|
|
|
productGroupDivider: { |
|
|
|
|
height: 5, |
|
|
|
|
backgroundColor: '#f0f0f0', |
|
|
|
|
width: '100%', |
|
|
|
|
backgroundColor: "#f0f0f0", |
|
|
|
|
width: "100%", |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|