Commit 43e13100a4a3e1dd18ba81a774954f042cf27e6f

Authored by yvan.ni
1 parent a2541b82

避免空对象

packageE/pages/cart/cart2/cart2.js
@@ -2594,8 +2594,8 @@ Page({ @@ -2594,8 +2594,8 @@ Page({
2594 if (pt_res) { 2594 if (pt_res) {
2595 for (var io in item_map.goods) { 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 if (!th.data.ispt_goods) { 2599 if (!th.data.ispt_goods) {
2600 item_map.goods[io].account = item_map.goods[io].account_fir; 2600 item_map.goods[io].account = item_map.goods[io].account_fir;
2601 item_map.goods[io].account_yu = item_map.goods[io].account_yu_fir; 2601 item_map.goods[io].account_yu = item_map.goods[io].account_yu_fir;
@@ -4834,8 +4834,8 @@ Page({ @@ -4834,8 +4834,8 @@ Page({
4834 4834
4835 if (pt_res) { 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 item.is_discount_amount = 1; 4839 item.is_discount_amount = 1;
4840 } 4840 }
4841 } 4841 }
@@ -7119,9 +7119,9 @@ Page({ @@ -7119,9 +7119,9 @@ Page({
7119 for (var i in arr) { 7119 for (var i in arr) {
7120 if (arr[i].goods_id == goods_id) return arr[i]; 7120 if (arr[i].goods_id == goods_id) return arr[i];
7121 } 7121 }
  7122 + return {};
7122 }, 7123 },
7123 7124
7124 -  
7125 //从优惠的映射中拿出商品从表的item,要防止空对象的时候,空就返回空对象 7125 //从优惠的映射中拿出商品从表的item,要防止空对象的时候,空就返回空对象
7126 arr_get_goods_n: function (good, arr) { 7126 arr_get_goods_n: function (good, arr) {
7127 for (var i in arr) { 7127 for (var i in arr) {