422 lines
11 KiB
Vue
422 lines
11 KiB
Vue
<!-- 聊天item -->
|
|
<template>
|
|
<view class="chat-item">
|
|
<view v-if="copyFlag" class="chat-content-operate"
|
|
:class="[item.selfStatus?'chat-content-operate-r':'chat-content-operate-l']">
|
|
<text class="chat-content-operate-text" @click="copyFn">复制</text>
|
|
<text class="chat-content-operate-text" @click="withdrawFn"
|
|
style="border-left: 1rpx solid #eeeeee;">撤回</text>
|
|
</view>
|
|
<text class="chat-time" v-if="item.chatTime&&item.chatTime.length">
|
|
{{item.chatTime}}
|
|
</text>
|
|
<view :class="{'chat-container':true,'chat-location-me':item.selfStatus}">
|
|
<view class="chat-icon-container" @click="navUserFn(item)">
|
|
<image class="chat-icon" :src="item.avatar" mode="aspectFill" />
|
|
</view>
|
|
<view class="chat-content-container" @longpress="showActions()" @click="copyFlag=false">
|
|
<!-- <text :class="{'chat-user-name':true,'chat-location-me':item.selfStatus}">
|
|
{{item.nickname}}
|
|
</text> -->
|
|
<image v-if="item.selfStatus===true" class="mess_l" src="@/static/images/app/icon/mess_r.png" mode="">
|
|
</image>
|
|
<image v-else class="mess_r" src="@/static/images/app/icon/mess_l.png" mode=""></image>
|
|
<template v-if="item.msgType ===0">
|
|
<view :class="{'chat-text-container':true,'chat-text-container-me':item.selfStatus}">
|
|
<text :class="{'char-text':true,'char-text-me':item.selfStatus}"
|
|
:style="'font-size:36rpx;color:'+(item.selfStatus?'#000;':'#333;')">{{item.content}}</text>
|
|
</view>
|
|
</template>
|
|
<template v-else-if="item.msgType ===1">
|
|
<view
|
|
:class="{'chat-text-container-me-border-radius':item.selfStatus,'chat-text-container-border-radius':true}"
|
|
@click.stop="previewImage(item.content)">
|
|
<u--image :radius="'16rpx 16rpx 16rpx 16rpx'" :src="item.content" width="85" height="131" />
|
|
</view>
|
|
</template>
|
|
<template v-else-if="item.msgType ===2">
|
|
<view
|
|
:class="{'chat-text-container-me-border-radius':item.selfStatus,'chat-text-container-border-radius':true}"
|
|
style="position: relative;">
|
|
<image @click.stop="videoPlay(item.content)"
|
|
:src="item.content+'?x-oss-process=video/snapshot,t_1000,m_fast'"
|
|
style="width: 170rpx;height:262rpx;overflow: hidden;"
|
|
:style="{borderRadius:'16rpx 16rpx 16rpx 16rpx'}" />
|
|
<view :class="{'chat-video-container-me':item.selfStatus,'chat-video-container':true}"
|
|
@click.stop="videoPlay(item.content)">
|
|
<image mode="aspectFit"
|
|
src="https://qicheoss.oss-cn-shanghai.aliyuncs.com/xcximage/douyin/play.png"
|
|
style="width: 60rpx;height: 60rpx;opacity: 0.6;" />
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<template v-else-if="item.msgType ===4">
|
|
<view
|
|
:class="{'chat-text-container-me-border-radius':item.selfStatus,'chat-text-container-border-radius':true}"
|
|
style="position: relative;"
|
|
@click="Navto({url:'/pages/driver/goods/goods_details/index',type:'redirectTo',params:{id:goodsDetai(item.content).id}})">
|
|
<u--image :src="goodsDetai(item.content).image" width="85" height="131" />
|
|
<view
|
|
style="position: absolute;bottom: 0;left: 0;padding: 8rpx 4rpx;background-color: rgba(0, 0, 0, 0.5);border-radius: 16rpx 0 16rpx 16rpx;">
|
|
<u--text :text="goodsDetai(item.content).name" size="10" lines="1" color="#fff" />
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<template v-else-if="item.msgType ===5">
|
|
<view
|
|
:class="{'chat-text-container-me-border-radius':item.selfStatus,'chat-text-container-border-radius':true}"
|
|
style="position: relative;"
|
|
@click.stop="Navto({url:'/pages/driver/discover/discover_video/index',type:'redirectTo',params:{noteId:discoverVideo(item.content).id}})">
|
|
<image :src="discoverVideo(item.content).image"
|
|
style="width: 170rpx;height:262rpx;border-radius: 16rpx;overflow: hidden;" />
|
|
<view :class="{'chat-video-container-me':item.selfStatus,'chat-video-container':true}">
|
|
<image mode="aspectFit"
|
|
src="https://qicheoss.oss-cn-shanghai.aliyuncs.com/xcximage/douyin/play.png"
|
|
style="width: 60rpx;height: 60rpx;opacity: 0.6;" />
|
|
</view>
|
|
<view
|
|
style="position: absolute;bottom: 8rpx;left: 0;padding: 8rpx 4rpx;background-color: rgba(0, 0, 0, 0.5);border-radius: 14rpx;">
|
|
<u--text :text="discoverVideo(item.content).name" size="10" lines="1" color="#fff" />
|
|
</view>
|
|
</view>
|
|
</template>
|
|
<template v-else-if="item.msgType === 6">
|
|
<!-- :class="{'chat-text-container-me-border-radius':item.selfStatus,'chat-text-container-border-radius':true}" -->
|
|
<view
|
|
:class="item.selfStatus===true?'chat-text-container-me-border-radius':'chat-text-container-border-radius'"
|
|
style="position: relative;"
|
|
@click.stop="Navto({url:`/pages/driver/mine/my_activity/detail?type=help&id=${JSON.parse(item.content).id}&uid=${item.uid}&fromUid=${JSON.parse(item.content).fromUid}`,type:'redirectTo',params:{noteId:discoverVideo(item.content).id}})">
|
|
<!-- <view class="activity-box"> -->
|
|
<view>
|
|
<text style="font-size: 24rpx;">点击助力好友</text>
|
|
</view>
|
|
<view class="activity-item">
|
|
<image style="width: 350rpx;height: 350rpx;" :src="JSON.parse(item.content).cover" mode="">
|
|
</image>
|
|
<view class="activity-item-info">
|
|
<view class="activity-item-name">
|
|
<text
|
|
style="font-size: 32rpx;font-weight: 500;color: #000000;">{{JSON.parse(item.content).name}}</text>
|
|
</view>
|
|
<view class="activity-item-intro">
|
|
<text
|
|
style="font-size: 28rpx;font-weight: 500;color: #444444;">{{JSON.parse(item.content).intro}}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<!-- </view> -->
|
|
</view>
|
|
</template>
|
|
</view>
|
|
</view>
|
|
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
immsgRecall
|
|
} from '@/api/message/index.js';
|
|
export default {
|
|
name: "chat-item",
|
|
props: {
|
|
item: {
|
|
type: Object,
|
|
default () {
|
|
return {
|
|
chatTime: '',
|
|
avatar: '',
|
|
nickname: '',
|
|
content: '',
|
|
selfStatus: false,
|
|
}
|
|
}
|
|
},
|
|
index: 0
|
|
},
|
|
data() {
|
|
return {
|
|
copyFlag: false,
|
|
};
|
|
},
|
|
mounted() {
|
|
// console.log('vue,',this.item);
|
|
},
|
|
computed: {
|
|
//商品详情
|
|
goodsDetai() {
|
|
return (val) => {
|
|
return JSON.parse(val)
|
|
}
|
|
},
|
|
//短视频详情
|
|
discoverVideo() {
|
|
return (val) => {
|
|
return JSON.parse(val)
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
//复制
|
|
copyFn() {
|
|
console.log('复制', this.item);
|
|
this.copyFlag = false
|
|
uni.setClipboardData({
|
|
data: this.item.content,
|
|
success: () => {
|
|
uni.showToast({
|
|
title: '复制成功',
|
|
duration: 2000,
|
|
})
|
|
}
|
|
});
|
|
},
|
|
//撤回
|
|
withdrawFn() {
|
|
console.log('//撤回', this.item);
|
|
this.copyFlag = false
|
|
console.log(this.item.id);
|
|
immsgRecall(this.item.id).then(res=>{
|
|
console.log(res);
|
|
this.getMsgListFns()
|
|
uni.showToast({
|
|
title: '撤回成功',
|
|
duration: 2000,
|
|
})
|
|
})
|
|
},
|
|
//长嗯
|
|
showActions() {
|
|
console.log('长嗯', this.copyFlag, this.item);
|
|
this.copyFlag = true
|
|
},
|
|
navUserFn(item) {
|
|
console.log(item);
|
|
uni.navigateTo({
|
|
url: `/pages/driver/mine/personal_center/personal_center?uid=${item.srcUid}`
|
|
})
|
|
},
|
|
previewImage(img) {
|
|
uni.previewImage({
|
|
urls: [img],
|
|
current: 0
|
|
});
|
|
},
|
|
//播放视频
|
|
videoPlay(e) {
|
|
this.$emit('videoPlay', e)
|
|
},
|
|
//撤回数据
|
|
getMsgListFns(e) {
|
|
this.$emit('getMsgListFns', this.index)
|
|
},
|
|
//跳转
|
|
Navto(url) {
|
|
uni.$u.route(url)
|
|
},
|
|
},
|
|
onLoad() {}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.chat-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
padding: 20rpx;
|
|
position: relative;
|
|
}
|
|
|
|
.chat-content-operate {
|
|
position: absolute;
|
|
height: 70rpx;
|
|
/* width: 120rpx; */
|
|
top: 30rpx;
|
|
background: #888888;
|
|
z-index: 99;
|
|
display: flex;
|
|
align-items: center;
|
|
flex-direction: row;
|
|
justify-content: space-around;
|
|
border-radius: 16rpx;
|
|
}
|
|
|
|
.chat-content-operate-l {
|
|
left: 120rpx;
|
|
}
|
|
|
|
.chat-content-operate-r {
|
|
right: 120rpx;
|
|
}
|
|
|
|
.chat-content-operate-text {
|
|
padding: 0 16rpx;
|
|
/* border-radius: 16rpx; */
|
|
font-size: 24rpx;
|
|
color: #eee;
|
|
|
|
}
|
|
|
|
.chat-time {
|
|
padding: 24rpx 0rpx;
|
|
text-align: center;
|
|
font-size: 22rpx;
|
|
color: #aaa;
|
|
}
|
|
|
|
.chat-container {
|
|
display: flex;
|
|
flex-direction: row;
|
|
/* border: 1px solid green; */
|
|
}
|
|
|
|
.chat-video-container-me {
|
|
margin-left: 0;
|
|
/* #ifdef H5 */
|
|
right: 50rpx;
|
|
/*#endif*/
|
|
/* #ifdef MP */
|
|
right: 100rpx;
|
|
/*#endif*/
|
|
}
|
|
|
|
.chat-video-container {
|
|
position: absolute;
|
|
top: 100rpx;
|
|
flex: 1;
|
|
justify-content: center;
|
|
margin-left: 50rpx;
|
|
align-items: center;
|
|
}
|
|
|
|
.chat-text-container-me-border-radius {
|
|
/* border-radius: 16rpx 0 16rpx 16rpx; */
|
|
border-radius: 16rpx 16rpx 16rpx 16rpx;
|
|
padding: 16rpx;
|
|
background-color: #FFF;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.chat-text-container-border-radius {
|
|
border-radius: 16rpx 16rpx 16rpx 16rpx;
|
|
padding: 16rpx;
|
|
background-color: #FFF;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.chat-location-me {
|
|
flex-direction: row-reverse;
|
|
text-align: right;
|
|
}
|
|
|
|
.chat-icon-container {
|
|
margin-top: 12rpx;
|
|
/* border: 1px solid green; */
|
|
}
|
|
|
|
.chat-icon {
|
|
width: 80rpx;
|
|
height: 80rpx;
|
|
border-radius: 50%;
|
|
background-color: #eee;
|
|
}
|
|
|
|
.chat-content-container {
|
|
margin: 0rpx 8rpx;
|
|
position: relative;
|
|
/* border: 1px solid yellow; */
|
|
}
|
|
|
|
.chat-user-name {
|
|
font-size: 26rpx;
|
|
color: #888;
|
|
}
|
|
|
|
.chat-text-container {
|
|
background-color: #FFF;
|
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
|
padding: 22rpx 24rpx;
|
|
margin: 10rpx 0 0 10rpx;
|
|
max-width: 500rpx;
|
|
/* border: 1px solid red; */
|
|
}
|
|
|
|
.chat-text-container-me {
|
|
background-color: #84D2CF;
|
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
|
margin-right: 10rpx;
|
|
max-width: 500rpx;
|
|
/* border: 1px solid black; */
|
|
}
|
|
|
|
|
|
.mess_r {
|
|
position: absolute;
|
|
top: 18rpx;
|
|
left: 0rpx;
|
|
width: 52rpx;
|
|
height: 44rpx;
|
|
z-index: -1;
|
|
/* border: 1px solid black; */
|
|
}
|
|
|
|
.mess_l {
|
|
position: absolute;
|
|
top: 18rpx;
|
|
right: 0rpx;
|
|
width: 52rpx;
|
|
height: 44rpx;
|
|
z-index: -1;
|
|
/* border: 1px solid red; */
|
|
}
|
|
|
|
.char-text {
|
|
font-size: 28rpx;
|
|
max-width: 500rpx;
|
|
word-break: break-all;
|
|
z-index: 9999;
|
|
}
|
|
|
|
.char-text-me {
|
|
color: white;
|
|
z-index: 9999;
|
|
}
|
|
|
|
.video {
|
|
width: 170rpx;
|
|
height: 262rpx;
|
|
}
|
|
|
|
.activity-box {
|
|
padding: 16rpx;
|
|
background-color: #FFF;
|
|
}
|
|
|
|
.activity-item {
|
|
margin-top: 16rpx;
|
|
background: #F5F5F5;
|
|
border-radius: 4rpx;
|
|
/* .activity-item-info {
|
|
margin-left: 16rpx;
|
|
height: 124rpx;
|
|
line-height: 44rpx;
|
|
overflow: hidden;
|
|
.item {
|
|
margin-right: 12rpx;
|
|
padding: 0 12rpx;
|
|
line-height: 42rpx;
|
|
background-color: #FFFFFF;
|
|
}
|
|
} */
|
|
/* image {
|
|
width: 124rpx;
|
|
height: 124rpx;
|
|
} */
|
|
}
|
|
|
|
.activity-item-info {
|
|
width: 350rpx;
|
|
line-height: 44rpx;
|
|
overflow: hidden;
|
|
}
|
|
</style> |