index.wxml 1.5 KB
<view class="tab-bar">
  <view class="tab-bar-border"></view>
  <block wx:for="{{list}}" wx:key="pagePath">
    <view
      class="tab-bar-item {{item.isMatters ? 'tab-bar-item--matters' : ''}} {{item.isMatters && selected === index ? 'tab-bar-item--matters-on' : ''}}"
      data-path="{{item.pagePath}}"
      data-index="{{index}}"
      bindtap="switchTab"
    >
      <block wx:if="{{item.isMatters}}">
        <view class="tab-bar-matters-box">
          <block wx:if="{{selected === index}}">
            <image
              class="tab-bar-matters-act-icon"
              src="{{item.selectedIconPath}}"
              mode="aspectFit"
            />
          </block>
          <block wx:else>
            <image class="tab-bar-icon" src="{{item.iconPath}}" mode="aspectFit" />
            <text class="tab-bar-text">{{item.text}}</text>
          </block>
        </view>
      </block>
      <block wx:else>
        <view class="tab-bar-icon-wrap">
          <image
            class="tab-bar-icon-layer"
            src="{{item.iconPath}}"
            mode="aspectFit"
            style="opacity: {{selected === index ? 0 : 1}};"
          />
          <image
            class="tab-bar-icon-layer"
            src="{{item.selectedIconPath}}"
            mode="aspectFit"
            style="opacity: {{selected === index ? 1 : 0}};"
          />
        </view>
        <text class="tab-bar-text" style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</text>
      </block>
    </view>
  </block>
</view>