<template>
<div @longpress="long">
<!-- 时间显示 -->
<view v-if="showTime"
class="flex align-center justify-center pb-4 pt-2">
<text class="font-sm text-light-muted">{{showTime}}</text>
</view>
<!-- 撤回消息 -->
<view v-if="item.isremove == 1" ref="isremove"
class="flex align-center justify-center pb-4 pt-1">
<text class="font-sm text-light-muted">{{ isself ? '你' : '对方' }}撤回了一条信息</text>
</view>
<!-- 系统消息 -->
<view v-if="item.type === 'system'" ref="isremove"
class="flex align-center justify-center pb-4 pt-1">
<text class="font-sm text-light-muted">{{item.data}}</text>
</view>
<!-- 进群消息 -->
<view v-if="item.type === 'join'"
class="flex align-center justify-center pb-4 pt-1">
<text class="font-sm text-light-muted">{{item.data}}</text>
</view>
<!-- 进群消息 -->
<view v-if="item.type === 'invite'"
class="flex align-center justify-center pb-4 pt-1">
<text class="font-sm text-light-muted">{{item.data}}</text>
<text class="font-sm text-light-muted text-info" @click="inviteConfirm">{{item.isconfirm ? "已确认":"确认"}}</text>
</view>
<!-- 气泡 -->
<view v-if="item.type !== 'system' && item.type !== 'join' && item.type !== 'invite' && item.isremove == 0" class="flex align-start position-relative mb-3"
:class="!isself ? 'justify-start' : 'justify-end'">
<!-- 好友 -->
<template v-if="!isself">
<free-avater size="70" :src="item.from_avatar" @click="openUser"></free-avater>
<text v-if="hasLabelClass" class="iconfont text-white font-md position-absolute chat-left-icon" :style="shownickname ? 'top:45rpx;':'top:20rpx;'"></text>
</template>
<view class="flex flex-column">
<!-- 昵称 -->
<view v-if="shownickname" class="flex" :class="nicknameClass" style="max-width:500rpx;background-color: rgba(0,0,0,0);" :style="labelStyle">
<text class="font-sm text-muted">{{item.from_name}}</text>
</view>
<div class="p-2 rounded" :class="labelClass" style="max-width:500rpx;" :style="labelStyle">
<!-- 文字 -->
<text v-if="item.type === 'text'" class="font-md">{{item.data}}</text>
<!-- 表情包 | 图片-->
<free-image @longpress="stop" v-else-if="item.type === 'emoticon' || item.type === 'image'" :src="item.data" @click="preview(item.data)" imageClass="rounded" :maxWidth="500" :maxHeight="350"></free-image>
<!-- 音频 -->
<view v-else-if="item.type === 'audio'"
class="flex align-center"
@tap="openAudio" @longpress="stop">
<image v-if="isself" :src=" !audioPlaying ? '/static/audio/audio3.png' : '/static/audio/play.gif'"
style="width: 50rpx;height: 50rpx;"
class="mx-1"></image>
<text class="font">{{item.options.time + '"'}}</text>
<image v-if="!isself" :src=" !audioPlaying ? '/static/audio/audio3.png' : '/static/audio/play.gif'"
style="width: 50rpx;height: 50rpx;"
class="mx-1"></image>
</view>
<!-- 视频 -->
<view v-else-if="item.type === 'video'"
class="position-relative rounded"
@tap="openVideo" @longpress="stop">
<free-image :src="item.options.poster" imageClass="rounded" :maxWidth="300" :maxHeight="350" @load="loadPoster"></free-image>
<text class="iconfont text-white position-absolute" style="font-size: 80rpx;width: 80rpx;height: 80rpx;" :style="posterIconStyle"></text>
</view>
<!-- 名片 -->
<view v-else-if="item.type === 'card'" class="bg-white" style="width: 400rpx;" hover-class="bg-light" @tap="openUserBase" @longpress="stop">
<view class="p-3 flex align-center border-bottom border-light-secondary">
<free-avater size="70"
:src="item.options.avatar"
clickType="navigate"></free-avater>
<text class="font ml-2">{{item.data}}</text>
</view>
<view class="flex align-center p-2">
<text class="font-small text-muted">个人名片</text>
</view>
</view>
</div>
</view>
<!-- 本人 -->
<template v-if="isself">
<text v-if="hasLabelClass" class="iconfont text-chat-item font-md position-absolute chat-right-icon" :style="shownickname ? 'top:45rpx;':'top:20rpx;'"></text>
<free-avater size="70" :src="item.from_avatar"
@click="openUser"></free-avater>
</template>
</view>
<view v-if="item.sendStatus && item.sendStatus !== 'success'" class="flex align-center justify-end px-4">
<text class="font-sm" :class="item.sendStatus === 'fail' ? 'text-danger' : 'text-muted'">{{item.sendStatus === 'fail' ? '发送失败' : '发送中...'}}</text>
</view>
</div>
</template>
这是列表内容,用的list 循环渲染出来的 free-chat-item 就是自定义组件,调用的上面的内容
<list scrollable show-scrollbar="false" class="bg-light position-fixed left-0 right-0 px-3" style="bottom: 105rpx;box-sizing: border-box;" :style="chatBodyBottom" @click="clickPage">
<refresh class="align-center" @refresh="onrefresh" :display="refreshing ? 'show' : 'hide'">
</refresh>
<!-- 聊天信息列表组件 -->
<cell v-for="(item,index) in list" :key="item.id"
id="'chatItem_'+index">
<free-chat-item :item="item" :index="index" ref="chatItem"
pretime=" index > 0 ? list[index-1].create_time : 0"
@long="long" @preview="previewImage" @inviteConfirm="inviteConfirm"
shownickname="currentChatItem.shownickname"
</free-chat-item>
</cell>
</list>
比如在红米9a 这种老年机里面就非常卡,页面几乎不会动,但是同样的微信很流畅,为什么呢
0 个回复