angular8 获取文件流_Angular 8读取和过滤JSON数据-问答-阿里云开发者社区-阿里云...

我在Angular 8项目中工作,当前的任务是在进入购物篮和支付之前将预订的数据存储到本地存储中,我有眼镜、餐厅和giftCardstypes对象。我将对象存储在localStorage中

[{,…}, {id: 9, designation: "spectacle + restaurant", gift: [], type: "Soirée Bon plan",…},…]

0: {,…}

placesListContent: [{tr_id: "692741", tr_sp_id: "12535", tr_entite: "AG", tr_cat_ordre: "1", tr_cat: "Tarifs :",…}]

0: {tr_id: "692741", tr_sp_id: "12535", tr_entite: "AG", tr_cat_ordre: "1", tr_cat: "Tarifs :",…}

qte: 1

restaurant: null

spectacle: {sp_id: "12535", sp_date: "1563371131", sp_th_id: "1493", sp_cat_id: "3", sp_prod_id: "0",…}

1: {id: 9, designation: "spectacle + restaurant", gift: [], type: "Soirée Bon plan",…}

amount: 60

banner: ""

designation: "spectacle + restaurant"

format: "bb"

gift: []

icon: "/uploads/fe633f32ab883aae44f154f3fead6982.png"

id: 9

qte: 4

type: "Soirée Bon plan"

2: {id: 11, designation: "spectacle + restaurant", gift: [], type: "Soirée Chic",…}

amount: 100

banner: ""

designation: "spectacle + restaurant"

format: "vv"

gift: []

icon: "/uploads/f63473b5694a420ca32fa87f415879a0.png"

id: 11

qte: 2

type: "Soirée Chic"

3: {id: 12, designation: "spectacle + restaurant", gift: [], type: "Soirée VIP",…}

这是giftcardTypes的用户界面: https://i.stack.imgur.com/yaFVd.png

addGiftToCard(type) {

type = type.type

let cardParse = JSON.parse(localStorage.getItem('cart')) || []

let index = _.findIndex(cardParse, item => item.type && item.id == type.id)

if (index == -1) {

type.qte = 1

cardParse.push(type)

} else {

cardParse[index].qte += 1

}

localStorage.setItem('cart', JSON.stringify(cardParse))

}

谁能帮帮我!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值