<import src="goods-actions"/>

<template name="sub-goods">
  <view class="sub-goods">
    <view class="sub-goods__overlay" bindtap="hideSubGoods"></view>
    <view class="sub-goods__content">
      <icon bindtap="hideSubGoods" class="sub-goods__close" type="cancel" size="25" color="#999"/>
      <view class="sub-goods__hd">
        {{goods_name}}
      </view>
      <view class="sub-goods__bd">
        <view >规格: </view>
        <view class="sub-goods__list">
          <view data-sub-index="{{index}}" bindtap="changeSubGoods" wx:for="{{sub_goods}}" wx:key="sub_id" class="sub-goods__item {{index == activeIndex? 'sub-goods__item_active': ''}} ">
            {{item.sub_name}}
          </view>
        </view>
      </view>
      <view class="sub-goods__ft weui-flex">
        <view class="weui-flex__item">
          <text class="primary-color sub-goods__price">¥{{sub_goods[activeIndex]['price']}}</text>
          <text class="text-small">({{sub_goods[activeIndex]['sub_name']}})</text>
        </view>
        <template is="goods-actions" wx:if="{{subNums[sub_goods[activeIndex]['sub_id']] > 0}}"  data="{{goods_id, sub_id: sub_goods[activeIndex]['sub_id'], num: subNums[sub_goods[activeIndex]['sub_id']]}}"></template>
        <view data-goods-id="{{goods_id}}" data-sub-id="{{sub_goods[activeIndex]['sub_id']}}" bindtap="increase" wx:else class="sub-goods__add-cart">
          加入购物车
        </view>
      </view>
    </view>
  </view>
</template>