增加get 保护 review by yuliang。
Showing
1 changed file
with
8 additions
and
5 deletions
@@ -74,12 +74,12 @@ export function pressCategoryBMore(category_id){ | @@ -74,12 +74,12 @@ export function pressCategoryBMore(category_id){ | ||
74 | let {categoryB} = getState(); | 74 | let {categoryB} = getState(); |
75 | 75 | ||
76 | //获取当前频道下一级分类列表信息 | 76 | //获取当前频道下一级分类列表信息 |
77 | - let categoryData = categoryB.categoryList.get(categoryB.currentChannelValue); | 77 | + let categoryData = categoryB.categoryList ? categoryB.categoryList.get(categoryB.currentChannelValue) : []; |
78 | 78 | ||
79 | //获取指定category_id分类信息 | 79 | //获取指定category_id分类信息 |
80 | let category = null; | 80 | let category = null; |
81 | categoryData.map((item, i) => { | 81 | categoryData.map((item, i) => { |
82 | - if(category_id == item.get('category_id')){ | 82 | + if(item && (category_id == item.get('category_id'))){ |
83 | category = item; | 83 | category = item; |
84 | } | 84 | } |
85 | }); | 85 | }); |
@@ -92,7 +92,7 @@ export function pressCategoryBMore(category_id){ | @@ -92,7 +92,7 @@ export function pressCategoryBMore(category_id){ | ||
92 | }; | 92 | }; |
93 | 93 | ||
94 | //设置当前的类别信息 | 94 | //设置当前的类别信息 |
95 | - dispatch(setCurrentCateB(category_id, category.get('category_name'))); | 95 | + dispatch(setCurrentCateB(category_id, category ? category.get('category_name') : "")); |
96 | dispatch(jumpToCategory(all, 0, categoryB.currentChannelId)); | 96 | dispatch(jumpToCategory(all, 0, categoryB.currentChannelId)); |
97 | 97 | ||
98 | }; | 98 | }; |
@@ -113,7 +113,7 @@ export function getCategoryBSubCategoryDetail(category_id, category_value){ | @@ -113,7 +113,7 @@ export function getCategoryBSubCategoryDetail(category_id, category_value){ | ||
113 | //检查缓存是否存在数据,如果不存在则获取 | 113 | //检查缓存是否存在数据,如果不存在则获取 |
114 | let cache = categoryB.cacheSubCateData; | 114 | let cache = categoryB.cacheSubCateData; |
115 | let key = getSubDetailCacheKey(currentChannelId, category_id); | 115 | let key = getSubDetailCacheKey(currentChannelId, category_id); |
116 | - let categoryData = cache.get(key); | 116 | + let categoryData = cache ? cache.get(key) : ""; |
117 | 117 | ||
118 | //设置当前的类别信息 | 118 | //设置当前的类别信息 |
119 | dispatch(setCurrentCateB(category_id, category_value)); | 119 | dispatch(setCurrentCateB(category_id, category_value)); |
@@ -201,7 +201,10 @@ export function getCategoryBFirstSubCategoryDetail(channel_id) { | @@ -201,7 +201,10 @@ export function getCategoryBFirstSubCategoryDetail(channel_id) { | ||
201 | else if(channel_id == '4'){ | 201 | else if(channel_id == '4'){ |
202 | category = categoryList.get('lifestyle').get(0); | 202 | category = categoryList.get('lifestyle').get(0); |
203 | } | 203 | } |
204 | - dispatch(getCategoryBSubCategoryDetail(category.get('category_id'), category.get('category_name'))); | 204 | + |
205 | + let category_id = category ? category.get('category_id') : ""; | ||
206 | + let category_name = category ? category.get('category_name') : ""; | ||
207 | + dispatch(getCategoryBSubCategoryDetail(category_id, category_name)); | ||
205 | }; | 208 | }; |
206 | } | 209 | } |
207 | 210 |
-
Please register or login to post a comment