react-native - REACT NATIVE 回购之前购买的订单
问题描述
我想一次用很多产品回购我之前的订单。有什么方法可以解决这个问题吗?我尝试了很多方法,但似乎都不起作用。
{
"error_code": "00",
"message": "",
"Slip": [
{
"SalesSlipID": 1473767,
"SalesDateUnknown": true,
"ClientID": 484,
"SiteID": 338407,
"SubTotal": 8300,
"ConsumptionTax": 830,
"Total": 9130,
"EstablishmentID": null,
"StaffName": "奥村 進吾",
"FormatAcceptedDate": "21-07-07",
"FormatSalesDate": "21-07-07",
"sales_goods": [
{
"SalesGoodsID": 3535906,
"SalesSlipID": 1473767,
"GoodsID": 76993,
"GoodsSubID": 119983,
"GoodsName": "DANシリコンセラR 5分艶淡彩P-1グレーKN-55<597-2001-00614>",
"GoodsSize": "15kg",
"SpecialPriceID": 5346,
"Price": 3350,
"Carriage": 0,
"Number": 1,
},
{
"SalesGoodsID": 3535907,
"SalesSlipID": 1473767,
"GoodsID": 76993,
"GoodsSubID": 119985,
"GoodsName": "DANシリコンセラR 5分艶淡彩P-3<597-2009-06251>",
"GoodsSize": "15kg",
"SpecialPriceID": 5346,
"Price": 3350,
"Carriage": 0,
"Number": 1,
},
{
"SalesGoodsID": 3535908,
"SalesSlipID": 1473767,
"GoodsID": 8775,
"GoodsSubID": 1,
"GoodsName": "小口調色料金ニッペ800",
"GoodsSize": "",
"SpecialPriceID": 1,
"Price": 800,
"Carriage": 0,
"Number": 2,
}
]
},
这是我的代码。我想在 [sales_goods] onClickCart(data) { const itemcart = { goods: data, quantity: data.Number, Price:data.Price }; 中添加所有产品
AsyncStorage.getItem('cart')
.then(datacart => {
if (datacart !== null) {
const cart = JSON.parse(datacart);
cart.push(itemcart);
AsyncStorage.setItem('cart', JSON.stringify(cart));
} else {
const cart = [];
cart.push(itemcart);
AsyncStorage.setItem('cart', JSON.stringify(cart));
}
})
.catch(error => {
alert(error);
});
}
选择固定数组时,会增加1个产品
onPress={() => this.onClickCart(item.sales_goods[0])}>
我的英语不是很好。谢谢
解决方案
推荐阅读
- vue.js - 使用 Vuex 从组件获取和编辑状态。ReferenceError: $store 未定义
- python - 如何用超过 1 个向量拟合 MultinomialNB?
- python - 如何处理 Panda Dataframe 中的字符串?
- azure - 代表 Azure AD 多租户应用程序的 Azure 资源管理器
- video - 使用 ffmpeg 保持电视格式的纵横比
- bash - For循环Shell脚本程序以特定模式查找最新文件
- css - Laravel MİX 编译警告
- java - JPA 多个名为 ... 的转换器在此持久性单元中定义
- xamarin.android - 在活动中加载数据时,ProgressBar 在某个时刻停止旋转 (Xamarin.Android)
- wso2 - WSO2 Enterprise Integrator 和 Identity Server,它们是否一起工作和集成