Commit a2541b82fb2210a2f01037431a5ea6a26c99a3cf
1 parent
1909c1f5
1、 要防止空对象,用 || 0
2、 从优惠的映射中拿出商品从表的item,要防止空对象的时候,空就返回空对象 arr_get_goods_n: function (good, arr) {}
Showing
1 changed file
with
5 additions
and
3 deletions
packageE/pages/cart/cart2/cart2.js
... | ... | @@ -555,8 +555,9 @@ Page({ |
555 | 555 | }) |
556 | 556 | if (pt_res) { |
557 | 557 | for (let io = 0; io <new_arr.length ; io++) { |
558 | - new_arr[io].account_yc = this.arr_get_goods_n(new_arr[io], pt_res).fisrt_account; | |
559 | - new_arr[io].account_yc_yu = this.arr_get_goods_n(new_arr[io], pt_res).fisrt_account_yu; | |
558 | + //要防止空对象,用 || 0 | |
559 | + new_arr[io].account_yc = this.arr_get_goods_n(new_arr[io], pt_res).fisrt_account || 0; | |
560 | + new_arr[io].account_yc_yu = this.arr_get_goods_n(new_arr[io], pt_res).fisrt_account_yu || 0; | |
560 | 561 | } |
561 | 562 | } |
562 | 563 | |
... | ... | @@ -7121,11 +7122,12 @@ Page({ |
7121 | 7122 | }, |
7122 | 7123 | |
7123 | 7124 | |
7124 | - //从优惠的映射中拿出商品从表的item | |
7125 | + //从优惠的映射中拿出商品从表的item,要防止空对象的时候,空就返回空对象 | |
7125 | 7126 | arr_get_goods_n: function (good, arr) { |
7126 | 7127 | for (var i in arr) { |
7127 | 7128 | if (arr[i].goods_id == good.goods_id && arr[i].prom_id == good.prom_id && arr[i].prom_type == good.prom_type ) return arr[i]; |
7128 | 7129 | } |
7130 | + return {}; | |
7129 | 7131 | }, |
7130 | 7132 | |
7131 | 7133 | ... | ... |