javascript - 使用 vanilla JS 模拟购物车功能
问题描述
我正在用 express 构建一个商店经理应用程序,它要求我拥有三个模型,用户、产品和销售。我想为销售模型实现购物车功能,所以我有这样的东西:
const carts = [
// Cart 1
{
{
Product: Product1
Quantity: 20
Unit Price: 500
Amount: 10000
},
{
Product: product2
Quantity: 5
Unit Price: 15000
Amount: 75000
},
{
Product: anotherProduct
Quantity: 10
Unit Price: 500
Amount: 5000
},
{
Product: Product3
Quantity: 2
Unit Price: 500
Amount: 1000
},
Total : 91000
},
// Cart 2
{
{
Product: product1
Quantity: 20
Unit Price: 500
Amount: 10000
},
{
Product: product2
Quantity: 5
Unit Price: 15000
Amount: 75000
},
Total: 80000
}
];
Cart 1 代表一个服务员的销售,而 Cart 2 代表另一个服务员的销售。如何包含 saleId、attachantId 和 total 以便于参考?注意我将要通过销售模型运行搜索/循环以按 saleId 过滤
解决方案
推荐阅读
- rundeck - Rundeck 并行运行某些步骤
- git - 在 git repo 消失后重新启动自动部署?
- c - C程序停在某个数字上
- ssis - SSIS 将 YYYY-MM-DD 字符串加载到日期数据类型中
- flutter - 在flutter中使用api时如何使用自动变量?
- vue.js - 在 Ionic Vue 中使用 Stencil 组件
- javascript - 文本颜色随搜索输入而变化,但无法按预期工作
- php - PHP 页面导航优化 - 在导航项上设置“活动”
- excel - 过滤和发送电子邮件
- .net-core - 如何使用不同的 DbContext 配置多个 UserManager