msglist.wxml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!--comps/msglist/msglist.wxml-->
  2. <template name="txt">
  3. <text class="msg-text" style="float:left;">{{ item.data }}</text>
  4. </template>
  5. <template name="emoji">
  6. <image class="avatar" src="{{ '../../../images/faces/' + item.data }}" style="width:25px; height:25px; margin:0 0 2px 0; float:left;" />
  7. </template>
  8. <template name="img">
  9. <image class="avatar msg-img" src="{{item.msg.data}}" mode="aspectFit" bind:tap="previewImage" data-url="{{item.msg.data}}" />
  10. </template>
  11. <template name="video">
  12. <video class="msg-video" bindfullscreenchange="onFullscreenchange" src="{{ item.msg.data }}" controls autoplay />
  13. </template>
  14. <template name="audio">
  15. <audio src="{{ item.msg.url }}" controls autoplay />
  16. </template>
  17. <!-- view 换成 scroll-view效果更好 用view是为了要stopPullDownRefresh -->
  18. <scroll-view scroll-y="true" class="{{view}} wrap {{isIPX?'scroll_view_X': ''}}" bind:tap="onTap" bindscroll="scrollmore" bindscrolltoupper="refresh" upper-threshold='-50' scroll-into-view="{{toView}}">
  19. <view class="message" wx:for="{{chatMsg}}" wx:key="mid" id="{{item.mid}}">
  20. <view class="{{item.style == 'self' ? 'row-right' : 'row-left'}}">
  21. <image class="photo" src="{{item.info.fromInfo.avatarurl || imgPath +'/chat-user.png'}}" wx:if="{{item.style != 'self'}}"></image>
  22. <view class="msgbox">
  23. <text class="user-text" wx:if="{{item.style != 'self'}}">{{item.info.fromInfo.nickname + ' ' + item.time}}</text>
  24. <text class="user-text" wx:if="{{item.style == 'self'}}">{{item.time + ' ' + item.info.fromInfo.nickname}}</text>
  25. <view wx:if="{{ item.msg.type == 'img' || item.msg.type == 'video' }}">
  26. <template is="{{ item.msg.type }}" data="{{ item }}" />
  27. </view>
  28. <audio-msg wx:if="{{ item.msg.type == 'audio' }}" msg="{{ item }}"></audio-msg>
  29. <view wx:elif="{{ item.msg.type == 'txt' || item.msg.type == 'emoji' }}" data-msg="{{item}}" bindtap="clickMsg">
  30. <view class="template" wx:for="{{ item.msg.data }}" wx:key="item">
  31. <template is="{{ item.type }}" data="{{ item }}" />
  32. </view>
  33. </view>
  34. </view>
  35. <image class="photo" src="{{item.info.fromInfo.avatarurl || imgPath +'/chat-user.png'}}" wx:if="{{item.style == 'self'}}"></image>
  36. </view>
  37. </view>
  38. </scroll-view>
  39. <view style="height: 1px;"></view>