Commit 0a98958a2a33f0d4354193b8e1e12596ba64f419
1 parent
82539a1b
规格使用过滤器
Showing
2 changed files
with
13 additions
and
3 deletions
pages/goods/goodsInfo/goodsInfo.wxml
| ... | ... | @@ -464,7 +464,7 @@ |
| 464 | 464 | <text>规格</text> |
| 465 | 465 | </view> |
| 466 | 466 | <view class="item_right"> |
| 467 | - <text>{{data.goods_spec==""?"规格1":data.goods_spec}}</text> | |
| 467 | + <text>{{filters.show_gui_ge(data.goods_spec,data.goods_color)}}</text> | |
| 468 | 468 | </view> |
| 469 | 469 | </view> |
| 470 | 470 | <view class="tb_item tb-l"> | ... | ... |
utils/filter.wxs
| ... | ... | @@ -22,13 +22,23 @@ var filters = { |
| 22 | 22 | |
| 23 | 23 | pInt:function(t) { |
| 24 | 24 | var d = parseInt(t); return d; |
| 25 | - } | |
| 25 | + }, | |
| 26 | 26 | |
| 27 | + show_gui_ge:function(spec,color){ | |
| 28 | + if((spec=="" || spec==null)){ | |
| 29 | + if((color=="" || color==null)){ return "规格1"; | |
| 30 | + }else{return color; } | |
| 31 | + }else{ | |
| 32 | + if((color=="" || color==null)){ return spec; | |
| 33 | + }else{ return spec+"/"+color; } | |
| 34 | + } | |
| 35 | + } | |
| 27 | 36 | } |
| 28 | 37 | module.exports = { |
| 29 | 38 | toFix: filters.toFix, |
| 30 | 39 | replace_time:filters.replace_time, |
| 31 | 40 | replace_time2: filters.replace_time2, |
| 32 | 41 | format_time:filters.format_time, |
| 33 | - pInt:filters.pInt | |
| 42 | + pInt:filters.pInt, | |
| 43 | + show_gui_ge:filters.show_gui_ge | |
| 34 | 44 | } |
| 35 | 45 | \ No newline at end of file | ... | ... |