<wxs module="_">
  module.exports.active = function (lastId, id) {
    return lastId === id;
  }
  module.exports.show = function (message, component) {
    return message && message.component === component;
  }
</wxs>

<!--module/chats/pages/index/index.wxml-->
<view class="chats-container">
  <t-navbar title="{{i18n.chats.title}}" />
  <scroll-view 
    id="scrollview" 
    class="page-scroll__container" 
    type="list" 
    scroll-y 
    enhanced="{{true}}" 
    enable-passive 
    scroll-into-view="{{lastId}}" 
    scroll-into-view-alignment="end" 
    style="height: calc(100vh - 180rpx); padding-bottom:{{paddingBottom}}rpx;"
  >
    <view class="system-wrapper">
      <view class="date">{{date}}</view>
      <view class="title">{{i18n.chats.title}} 已进入聊天</view>
    </view>
    
    <block wx:for="{{messages}}" wx:index="{{index}}" wx:key="id">
      <chat-guide wx:if="{{(_.show(item, 'guide') && isShowGuide)}}" id="{{item.id}}" active="{{_.active(lastId, item.id)}}" bind:next="handle" bind:to="scrollIntoView" bind:nextType="nextType" bind:getCount="getCount" analysisCount="{{analysisCount}}" />
      <chat-questionnaire wx:if="{{_.show(item, 'questionnaire') && messageType}}" id="{{item.id}}" active="{{_.active(lastId, item.id)}}" bind:next="handle" 
      bind:to="scrollIntoView" bind:nextType="nextType" messageType="{{messageType}}" workId="{{id}}" bind:boxBottom="boxBottom" />
    </block>
    <!-- 固定底部锚点，便于 lastId='bottom' 时稳定滚动到最底部 -->
    <view id="bottom" style="height: 1rpx;"></view>
  </scroll-view>

  <view class="tabbar-container">
    <tabbar tabbarValue="{{tabbarValue}}"></tabbar>
  </view>
</view>