将采购订单详细信息React Native Expo发送至用户电子邮件



我有一个移动购物车,它显然有一个商品列表和一个购物车。我想在注册用户下订单时,将订单信息发送给他们的电子邮件。有一个很好的库EmailJS,可以让你发送信息到谷歌电子邮件。但我不明白,如何发送ItemListOfGood,以及其他指定信息(如交货地点或卡/现金支付(。有人有实施的链接或指南吗?也许是Firebase,但我没有发现类似的东西。

const MyCart = ({ navigation }) => {const [product, setProduct] = useState();
const [total, setTotal] = useState(null);
useEffect(() => {
const unsubscribe = navigation.addListener('focus', () => {
getDataFromDB();
});
return unsubscribe;
}, [navigation]);
//get data from local DB by ID
const getDataFromDB = async () => {
let items = await AsyncStorage.getItem('cartItems');
items = JSON.parse(items);
let productData = [];
if (items) {
Items.forEach(data => {
if (items.includes(data.id)) {
productData.push(data);
return;
}
});
setProduct(productData);
getTotal(productData);
} else {
setProduct(false);
getTotal(false);
}
};
//get total price of all items in the cart
const getTotal = productData => {
let total = 0;
for (let index = 0; index < productData.length; index++) {
let productPrice = productData[index].productPrice;
total = total + productPrice;
}
setTotal(total);
};
//remove data from Cart
const removeItemFromCart = async id => {
let itemArray = await AsyncStorage.getItem('cartItems');
itemArray = JSON.parse(itemArray);
if (itemArray) {
let array = itemArray;
for (let index = 0; index < array.length; index++) {
if (array[index] == id) {
array.splice(index, 1);
}
await AsyncStorage.setItem('cartItems', JSON.stringify(array));
getDataFromDB();
}
}
};
//checkout
const checkOut = async () => {
try {
await AsyncStorage.removeItem('cartItems');
} catch (error) {
return error;
}
ToastAndroid.show('Заказ скоро будет доставлен!', ToastAndroid.SHORT);
navigation.navigate('Home');
};
const renderProducts = (data, index) => {
return (
<TouchableOpacity
key={data.key}
onPress={() => navigation.navigate('ProductInfo', { productID: data.id })}
style={{
width: '100%',
height: 100,
marginVertical: 6,
flexDirection: 'row',
alignItems: 'center',
}}>
<View
style={{
width: '30%',
height: 100,
padding: 14,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: COLOURS.backgroundLight,
borderRadius: 10,
marginRight: 22,
}}>
<Image
source={data.productImage}
style={{
width: '100%',
height: '100%',
resizeMode: 'contain',
}}
/>
</View>
<View
style={{
flex: 1,
height: '100%',
justifyContent: 'space-around',
}}>
<View style={{}}>
<Text
style={{
fontSize: 14,
maxWidth: '100%',
color: COLOURS.black,
fontWeight: '600',
letterSpacing: 1,
}}>
{data.productName}
</Text>
<View
style={{
marginTop: 4,
flexDirection: 'row',
alignItems: 'center',
opacity: 0.6,
}}>
<Text
style={{
fontSize: 14,
fontWeight: '400',
maxWidth: '85%',
marginRight: 4,
}}>
Br{data.productPrice}
</Text>
<Text>
(~Br;
{data.productPrice + data.productPrice / 20})
</Text>
</View>
</View>
<View
style={{
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
}}>
<View
style={{
flexDirection: 'row',
alignItems: 'center',
}}>
<View
style={{
borderRadius: 100,
marginRight: 20,
padding: 4,
borderWidth: 1,
borderColor: COLOURS.backgroundMedium,
opacity: 0.5,
}}>
<MaterialCommunityIcons
name="minus"
style={{
fontSize: 16,
color: COLOURS.backgroundDark,
}}
/>
</View>
<Text>1</Text>
<View
style={{
borderRadius: 100,
marginLeft: 20,
padding: 4,
borderWidth: 1,
borderColor: COLOURS.backgroundMedium,
opacity: 0.5,
}}>
<MaterialCommunityIcons
name="plus"
style={{
fontSize: 16,
color: COLOURS.backgroundDark,
}}
/>
</View>
</View>
<TouchableOpacity onPress={() => removeItemFromCart(data.id)}>
<MaterialCommunityIcons
name="delete-outline"
style={{
fontSize: 16,
color: COLOURS.backgroundDark,
backgroundColor: COLOURS.backgroundLight,
padding: 8,
borderRadius: 100,
}}
/>
</TouchableOpacity>
</View>
</View>
</TouchableOpacity>
);
};

只有使用firebase-sdk才能完成。https://firebase.google.com/docs/auth/android/manage-users

最新更新