<!--pages/chat/chat.wxml-->
<block wx:if="{{noticeText}}" class="noticeBar">
  <VanNoticeBar color="#ffffff" background="#4ac987" left-icon="volume-o" mode="link" text="{{noticeText}}" bindtap="goToProductDetail" />
</block>
<view class="content" id='scrollSingel' bindtap="contentWatch">
  <view class="chatItem" wx:for="{{chatList}}" wx:key="index">
    <view class="{{item.id == 1 ? 'chatContent right' : 'chatContent left'}}">

      <image class="{{isResponing ? 'chatGpt isResponing' : 'chatGpt'}}" wx:if="{{!item.id}}" src="../../asset/icon/tiny-Chat-rotate.png" mode="heightFix" />

      <view class="{{istouching && istouchingIndex ==  index ? 'textShape istouching' : 'textShape'}}" bindtouchstart="messageTouchStart" bindtouchend="messageTouchEnd" data-index="{{index}}">

        <image wx:if="{{item.id != 1}}" class="arrowWhite" src="../../asset/icon/arrowWhite.png" mode="heightFix" />

        <view class="{{item.id == 1 ? 'message right' : 'message left'}}">
          <text user-select="true">{{item.message}}</text>
          <image class="loading" wx:if="{{item.id == 1 && (index + 1 == chatList.length) && isLoading}}" src="../../asset/icon/loading.png" mode="heightFix" />
          <!-- <view wx:if="{{item.id == 1}}" id="copyBox" class="{{isHolding && istouchingIndex ==  index ? 'copyBoxRight active' : 'copyBoxRight'}}" bindtap="copyMessage" data-message="{{item.message}}">
            <view class="boxInside">
              <view class="text">复制</view>
              <image class="arrowBlack" src="../../asset/icon/arrowBlack.png" mode="heightFix" />
            </view>
          </view> -->

          <view wx:if="{{item.id != 1}}" id="copyBox" class="{{isHolding && istouchingIndex ==  index ? 'copyBoxLeft active' : 'copyBoxLeft'}}" bindtap="copyMessage" data-message="{{item.message}}">
            <view class="boxInside">
              <view class="text">复制</view>
              <image class="arrowBlack" src="../../asset/icon/arrowBlack.png" mode="heightFix" />
            </view>
          </view>
        </view>

        <image wx:if="{{item.id == 1}}" class="arrowGreen" src="../../asset/icon/arrowGreen.png" mode="heightFix" />
      </view>

      <image class="userAvatar" wx:if="{{item.id && item.id == 1}}" src="../../asset/icon/UserSelect.png" mode="heightFix" />
    </view>
  </view>
  <view class='over' wx:if="{{reLoadSocket}}">聊天已挂起</view>
</view>

<view class="chatBox">
  <view wx:if="{{ inputMode }}" class="boxOutside">
    <image class="voiceBtn" mode="heightFix" src="../../asset/icon/voice.png" bindtap="voiceMode"></image>
    <input class="inputBox" type="text" bindinput="input" value="{{message}}" placeholder="单次最多可输入{{saysContentLength}}字" cursor-spacing="20" confirm-type="send" bindconfirm="send" />
    <button class="sendBtn" type="primary" bindtap="send">发送</button>
  </view>

  <view wx:if="{{ !inputMode }}" class="boxOutside">
    <image class="voiceBtn" mode="heightFix" src="../../asset/icon/keyboard.png" bindtap="voiceMode"></image>
    <button class="pushBtn" type="primary" bindtouchstart="speakStart" bindtouchend="speakEnd">按住 说话</button>
  </view>
</view>