chat 页面

This commit is contained in:
2022-02-18 09:58:15 +08:00
parent 1e7e589bab
commit 08971f256d
3 changed files with 21 additions and 12 deletions

View File

@@ -2,13 +2,18 @@
<view class="group--chat"> <view class="group--chat">
<list class="body" :show-scrollbar="false"> <list class="body" :show-scrollbar="false">
<cell class="cell" v-for="(item, index) in messages" :key="index"> <cell class="cell" v-for="(item, index) in messages" :key="index">
<view class="cell-system" v-if="item.senderUserId === '__system__'"> <text class="text">{{ item.content.message }}</text> </view> <view class="cell-system" v-if="item.senderUserId === '__system__'"> <text
class="text">{{ item.content.message }}</text> </view>
<view v-else :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']"> <view v-else :class="['cell-item', item.messageDirection == 1 ? 'right' : 'left']">
<u-avatar class="avatar" @click="toUser(item)" size="36" shape="square" :src="contact(item.senderUserId).portraitUrl" /> <u-avatar class="avatar" @click="toUser(item)" size="36" shape="square"
:src="contact(item.senderUserId).portraitUrl" />
<view class="msg"> <view class="msg">
<show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1" :msg="item.content" :name="contact(item.senderUserId).name" /> <show-voice v-if="item.objectName === 'RC:HQVCMsg'" :guest="item.messageDirection == 1"
<show-image v-if="item.objectName === 'RC:ImgMsg'" :guest="item.messageDirection == 1" :msg="item.content" :name="contact(item.senderUserId).name" /> :msg="item.content" :name="contact(item.senderUserId).name" />
<show-text v-if="item.objectName === 'RC:TxtMsg'" :guest="item.messageDirection == 1" :msg="item.content" :name="contact(item.senderUserId).name" /> <show-image v-if="item.objectName === 'RC:ImgMsg'" :guest="item.messageDirection == 1"
:msg="item.content" :name="contact(item.senderUserId).name" />
<show-text v-if="item.objectName === 'RC:TxtMsg'" :guest="item.messageDirection == 1"
:msg="item.content" :name="contact(item.senderUserId).name" />
</view> </view>
</view> </view>
</cell> </cell>
@@ -163,11 +168,13 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.group--chat { .group--chat {
background: $window-color; background: $window-color;
flex: 1; height: 100vh;
display: flex;
flex-direction: column;
.body { .body {
flex: 1; flex: 1;
.cell { .cell {
padding: 10rpx 30rpx; padding: 10rpx 30rpx;

View File

@@ -99,7 +99,7 @@
code, code,
conversations conversations
}) => { }) => {
if (code === 0) { if (code === 0) {
this.conversations = conversations this.conversations = conversations
} }
}) })

View File

@@ -15,7 +15,8 @@
<show-text v-if="item.objectName === 'RC:TxtMsg'" :guest="item.messageDirection == 1" <show-text v-if="item.objectName === 'RC:TxtMsg'" :guest="item.messageDirection == 1"
:msg="item.content" /> :msg="item.content" />
<view class="state" v-if="item.messageDirection == 1"> <view class="state" v-if="item.messageDirection == 1">
<text :class="item.sentStatus === 50?'state-text':'state-text-active'">{{ item.sentStatus == 50 ? '已读': '未读'}}</text> <text
:class="item.sentStatus === 50?'state-text':'state-text-active'">{{ item.sentStatus == 50 ? '已读': '未读'}}</text>
</view> </view>
</view> </view>
</view> </view>
@@ -169,8 +170,9 @@
/* 窗口 */ /* 窗口 */
.chat { .chat {
background: $window-color; background: $window-color;
flex: 1; height: 100vh;
display: flex;
flex-direction: column;
.body { .body {
flex: 1; flex: 1;
@@ -223,7 +225,7 @@
.state-text-active { .state-text-active {
font-size: $title-size-m - 2; font-size: $title-size-m - 2;
color: #cecece; color: #cecece;
} }
} }
} }