Commit 43e13100a4a3e1dd18ba81a774954f042cf27e6f
1 parent
a2541b82
避免空对象
Showing
1 changed file
with
5 additions
and
5 deletions
packageE/pages/cart/cart2/cart2.js
... | ... | @@ -2594,8 +2594,8 @@ Page({ |
2594 | 2594 | if (pt_res) { |
2595 | 2595 | for (var io in item_map.goods) { |
2596 | 2596 | //平摊赋值 |
2597 | - item_map.goods[io].account_fir = th.arr_get_goods(item_map.goods[io].goods_id, pt_res).fisrt_account; | |
2598 | - item_map.goods[io].account_yu_fir = th.arr_get_goods(item_map.goods[io].goods_id, pt_res).fisrt_account_yu; | |
2597 | + item_map.goods[io].account_fir = th.arr_get_goods(item_map.goods[io].goods_id, pt_res).fisrt_account || 0; | |
2598 | + item_map.goods[io].account_yu_fir = th.arr_get_goods(item_map.goods[io].goods_id, pt_res).fisrt_account_yu || 0; | |
2599 | 2599 | if (!th.data.ispt_goods) { |
2600 | 2600 | item_map.goods[io].account = item_map.goods[io].account_fir; |
2601 | 2601 | item_map.goods[io].account_yu = item_map.goods[io].account_yu_fir; |
... | ... | @@ -4834,8 +4834,8 @@ Page({ |
4834 | 4834 | |
4835 | 4835 | if (pt_res) { |
4836 | 4836 | //平摊赋值 |
4837 | - goods.account = pt_res[0].fisrt_account; | |
4838 | - goods.account_yu = pt_res[0].fisrt_account_yu; | |
4837 | + goods.account = pt_res[0].fisrt_account || 0; | |
4838 | + goods.account_yu = pt_res[0].fisrt_account_yu || 0; | |
4839 | 4839 | item.is_discount_amount = 1; |
4840 | 4840 | } |
4841 | 4841 | } |
... | ... | @@ -7119,9 +7119,9 @@ Page({ |
7119 | 7119 | for (var i in arr) { |
7120 | 7120 | if (arr[i].goods_id == goods_id) return arr[i]; |
7121 | 7121 | } |
7122 | + return {}; | |
7122 | 7123 | }, |
7123 | 7124 | |
7124 | - | |
7125 | 7125 | //从优惠的映射中拿出商品从表的item,要防止空对象的时候,空就返回空对象 |
7126 | 7126 | arr_get_goods_n: function (good, arr) { |
7127 | 7127 | for (var i in arr) { | ... | ... |