<!--components/search-filter/index.wxml-->
<wxs src="../../pages/common.wxs" module="common"></wxs>
<view class='filter-wrapper' catchtouchmove="true">
  <i-row i-class='row-filter'>
    <i-col span="6">
      <view class="filter-item">
        <text class="{{filter_idx==1?'active':''}}" catchtap='filterTap' data-idx="1">{{selected_titles.type}}</text>
        <image class="search-icon" src="/images/icon-down-select{{filter_idx==1?'ed':''}}.png"></image>
      </view>
    </i-col>
    <i-col span="6" i-class="col-class">
      <view class="filter-item">
        <text class="{{filter_idx==2?'active':''}}" catchtap='filterTap' data-idx="2">{{selected_titles.catalog}}</text>
        <image class="search-icon" src="/images/icon-down-select{{filter_idx==2?'ed':''}}.png"></image>
      </view>
    </i-col>
    <!-- 地区筛选 -->
    <i-col span="6" i-class="col-class">
      <view class="filter-item">
        <text class="{{filter_idx==3?'active':''}}" catchtap='filterTap' data-idx="3">{{selected_titles.region}}</text>
        <image class="search-icon" src="/images/icon-down-select{{filter_idx==3?'ed':''}}.png"></image>
      </view>
    </i-col>
    <i-col span="6" i-class="col-class">
      <view class="filter-item">
        <text class="{{filter_idx==4?'active':''}}" catchtap='filterTap' data-idx="4">标签{{selected.tags.length>0?'('+selected.tags.length+')':''}}</text>
        <image class="search-icon" src="/images/icon-down-select{{filter_idx==4?'ed':''}}.png"></image>
      </view>
    </i-col>
  </i-row>
  <view catchtap='closeFilter' class='filter-content-wrapper' wx:if="{{filter_idx>0}}" catchtouchmove='true'>
    <view class="row-content" catchtap='preventEvent'>
      <scroll-view class="scroll-view" scroll-y="true" style="width: 100%;height: 100%;" wx:if="{{filter_idx!=4}}">
        <view wx:if="{{filter_idx==1}}" class='filter-row' wx:for="{{types}}" wx:for-index="idx" wx:for-item="n" wx:key="n.id">
          <text bindtap="selectFilter" data-idx="{{n.id}}" data-name="{{n.name}}" class="{{selected.type==n.id?'seled':''}}">{{n.name}}</text>
          <image wx:if="{{selected.type==n.id}}" class="f-selected" src='/images/icon_filter_selected.png'></image>
        </view>
        <view wx:if="{{filter_idx==2}}" class='filter-row' wx:for="{{catalogs}}" wx:for-index="idx" wx:for-item="n" wx:key="n.id">
          <text bindtap="selectFilter" data-idx="{{n.id}}" data-name="{{n.name}}">{{n.name}}</text>
          <image wx:if="{{selected.catalog==n.id}}" class='f-selected' src='/images/icon_filter_selected.png'></image>
        </view>
        <!-- 地区选项 -->
        <view wx:if="{{filter_idx==3}}" class='filter-row' wx:for="{{regions}}" wx:for-index="idx" wx:for-item="n" wx:key="n.id">
          <text bindtap="selectFilter" data-idx="{{n.id}}" data-name="{{n.name}}">{{n.name}}</text>
          <image wx:if="{{selected.region==n.id}}" class='f-selected' src='/images/icon_filter_selected.png'></image>
        </view>
      </scroll-view>
      <scroll-view class="tab-scroll-view" scroll-y="true" wx:if="{{filter_idx==4}}">
    <view class="tags-wrapper">
        <block wx:for="{{tags}}" wx:for-index="idx" wx:for-item="n" wx:key="n.id">
          <view class="tag-item {{common.inArray(selected.tags, n.id)==true?'active':''}}" bindtap="selectTags" data-idx="{{n.id}}">
            {{n.name}}
          </view>
        </block>
    </view>
     </scroll-view>
      <view class="tag-btn-wrapper" wx:if="{{filter_idx==4}}">
          <button class="btn cancel" bindtap="cancelSelectTags">取消选择</button>
          <button class="btn ensure" bindtap="ensureSelectTags">确定</button>
    </view>
    </view>
  </view>
</view>