首页 > 解决方案 > 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])}>   

我的英语不是很好。谢谢

标签: react-nativereact-navigationcartshopping-cart

解决方案


推荐阅读